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


Groups > linux.kernel > #1368400

Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory
Date 2016-03-31 17:20 +0200
Message-ID <riMy7-71p-39@gated-at.bofh.it> (permalink)
References (1 earlier) <ria9t-4ad-29@gated-at.bofh.it> <rikVc-3my-15@gated-at.bofh.it> <rimNk-4K2-17@gated-at.bofh.it> <ringm-5c9-15@gated-at.bofh.it> <riJqy-4og-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu 31-03-16 20:56:23, Tetsuo Handa wrote:
> Michal Hocko wrote:
> > On Wed 30-03-16 20:46:48, Tetsuo Handa wrote:
> > > Michal Hocko wrote:
> > > > On Tue 29-03-16 15:13:54, David Rientjes wrote:
> > > > > On Tue, 29 Mar 2016, Michal Hocko wrote:
> > > > > 
> > > > > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> > > > > > index 86349586eacb..1c2b7a82f0c4 100644
> > > > > > --- a/mm/oom_kill.c
> > > > > > +++ b/mm/oom_kill.c
> > > > > > @@ -876,6 +876,10 @@ bool out_of_memory(struct oom_control *oc)
> > > > > >  		return true;
> > > > > >  	}
> > > > > >  
> > > > > > +	/* The OOM killer does not compensate for IO-less reclaim. */
> > > > > > +	if (!(oc->gfp_mask & __GFP_FS))
> > > > > > +		return true;
> > > > > > +
> > > 
> > > This patch will disable pagefault_out_of_memory() because currently
> > > pagefault_out_of_memory() is passing oc->gfp_mask == 0.
> > > 
> > > Because of current behavior, calling oom notifiers from !__GFP_FS seems
> > > to be safe.
> > 
> > You are right! I have completely missed that and thought we were
> > providing GFP_KERNEL there. So we have two choices. Either we do
> > use GFP_KERNEL (same as we do for sysrq+f) or we special case
> > pagefault_out_of_memory in some way. The second option seems to be safer
> > because the gfp_mask has to contain at least ___GFP_DIRECT_RECLAIM to
> > trigger the OOM path.
> 
> Oops, I missed that this patch also disables out_of_memory() for !__GFP_FS &&
> __GFP_NOFAIL allocation requests.

True. The following should take care of that:

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 54aa4ec06889..32d8210b8773 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -882,7 +882,7 @@ bool out_of_memory(struct oom_control *oc)
 	 * make sure exclude 0 mask - all other users should have at least
 	 * ___GFP_DIRECT_RECLAIM to get here.
 	 */
-	if (oc->gfp_mask && !(oc->gfp_mask & __GFP_FS))
+	if (oc->gfp_mask && !(oc->gfp_mask & (__GFP_FS|__GFP_NOFAIL)))
 		return true;
 
 	/*

Thanks for spotting this!

[...]
-- 
Michal Hocko
SUSE Labs

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


Thread

[RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Michal Hocko <mhocko@kernel.org> - 2016-03-29 15:30 +0200
  Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-03-29 15:50 +0200
    Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Michal Hocko <mhocko@kernel.org> - 2016-03-29 16:30 +0200
      Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-03-29 17:30 +0200
  Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Michal Hocko <mhocko@kernel.org> - 2016-03-29 16:20 +0200
  Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory David Rientjes <rientjes@google.com> - 2016-03-30 00:20 +0200
    Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Michal Hocko <mhocko@kernel.org> - 2016-03-30 11:50 +0200
      Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-03-30 13:50 +0200
        Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Michal Hocko <mhocko@kernel.org> - 2016-03-30 14:20 +0200
          Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-03-31 14:00 +0200
            Re: [RFC PATCH] mm, oom: move GFP_NOFS check to out_of_memory Michal Hocko <mhocko@kernel.org> - 2016-03-31 17:20 +0200

csiph-web