Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1427656

Re: mm, oom_reaper: How to handle race with oom_killer_disable() ?

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: mm, oom_reaper: How to handle race with oom_killer_disable() ?
Date 2016-06-21 13:50 +0200
Message-ID <rMslR-5hj-53@gated-at.bofh.it> (permalink)
References <rIvBD-5Ff-3@gated-at.bofh.it> <rJy4p-5xC-1@gated-at.bofh.it> <rMpnY-3mT-43@gated-at.bofh.it> <rMslR-5hj-55@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue 21-06-16 20:03:17, Tetsuo Handa wrote:
> Michal Hocko wrote:
> > On Mon 13-06-16 13:19:43, Michal Hocko wrote:
> > [...]
> > > I am trying to remember why we are disabling oom killer before kernel
> > > threads are frozen but not really sure about that right away.
> > 
> > OK, I guess I remember now. Say that a task would depend on a freezable
> > kernel thread to get to do_exit (stuck in wait_event etc...). We would
> > simply get stuck in oom_killer_disable for ever. So we need to address
> > it a different way.
> > 
> > One way would be what you are proposing but I guess it would be more
> > systematic to never call exit_oom_victim on a remote task.  After [1] we
> > have a solid foundation to rely only on MMF_REAPED even when TIF_MEMDIE
> > is set. It is more code than your patch so I can see a reason to go with
> > yours if the following one seems too large or ugly.
> > 
> > [1] http://lkml.kernel.org/r/1466426628-15074-1-git-send-email-mhocko@kernel.org
> > 
> > What do you think about the following?
> 
> I'm OK with not clearing TIF_MEMDIE from a remote task. But this patch is racy.
> 
> > @@ -567,40 +612,23 @@ static void oom_reap_task(struct task_struct *tsk)
> >  	while (attempts++ < MAX_OOM_REAP_RETRIES && !__oom_reap_task(tsk))
> >  		schedule_timeout_idle(HZ/10);
> >  
> > -	if (attempts > MAX_OOM_REAP_RETRIES) {
> > -		struct task_struct *p;
> > +	tsk->oom_reaper_list = NULL;
> >  
> > +	if (attempts > MAX_OOM_REAP_RETRIES) {
> 
> attempts > MAX_OOM_REAP_RETRIES would mean that down_read_trylock()
> continuously failed. But it does not guarantee that the offending task
> shall not call up_write(&mm->mmap_sem) and arrives at mmput() from exit_mm()
> (as well as other threads which are blocked at down_read(&mm->mmap_sem) in
> exit_mm() by the offending task arrive at mmput() from exit_mm()) when the
> OOM reaper was preempted at this point.
> 
> Therefore, find_lock_task_mm() in requeue_oom_victim() could return NULL and
> the OOM reaper could fail to set MMF_OOM_REAPED (and find_lock_task_mm() in
> oom_scan_process_thread() could return NULL and the OOM killer could fail to
> select next OOM victim as well) when __mmput() got stuck.

Fair enough. As this would break no-lockup requirement we cannot go that
way. Let me think about it more.
 
> So, from the point of view of correctness, there remains an unhandled race
> window as long as you depend on find_lock_task_mm() not returning NULL.
> You will again ask "does it really matter/occur", and I can't make progress.

Sigh...
-- 
Michal Hocko
SUSE Labs

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-13 13:20 +0200
  Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-21 10:40 +0200
    Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-21 13:50 +0200
      Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-21 15:30 +0200
        Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-06-21 17:40 +0200
          Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-21 20:00 +0200
            Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-06-21 23:50 +0200
              Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-22 08:50 +0200
                Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-22 09:00 +0200
                Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-06-22 13:00 +0200
                Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-22 14:10 +0200
                Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Michal Hocko <mhocko@kernel.org> - 2016-06-22 14:20 +0200
    Re: mm, oom_reaper: How to handle race with oom_killer_disable() ? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-06-21 14:00 +0200

csiph-web