From: Michal Hocko <mhocko@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
linux-mm@kvack.org
Subject: Re: [patch] mm, oom: avoid checking set of allowed nodes twice when selecting a victim
Date: Thu, 26 Apr 2012 10:45:10 +0200 [thread overview]
Message-ID: <20120426084510.GA10383@tiehlicka.suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.00.1204031633460.8112@chino.kir.corp.google.com>
On Tue 03-04-12 16:34:36, David Rientjes wrote:
> For systems with high CONFIG_NODES_SHIFT, checking nodes_intersect() for
> each thread's set of allowed nodes is very expensive. It's unnecessary
> to do this twice for each thread, once in select_bad_process() and once
> in oom_badness(). We've already filtered unkillable threads at the point
> where oom_badness() is called.
>
> oom_badness() must still check if a thread is a kthread, however, to
> ensure /proc/pid/oom_score doesn't report one as killable.
>
> This significantly speeds up the tasklist iteration when there are a
> large number of threads on the system and CONFIG_NODES_SHIFT is high.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
> ---
> mm/oom_kill.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -151,13 +151,16 @@ struct task_struct *find_lock_task_mm(struct task_struct *p)
> return NULL;
> }
>
> +static bool is_unkillable_kthread(struct task_struct *p)
> +{
> + return is_global_init(p) || (p->flags & PF_KTHREAD);
> +}
> +
> /* return true if the task is not adequate as candidate victim task. */
> static bool oom_unkillable_task(struct task_struct *p,
> const struct mem_cgroup *memcg, const nodemask_t *nodemask)
> {
> - if (is_global_init(p))
> - return true;
> - if (p->flags & PF_KTHREAD)
> + if (is_unkillable_kthread(p))
> return true;
>
> /* When mem_cgroup_out_of_memory() and p is not member of the group */
> @@ -185,7 +188,7 @@ unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
> {
> long points;
>
> - if (oom_unkillable_task(p, memcg, nodemask))
> + if (is_unkillable_kthread(p))
> return 0;
>
> p = find_lock_task_mm(p);
> @@ -478,9 +481,8 @@ static void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
>
> if (child->mm == p->mm)
> continue;
> - /*
> - * oom_badness() returns 0 if the thread is unkillable
> - */
> + if (oom_unkillable_task(child, memcg, nodemask))
> + continue;
> child_points = oom_badness(child, memcg, nodemask,
> totalpages);
> if (child_points > victim_points) {
>
> --
> 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/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2012-04-26 8:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 23:34 David Rientjes
2012-04-12 14:01 ` Michal Hocko
2012-04-24 23:09 ` David Rientjes
2012-04-25 8:06 ` Michal Hocko
2012-04-25 20:59 ` David Rientjes
2012-04-26 8:44 ` Michal Hocko
2012-04-26 8:45 ` Michal Hocko [this message]
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=20120426084510.GA10383@tiehlicka.suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.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