From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Oleg Nesterov <oleg@redhat.com>, Rik van Riel <riel@redhat.com>,
linux-mm@kvack.org
Subject: Re: [patch v2 1/2] oom: avoid killing a task if a thread sharing its mm cannot be killed
Date: Wed, 18 Aug 2010 12:11:37 +0900 [thread overview]
Message-ID: <20100818121137.20192c31.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1008171925250.2823@chino.kir.corp.google.com>
On Tue, 17 Aug 2010 19:36:02 -0700 (PDT)
David Rientjes <rientjes@google.com> wrote:
> On Wed, 18 Aug 2010, KAMEZAWA Hiroyuki wrote:
>
> > > The oom killer's goal is to kill a memory-hogging task so that it may
> > > exit, free its memory, and allow the current context to allocate the
> > > memory that triggered it in the first place. Thus, killing a task is
> > > pointless if other threads sharing its mm cannot be killed because of its
> > > /proc/pid/oom_adj or /proc/pid/oom_score_adj value.
> > >
> > > This patch checks all user threads on the system to determine whether
> > > oom_badness(p) should return 0 for p, which means it should not be killed.
> > > If a thread shares p's mm and is unkillable, p is considered to be
> > > unkillable as well.
> > >
> > > Kthreads are not considered toward this rule since they only temporarily
> > > assume a task's mm via use_mm().
> > >
> > > Signed-off-by: David Rientjes <rientjes@google.com>
> >
> > Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> >
>
> Thanks!
>
> > Thank you. BTW, do you have good idea for speed-up ?
> > This code seems terribly slow when a system has many processes.
> >
>
> I was thinking about adding an "unsinged long oom_kill_disable_count" to
> struct mm_struct that would atomically increment anytime a task attached
> to it had a signal->oom_score_adj of OOM_SCORE_ADJ_MIN.
>
> The proc handler when changing /proc/pid/oom_score_adj would inc or dec
> the counter depending on the new value, and exit_mm() would dec the
> counter if current->signal->oom_score_adj is OOM_SCORE_ADJ_MIN.
>
> What do you think?
>
Hmm. I want to make hooks to "exit" small.
One idea is.
add a new member
mm->unkiilable_by_oom_jiffies.
And add
> +static bool is_mm_unfreeable(struct mm_struct *mm)
> +{
> + struct task_struct *p;
> +
if (mm->unkillable_by_oom_jiffies < jiffies)
return true;
> + for_each_process(p)
> + if (p->mm == mm && !(p->flags & PF_KTHREAD) &&
> + p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
mm->unkillable_by_oom_jiffies = jiffies + HZ;
> + return true;
> + return false;
> +}+static bool is_mm_unfreeable(struct mm_struct *mm)
Maybe no new lock is required and this not-accurate one will work enough.
Thanks,
-Kame
--
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:[~2010-08-18 3:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-17 1:15 David Rientjes
2010-08-17 1:16 ` [patch v2 2/2] oom: kill all threads sharing oom killed task's mm David Rientjes
2010-08-18 2:08 ` KAMEZAWA Hiroyuki
2010-08-19 5:31 ` KOSAKI Motohiro
2010-08-19 8:03 ` David Rientjes
2010-08-19 8:10 ` KOSAKI Motohiro
2010-08-19 11:17 ` KOSAKI Motohiro
2010-08-19 20:48 ` David Rientjes
2010-08-20 0:31 ` KOSAKI Motohiro
2010-08-20 9:05 ` David Rientjes
2010-08-18 2:07 ` [patch v2 1/2] oom: avoid killing a task if a thread sharing its mm cannot be killed KAMEZAWA Hiroyuki
2010-08-18 2:36 ` David Rientjes
2010-08-18 3:11 ` KAMEZAWA Hiroyuki [this message]
2010-08-18 3:43 ` David Rientjes
2010-08-18 3:55 ` KAMEZAWA Hiroyuki
2010-08-18 8:11 ` David Rientjes
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=20100818121137.20192c31.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=riel@redhat.com \
--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