From: Roman Gushchin <guro@fb.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: linux-mm@kvack.org, Michal Hocko <mhocko@kernel.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
David Rientjes <rientjes@google.com>, Tejun Heo <tj@kernel.org>,
kernel-team@fb.com, cgroups@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [v5 2/4] mm, oom: cgroup-aware OOM killer
Date: Wed, 23 Aug 2017 17:20:31 +0100 [thread overview]
Message-ID: <20170823162031.GA13578@castle.dhcp.TheFacebook.com> (raw)
In-Reply-To: <20170822170344.GA13547@cmpxchg.org>
Hi Johannes!
Thank you for review!
I do agree with most of the comments, and I will address them in v6.
I'll post it soon.
Please, find some comments below.
On Tue, Aug 22, 2017 at 01:03:44PM -0400, Johannes Weiner wrote:
> Hi Roman,
>
> great work! This looks mostly good to me now. Below are some nitpicks
> concerning naming and code layout, but nothing major.
>
> > +
> > + css_task_iter_start(&memcg->css, 0, &it);
> > + while ((task = css_task_iter_next(&it))) {
> > + /*
> > + * If there are no tasks, or all tasks have oom_score_adj set
> > + * to OOM_SCORE_ADJ_MIN and oom_kill_all_tasks is not set,
> > + * don't select this memory cgroup.
> > + */
> > + if (!elegible &&
> > + (memcg->oom_kill_all_tasks ||
> > + task->signal->oom_score_adj != OOM_SCORE_ADJ_MIN))
> > + elegible = 1;
>
> This is a little awkward to read. How about something like this:
>
> /*
> * When killing individual tasks, we respect OOM score adjustments:
> * at least one task in the group needs to be killable for the group
> * to be oomable.
> *
> * Also check that previous OOM kills have finished, and abort if
> * there are any pending OOM victims.
> */
> oomable = memcg->oom_kill_all_tasks;
> while ((task = css_task_iter_next(&it))) {
> if (!oomable && task->signal_oom_score_adj != OOM_SCORE_ADJ_MIN)
> oomable = 1;
>
> > + if (tsk_is_oom_victim(task) &&
> > + !test_bit(MMF_OOM_SKIP, &task->signal->oom_mm->flags)) {
> > + elegible = -1;
> > + break;
> > + }
> > + }
> > + css_task_iter_end(&it);
We ignore oom_score_adj if oom_kill_all_tasks is set, it's
not reflected in your version. Anyway, I've moved the comments block
outside and rephrased it to make more clear.
>
> etc.
>
> > +
> > + return elegible > 0 ? memcg_oom_badness(memcg, nodemask) : elegible;
>
> I find these much easier to read if broken up, even if it's more LOC:
>
> if (eligible <= 0)
> return eligible;
>
> return memcg_oom_badness(memcg, nodemask);
>
> > +static void select_victim_memcg(struct mem_cgroup *root, struct oom_control *oc)
> > +{
> > + struct mem_cgroup *iter, *parent;
> > +
> > + for_each_mem_cgroup_tree(iter, root) {
> > + if (memcg_has_children(iter)) {
> > + iter->oom_score = 0;
> > + continue;
> > + }
> > +
> > + iter->oom_score = oom_evaluate_memcg(iter, oc->nodemask);
> > + if (iter->oom_score == -1) {
>
> Please add comments to document the special returns. Maybe #defines
> would be clearer, too.
>
> > + oc->chosen_memcg = (void *)-1UL;
> > + mem_cgroup_iter_break(root, iter);
> > + return;
> > + }
> > +
> > + if (!iter->oom_score)
> > + continue;
>
> Same here.
>
> Maybe a switch would be suitable to handle the abort/no-score cases.
Not sure about switch/defines, but I've added several comment blocks
to describe possible return values, as well as their handling.
Hope, it will be enough.
> > static int memory_events_show(struct seq_file *m, void *v)
> > {
> > struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
> > @@ -5310,6 +5512,12 @@ static struct cftype memory_files[] = {
> > .write = memory_max_write,
> > },
> > {
> > + .name = "oom_kill_all_tasks",
> > + .flags = CFTYPE_NOT_ON_ROOT,
> > + .seq_show = memory_oom_kill_all_tasks_show,
> > + .write = memory_oom_kill_all_tasks_write,
> > + },
>
> This name is quite a mouthful and reminiscent of the awkward v1
> interface names. It doesn't really go well with the v2 names.
>
> How about memory.oom_group?
I'd prefer to have something more obvious. I've renamed
memory.oom_kill_all_tasks to memory.oom_kill_all, which was earlier suggested
by Vladimir. Are you ok with it?
Thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-08-23 16:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-14 18:32 [v5 1/4] mm, oom: refactor the oom_kill_process() function Roman Gushchin
2017-08-14 18:32 ` [v5 0/4] cgroup-aware OOM killer Roman Gushchin
2017-08-14 18:32 ` [v5 2/4] mm, oom: " Roman Gushchin
2017-08-14 22:42 ` David Rientjes
2017-08-15 12:15 ` Roman Gushchin
2017-08-15 12:20 ` Aleksa Sarai
2017-08-15 12:57 ` Roman Gushchin
2017-08-15 21:47 ` David Rientjes
2017-08-16 15:43 ` Roman Gushchin
2017-08-21 0:50 ` David Rientjes
2017-08-21 9:46 ` Roman Gushchin
2017-08-22 17:03 ` Johannes Weiner
2017-08-23 16:20 ` Roman Gushchin [this message]
2017-08-23 17:24 ` Johannes Weiner
2017-08-23 18:04 ` Roman Gushchin
2017-08-23 23:13 ` David Rientjes
2017-08-14 18:32 ` [v5 3/4] mm, oom: introduce oom_priority for memory cgroups Roman Gushchin
2017-08-14 22:44 ` David Rientjes
2017-08-14 18:32 ` [v5 4/4] mm, oom, docs: describe the cgroup-aware OOM killer Roman Gushchin
2017-08-14 22:52 ` David Rientjes
2017-08-15 14:13 ` Roman Gushchin
2017-08-15 20:56 ` David Rientjes
2017-08-16 14:43 ` Roman Gushchin
2017-08-17 12:16 ` Roman Gushchin
2017-08-21 0:41 ` David Rientjes
2017-08-14 22:00 ` [v5 1/4] mm, oom: refactor the oom_kill_process() function David Rientjes
2017-08-22 17:06 ` Johannes Weiner
2017-08-23 12:30 ` Roman Gushchin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170823162031.GA13578@castle.dhcp.TheFacebook.com \
--to=guro@fb.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@fb.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rientjes@google.com \
--cc=tj@kernel.org \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox