LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Konstantin Khlebnikov <koct9i@gmail.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	"\\Rafael J. Wysocki\\" <rjw@rjwysocki.net>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm, oom: do not fail __GFP_NOFAIL allocation if oom killer is disbaled
Date: Wed, 25 Feb 2015 01:16:49 +0300	[thread overview]
Message-ID: <CALYGNiPVcbzJxxwcUVfCOKA56xyV+r8B7DjU4aVhSqAXor2w7Q@mail.gmail.com> (raw)
In-Reply-To: <CALYGNiOj2-FZyUC5oFews7481WW2B2NJuYz96xS3KxAOc4jpPw@mail.gmail.com>

On Wed, Feb 25, 2015 at 1:09 AM, Konstantin Khlebnikov <koct9i@gmail.com> wrote:
> On Tue, Feb 24, 2015 at 10:11 PM, Johannes Weiner <hannes@cmpxchg.org> wrote:
>> On Tue, Feb 24, 2015 at 07:19:24PM +0100, Michal Hocko wrote:
>>> Tetsuo Handa has pointed out that __GFP_NOFAIL allocations might fail
>>> after OOM killer is disabled if the allocation is performed by a
>>> kernel thread. This behavior was introduced from the very beginning by
>>> 7f33d49a2ed5 (mm, PM/Freezer: Disable OOM killer when tasks are frozen).
>>> This means that the basic contract for the allocation request is broken
>>> and the context requesting such an allocation might blow up unexpectedly.
>>>
>>> There are basically two ways forward.
>>> 1) move oom_killer_disable after kernel threads are frozen. This has a
>>>    risk that the OOM victim wouldn't be able to finish because it would
>>>    depend on an already frozen kernel thread. This would be really
>>>    tricky to debug.
>>> 2) do not fail GFP_NOFAIL allocation no matter what and risk a potential
>>>    Freezable kernel threads will loop and fail the suspend. Incidental
>>>    allocations after kernel threads are frozen will at least dump a
>>>    warning - if we are lucky and the serial console is still active of
>>>    course...
>>>
>>> This patch implements the later option because it is safer. We would see
>>> warnings rather than allocation failures for the kernel threads which
>>> would blow up otherwise and have a higher chances to identify
>>> __GFP_NOFAIL users from deeper pm code.
>>>
>>> Signed-off-by: Michal Hocko <mhocko@suse.cz>
>>> ---
>>>
>>> We haven't seen any bug reports
>>>
>>>  mm/oom_kill.c | 8 ++++++++
>>>  1 file changed, 8 insertions(+)
>>>
>>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>>> index 642f38cb175a..ea8b443cd871 100644
>>> --- a/mm/oom_kill.c
>>> +++ b/mm/oom_kill.c
>>> @@ -772,6 +772,10 @@ out:
>>>               schedule_timeout_killable(1);
>>>  }
>>>
>>> +static DEFINE_RATELIMIT_STATE(oom_disabled_rs,
>>> +             DEFAULT_RATELIMIT_INTERVAL,
>>> +             DEFAULT_RATELIMIT_BURST);
>>> +
>>>  /**
>>>   * out_of_memory -  tries to invoke OOM killer.
>>>   * @zonelist: zonelist pointer
>>> @@ -792,6 +796,10 @@ bool out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
>>>       if (!oom_killer_disabled) {
>>>               __out_of_memory(zonelist, gfp_mask, order, nodemask, force_kill);
>>>               ret = true;
>>> +     } else if (gfp_mask & __GFP_NOFAIL) {
>>> +             if (__ratelimit(&oom_disabled_rs))
>>> +                     WARN(1, "Unable to make forward progress for __GFP_NOFAIL because OOM killer is disbaled\n");
>>> +             ret = true;
>>
>> I'm fine with keeping the allocation looping, but is that message
>> helpful?  It seems completely useless to the user encountering it.  Is
>> it going to help kernel developers when we get a bug report with it?
>>
>> WARN_ON_ONCE()?
>
> maybe panic() ?
>
> If somebody turns off oom-killer it seems he's pretty sure that he has
> enough memory.

Ah, that's used in freeze/suspend code. I thought that some kind of
sysctl for brave sysadmins.

>
>>
>> --
>> 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:[~2015-02-24 22:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 18:19 Michal Hocko
2015-02-24 18:22 ` Michal Hocko
2015-02-24 19:11 ` Johannes Weiner
2015-02-24 20:23   ` David Rientjes
2015-02-25 14:08     ` [PATCH -v2] " Michal Hocko
2015-02-25 20:41       ` David Rientjes
2015-02-26 17:34         ` Michal Hocko
2015-02-24 22:09   ` [PATCH] " Konstantin Khlebnikov
2015-02-24 22:16     ` Konstantin Khlebnikov [this message]
2015-02-25 14:02   ` Michal Hocko

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=CALYGNiPVcbzJxxwcUVfCOKA56xyV+r8B7DjU4aVhSqAXor2w7Q@mail.gmail.com \
    --to=koct9i@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=rientjes@google.com \
    --cc=rjw@rjwysocki.net \
    --subject='Re: [PATCH] mm, oom: do not fail __GFP_NOFAIL allocation if oom killer is disbaled' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).