lkml.org 
[lkml]   [2020]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/4] mm/page_alloc: fix non cma alloc context
2020년 7월 17일 (금) 오후 5:32, David Laight <David.Laight@aculab.com>님이 작성:
>
> From: js1304@gmail.com
> > Sent: 15 July 2020 06:05
> > From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >
> > Currently, preventing cma area in page allocation is implemented by using
> > current_gfp_context(). However, there are two problems of this
> > implementation.
> ...
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 6416d08..cd53894 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> ...
> > @@ -3693,6 +3691,16 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask)
> > return alloc_flags;
> > }
> >
> > +static inline void current_alloc_flags(gfp_t gfp_mask,
> > + unsigned int *alloc_flags)
> > +{
> > + unsigned int pflags = READ_ONCE(current->flags);
> > +
> > + if (!(pflags & PF_MEMALLOC_NOCMA) &&
> > + gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE)
> > + *alloc_flags |= ALLOC_CMA;
> > +}
> > +
>
> I'd guess this would be easier to understand and probably generate
> better code if renamed and used as:
> alloc_flags |= can_alloc_cma(gpf_mask);
>
> Given it is a 'static inline' the compiler might end up
> generating the same code.
> If you needed to clear a flag doing:
> alloc_flags = current_alloc_flags(gpf_mask, alloc_flags);
> is much better for non-inlined function.

Vlastimil suggested this way and I have agreed with that. Anyway,
thanks for the suggestion.

Thanks.

\
 
 \ /
  Last update: 2020-07-17 11:15    [W:0.306 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site