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


Groups > linux.kernel > #1552748

Re: [PATCH] mm: support __GFP_REPEAT in kvmalloc_node

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] mm: support __GFP_REPEAT in kvmalloc_node
Date 2017-01-06 13:40 +0100
Message-ID <sWBYl-1Wp-3@gated-at.bofh.it> (permalink)
References <sVb0e-7pH-41@gated-at.bofh.it> <sVYki-8gW-33@gated-at.bofh.it> <sWBEZ-1NR-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri 06-01-17 13:09:36, Vlastimil Babka wrote:
> On 01/04/2017 07:12 PM, Michal Hocko wrote:
[...]
> > diff --git a/mm/util.c b/mm/util.c
> > index 8e4ea6cbe379..a2bfb85e60e5 100644
> > --- a/mm/util.c
> > +++ b/mm/util.c
> > @@ -348,8 +348,13 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
> >  	 * Make sure that larger requests are not too disruptive - no OOM
> >  	 * killer and no allocation failure warnings as we have a fallback
> >  	 */
> > -	if (size > PAGE_SIZE)
> > -		kmalloc_flags |= __GFP_NORETRY | __GFP_NOWARN;
> > +	if (size > PAGE_SIZE) {
> > +		kmalloc_flags |= __GFP_NOWARN;
> > +
> > +		if (!(kmalloc_flags & __GFP_REPEAT) ||
> > +				(size <= PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
> > +			kmalloc_flags |= __GFP_NORETRY;
> 
> I think this would be more understandable for me if it was written in
> the opposite way, i.e. "if we have costly __GFP_REPEAT allocation, don't
> use __GFP_NORETRY",

Dunno, doesn't look much simpler to me
		kmalloc_flags |= __GFP_NORETRY;
		if ((kmalloc_flags & __GFP_REPEAT) &&
				(size > PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
			kmalloc_flags &= ~__GFP_NORETRY;
		}

> but nevermind, seems correct to me wrt current
> handling of both flags in the page allocator. And it serves as a good
> argument to have this wrapper in mm/ as we are hopefully more likely to
> keep it working as intended with future changes, than all the opencoded
> variants.
> 
> Acked-by: Vlastimil Babka <vbabka@suse.cz>

Thanks!

-- 
Michal Hocko
SUSE Labs

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


Thread

[PATCH] mm: support __GFP_REPEAT in kvmalloc_node Michal Hocko <mhocko@kernel.org> - 2017-01-04 19:20 +0100
  Re: [PATCH] mm: support __GFP_REPEAT in kvmalloc_node Vlastimil Babka <vbabka@suse.cz> - 2017-01-06 13:20 +0100
    Re: [PATCH] mm: support __GFP_REPEAT in kvmalloc_node Michal Hocko <mhocko@kernel.org> - 2017-01-06 13:40 +0100
    Re: [PATCH] mm: support __GFP_REPEAT in kvmalloc_node Michal Hocko <mhocko@kernel.org> - 2017-01-09 10:00 +0100

csiph-web