From: js1...@gmail.com
> Sent: 15 July 2020 06:05
> From: Joonsoo Kim <iamjoonsoo....@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.

        David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

Reply via email to