linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: akpm@linux-foundation.org, oleg@redhat.com, linux-mm@kvack.org
Subject: Re: linux-4.4-rc1: TIF_MEMDIE without SIGKILL pending?
Date: Mon, 23 Nov 2015 12:33:52 +0100	[thread overview]
Message-ID: <20151123113352.GH21050@dhcp22.suse.cz> (raw)
In-Reply-To: <201511232006.EDD81713.JMSFOOtQFOHLFV@I-love.SAKURA.ne.jp>

On Mon 23-11-15 20:06:02, Tetsuo Handa wrote:
> Michal Hocko wrote:
> > On Sun 22-11-15 21:13:22, Tetsuo Handa wrote:
> > > I was updating kmallocwd in preparation for testing "[RFC 0/3] OOM detection
> > > rework v2" patchset. I noticed an unexpected result with linux.git as of
> > > 3ad5d7e06a96 .
> > > 
> > > The problem is that an OOM victim arrives at do_exit() with TIF_MEMDIE flag
> > > set but without pending SIGKILL. Is this correct behavior?
> > 
> > Have a look at out_of_memory where we do:
> >         /*
> >          * If current has a pending SIGKILL or is exiting, then automatically
> >          * select it.  The goal is to allow it to allocate so that it may
> >          * quickly exit and free its memory.
> >          *
> >          * But don't select if current has already released its mm and cleared
> >          * TIF_MEMDIE flag at exit_mm(), otherwise an OOM livelock may occur.
> >          */
> >         if (current->mm &&
> >             (fatal_signal_pending(current) || task_will_free_mem(current))) {
> >                 mark_oom_victim(current);
> >                 return true;
> >         }
> > 
> > So if the current was exiting already we are not killing it, we just give it
> > access to memory reserves to expedite the exit. We do the same thing for the
> > memcg case.
> 
> The result is the same even if I do
> 
> -	BUG_ON(test_thread_flag(TIF_MEMDIE) && !fatal_signal_pending(current));
> +	BUG_ON(test_thread_flag(TIF_MEMDIE) && !fatal_signal_pending(current) && !task_will_free_mem(current));
> 
> . I think that task_will_free_mem() is always false because this BUG_ON()
> is located before "exit_signals(tsk);  /* sets PF_EXITING */" line.

I haven't checked where exactly you added the BUG_ON, I was merely
comenting on the possibility that TIF_MEMDIE is set without sending
SIGKILL.

Now that I am looking at your BUG_ON more closely I am wondering whether
it makes sense at all. The fatal signal has been dequeued in get_signal
before we call into do_group_exit AFAICS.

[...]
-- 
Michal Hocko
SUSE Labs

--
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-11-23 11:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-22 12:13 Tetsuo Handa
2015-11-23  8:30 ` Michal Hocko
2015-11-23 11:06   ` Tetsuo Handa
2015-11-23 11:33     ` Michal Hocko [this message]
2015-11-23 12:38       ` Tetsuo Handa

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=20151123113352.GH21050@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=oleg@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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