linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: oleg@redhat.com
Cc: mhocko@kernel.org, linux-mm@kvack.org, mhocko@suse.com,
	vdavydov@virtuozzo.com, rientjes@google.com
Subject: Re: [PATCH] mm,oom: use per signal_struct flag rather than clear TIF_MEMDIE
Date: Sat, 25 Jun 2016 14:44:39 +0900	[thread overview]
Message-ID: <201606251444.EGJ69787.FtMOFJOLSHFQOV@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20160624215627.GA1148@redhat.com>

Oleg Nesterov wrote:
> Since I mentioned TIF_MEMDIE in another thread, I simply can't resist.
> Sorry for grunting.
> 
> On 06/24, Tetsuo Handa wrote:
> >
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -801,6 +801,7 @@ struct signal_struct {
> >  	 * oom
> >  	 */
> >  	bool oom_flag_origin;
> > +	bool oom_ignore_victims;        /* Ignore oom_victims value */
> >  	short oom_score_adj;		/* OOM kill score adjustment */
> >  	short oom_score_adj_min;	/* OOM kill score adjustment min value.
> >  					 * Only settable by CAP_SYS_RESOURCE. */
> 
> Yet another kludge to fix yet another problem with TIF_MEMDIE. Not
> to mention that that wh
> 
> Can't we state the fact TIF_MEMDIE is just broken? The very idea imo.

Yes. TIF_MEMDIE is a trouble maker.

Setting TIF_MEMDIE is per task_struct operation.
Sending SIGKILL is per signal_struct operation.
OOM killer is per mm_struct operation.

> I am starting to seriously think we should kill this flag, fix the
> compilation errors, remove the dead code (including the oom_victims
> logic), and then try to add something else. Say, even MMF_MEMDIE looks
> better although I understand it is not that simple.

I wish that TIF_MEMDIE is per signal_struct flag. But since we allow
mm-less TIF_MEMDIE thread to use ALLOC_NO_WATERMARKS via TIF_MEMDIE
inside __mmput() from mmput() from exit_mm() from do_exit(), we can't
replace

  test_thread_flag(TIF_MEMDIE)

in gfp_to_alloc_flags() with

  current->signal->oom_killed

or

  current->mm && (current->mm->flags & MMF_MEMDIE)

. But

> 
> Just one question. Why do we need this bit outside of oom-kill.c? It
> affects page_alloc.c and this probably makes sense. But who get this
> flag when we decide to kill the memory hog? A random thread foung by
> find_lock_task_mm(), iow a random thread with ->mm != NULL, likely the
> group leader. This simply can not be right no matter what.

I agree that setting TIF_MEMDIE to only first ->mm != NULL thread
does not make sense.

I've proposed setting TIF_MEMDIE to all ->mm != NULL threads which are
killed by the OOM killer because doing so won't increase the risk of
depleting the memory reserves, for TIF_MEMDIE helps only if that thread is
doing memory allocation
( http://lkml.kernel.org/r/1458529634-5951-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp ),
but it did not happen.

> 
> And in any case I don't understand this patch but I have to admit that
> I failed to force myself to read the changelog and the actual change ;)
> In any case I agree that we should not set MMF_MEMDIE if ->mm == NULL,
> and if we ensure this then I do not understand why we can't rely on
> MMF_OOM_REAPED. Ignoring the obvious races, if ->oom_victims != 0 then
> find_lock_task_mm() should succed.

Since we are using

  mm = current->mm;
  current->mm = NULL;
  __mmput(mm); (may block for unbounded period waiting for somebody else's memory allocation)
  exit_oom_victim(current);

sequence, we won't be able to make find_lock_task_mm(tsk) != NULL when
tsk->signal->oom_victims != 0 unless we change this sequence.
My patch tries to rescue it using tsk->signal->oom_ignore_victims flag.

> 
> Oleg.
> 
> 

--
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:[~2016-06-25  5:44 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 11:02 Tetsuo Handa
2016-06-24 12:39 ` Michal Hocko
2016-06-24 15:54   ` Tetsuo Handa
2016-06-24 22:42     ` Oleg Nesterov
2016-06-24 21:56 ` Oleg Nesterov
2016-06-25  5:44   ` Tetsuo Handa [this message]
2016-06-27  9:23     ` Michal Hocko
2016-06-27 10:36       ` Michal Hocko
2016-06-27 15:51         ` Oleg Nesterov
2016-06-27 16:06           ` Michal Hocko
2016-06-27 17:55             ` Oleg Nesterov
2016-06-28 10:19               ` Michal Hocko
2016-06-29  0:13                 ` Oleg Nesterov
2016-06-29  8:33                   ` Michal Hocko
2016-06-29 14:19                     ` Michal Hocko
2016-07-01 10:15                       ` Tetsuo Handa
2016-06-29 20:01                     ` Oleg Nesterov
2016-06-30  7:59                       ` Michal Hocko
2016-06-30 10:51                         ` Tetsuo Handa
2016-06-30 11:21                           ` Michal Hocko
2016-07-03 13:32                           ` Oleg Nesterov
2016-07-03 13:21                         ` Oleg Nesterov
2016-07-07 11:51                           ` Michal Hocko
2016-07-07 16:42                             ` Oleg Nesterov
2016-06-29 20:14                 ` Oleg Nesterov
2016-06-30  8:07                   ` Michal Hocko
2016-07-03 13:24                     ` Oleg Nesterov
2016-06-27 21:09       ` Oleg Nesterov
2016-06-28 10:26         ` Michal Hocko
2016-06-29 19:34           ` Oleg Nesterov
2016-06-27 20:40     ` Oleg Nesterov
2016-06-28 10:29       ` Michal Hocko
2016-06-29 20:24         ` Oleg Nesterov
2016-06-30  8:16           ` 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=201606251444.EGJ69787.FtMOFJOLSHFQOV@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=oleg@redhat.com \
    --cc=rientjes@google.com \
    --cc=vdavydov@virtuozzo.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