linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: rientjes@google.com
Cc: kosaki.motohiro@jp.fujitsu.com, kamezawa.hiroyu@jp.fujitsu.com,
	akpm@linux-foundation.org, oleg@redhat.com, linux-mm@kvack.org
Subject: Re: [patch v2] mm, oom: do not schedule if current has been killed
Date: Tue, 19 Jun 2012 13:32:14 -0400	[thread overview]
Message-ID: <4FE0B79E.1060601@jp.fujitsu.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1206182321160.27620@chino.kir.corp.google.com>

On 6/19/2012 2:26 AM, David Rientjes wrote:
> On Tue, 19 Jun 2012, KOSAKI Motohiro wrote:
> 
>>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>>> --- a/mm/oom_kill.c
>>> +++ b/mm/oom_kill.c
>>> @@ -746,10 +746,11 @@ out:
>>>        read_unlock(&tasklist_lock);
>>>
>>>        /*
>>> -        * Give "p" a good chance of killing itself before we
>>> +        * Give "p" a good chance of exiting before we
>>>         * retry to allocate memory unless "p" is current
>>>         */
>>> -       if (killed && !test_thread_flag(TIF_MEMDIE))
>>> +       if (killed && !fatal_signal_pending(current) &&
>>> +                     !(current->flags & PF_EXITING))
>>>                schedule_timeout_uninterruptible(1);
>>>  }
>>
>> Why don't check gfp_flags? I think the rule is,
>>
>> 1) a thread of newly marked as TIF_MEMDIE
>>     -> now it has a capability to access reseve memory. let's immediately retry.
>> 2) allocation for GFP_HIGHUSER_MOVABLE
>>     -> we can fail to allocate it safely. let's immediately fail.
>>         (I suspect we need to change page allocator too)
>> 3) GFP_KERNEL and PF_EXITING
>>     -> don't retry immediately. It shall fail again. let's wait until
>> killed process
>>         is exited.
>>
> 
> The killed process may exit but it does not guarantee that its memory will 
> be freed if it's shared with current.  This is the case that the patch is 
> addressing, where right now we unnecessarily schedule if current has been 
> killed or is already along the exit path.  We want to retry as soon as 
> possible so that either the allocation now succeeds or we can recall the 
> oom killer as soon as possible and get TIF_MEMDIE set because we have a 
> fatal signal so current may exit in a timely way as well.  The point is 
> that if current has either a SIGKILL or is already exiting as it returns 
> from the oom killer, it does no good to continue to stall and prevent that 
> memory freeing.

You missed live lock risk. immediate retry makes immediate fail if no one
freed any memory. Even if the task call out_of_memory() again, select_bad_process()
may return -1 and don't makes any forward progress.



--
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>

  reply	other threads:[~2012-06-19 17:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19  1:08 [patch] " David Rientjes
2012-06-19  1:57 ` Kamezawa Hiroyuki
2012-06-19  2:23   ` David Rientjes
2012-06-19  2:31     ` [patch v2] " David Rientjes
2012-06-19  2:51       ` Kamezawa Hiroyuki
2012-06-19  6:03       ` KOSAKI Motohiro
2012-06-19  6:26         ` David Rientjes
2012-06-19 17:32           ` KOSAKI Motohiro [this message]
2012-06-19 18:59             ` David Rientjes
2012-06-19 19:29               ` KOSAKI Motohiro
2012-06-19 13:55       ` Oleg Nesterov
2012-06-19 20:24         ` David Rientjes
2012-06-19 20:58           ` [patch v3] " David Rientjes
2012-06-19 21:39             ` KOSAKI Motohiro
2012-06-20  0:38               ` Kamezawa Hiroyuki
2012-06-21  1:23                 ` 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=4FE0B79E.1060601@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=oleg@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