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


Groups > linux.kernel > #1666712

Re: [patch] mm, oom: prevent additional oom kills before memory is freed

From Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Newsgroups linux.kernel
Subject Re: [patch] mm, oom: prevent additional oom kills before memory is freed
Date 2017-06-15 15:10 +0200
Message-ID <tSCH8-2TS-19@gated-at.bofh.it> (permalink)
References <tSAFk-1qG-5@gated-at.bofh.it> <tSAP0-1J4-13@gated-at.bofh.it> <tSBi2-1Sz-13@gated-at.bofh.it> <tSBL3-2jj-3@gated-at.bofh.it> <tSBUJ-2mB-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Michal Hocko wrote:
> On Thu 15-06-17 14:03:35, Michal Hocko wrote:
> > On Thu 15-06-17 20:32:39, Tetsuo Handa wrote:
> > > @@ -556,25 +553,21 @@ static void oom_reap_task(struct task_struct *tsk)
> > >  	struct mm_struct *mm = tsk->signal->oom_mm;
> > >  
> > >  	/* Retry the down_read_trylock(mmap_sem) a few times */
> > > -	while (attempts++ < MAX_OOM_REAP_RETRIES && !__oom_reap_task_mm(tsk, mm))
> > > +	while (__oom_reap_task_mm(tsk, mm), !test_bit(MMF_OOM_SKIP, &mm->flags)
> > > +	       && attempts++ < MAX_OOM_REAP_RETRIES)
> > >  		schedule_timeout_idle(HZ/10);
> > >  
> > > -	if (attempts <= MAX_OOM_REAP_RETRIES)
> > > -		goto done;
> > > -
> > > -
> > > -	pr_info("oom_reaper: unable to reap pid:%d (%s)\n",
> > > -		task_pid_nr(tsk), tsk->comm);
> > > -	debug_show_all_locks();
> > > -
> > > -done:
> > > -	tsk->oom_reaper_list = NULL;
> > > -
> > >  	/*
> > >  	 * Hide this mm from OOM killer because it has been either reaped or
> > >  	 * somebody can't call up_write(mmap_sem).
> > >  	 */
> > > -	set_bit(MMF_OOM_SKIP, &mm->flags);
> > > +	if (!test_and_set_bit(MMF_OOM_SKIP, &mm->flags)) {
> > > +		pr_info("oom_reaper: unable to reap pid:%d (%s)\n",
> > > +			task_pid_nr(tsk), tsk->comm);
> > > +		debug_show_all_locks();
> > > +	}
> > > +
> > 
> > How does this _solve_ anything? Why would you even retry when you
> > _know_ that the reference count dropped to zero. It will never
> > increment. So the above is basically just schedule_timeout_idle(HZ/10) *
> > MAX_OOM_REAP_RETRIES before we set MMF_OOM_SKIP.

If the OOM reaper knows that mm->users == 0, it gives __mmput() some time
to "complete exit_mmap() etc. and set MMF_OOM_SKIP". If __mmput() released
some memory, subsequent OOM killer invocation is automatically avoided.
If __mmput() did not release some memory, let the OOM killer invoke again.

> 
> Just to make myself more clear. The above assumes that the victim hasn't
> passed exit_mmap and MMF_OOM_SKIP in __mmput. Which is the case we want to
> address here.

David is trying to avoid setting MMF_OOM_SKIP when the OOM reaper found that
mm->users == 0. But we must not wait forever because __mmput() might fail to
release some memory immediately. If __mmput() did not release some memory within
schedule_timeout_idle(HZ/10) * MAX_OOM_REAP_RETRIES sleep, let the OOM killer
invoke again. So, this is the case we want to address here, isn't it?

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


Thread

[patch] mm, oom: prevent additional oom kills before memory is  freed David Rientjes <rientjes@google.com> - 2017-06-15 01:50 +0200
  Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 12:50 +0200
    Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-15 13:00 +0200
      Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 13:10 +0200
        Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-15 13:40 +0200
          Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 14:10 +0200
            Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 14:20 +0200
              Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-15 15:10 +0200
                Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 15:30 +0200
                Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-15 23:50 +0200
                Re: [patch] mm, oom: prevent additional oom kills before memory is  freed David Rientjes <rientjes@google.com> - 2017-06-15 23:40 +0200
        Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 14:30 +0200
    Re: [patch] mm, oom: prevent additional oom kills before memory is  freed David Rientjes <rientjes@google.com> - 2017-06-15 23:30 +0200
      Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-15 23:50 +0200
        Re: [patch] mm, oom: prevent additional oom kills before memory is  freed David Rientjes <rientjes@google.com> - 2017-06-16 00:10 +0200
          Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-16 00:20 +0200
            Re: [patch] mm, oom: prevent additional oom kills before memory is  freed David Rientjes <rientjes@google.com> - 2017-06-16 00:50 +0200
              Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-16 10:10 +0200
            Re: Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> - 2017-06-16 03:00 +0200
              Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> - 2017-06-16 06:10 +0200
              Re: Re: [patch] mm, oom: prevent additional oom kills before memory  is freed Michal Hocko <mhocko@kernel.org> - 2017-06-16 10:40 +0200
                Re: Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-16 12:30 +0200
                Re: Re: [patch] mm, oom: prevent additional oom kills before memory  is freed Michal Hocko <mhocko@kernel.org> - 2017-06-16 13:10 +0200
                Re: Re: [patch] mm, oom: prevent additional oom kills before memoryis freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-16 16:30 +0200
                Re: Re: [patch] mm, oom: prevent additional oom kills before  memoryis freed Michal Hocko <mhocko@kernel.org> - 2017-06-16 16:50 +0200
                Re: Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-17 15:40 +0200
        Re: [patch] mm, oom: prevent additional oom kills before memory is freed Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-16 14:30 +0200
          Re: [patch] mm, oom: prevent additional oom kills before memory is  freed Michal Hocko <mhocko@kernel.org> - 2017-06-16 16:20 +0200
            [PATCH] mm,oom_kill: Close race window of needlessly selecting new victims. Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-06-17 07:20 +0200

csiph-web