[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <be55deff4ef1453983522d247bd36110@AcuMS.aculab.com>
Date: Fri, 17 Jul 2020 08:32:07 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'js1304@...il.com'" <js1304@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>
CC: "linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-team@....com" <kernel-team@....com>,
Vlastimil Babka <vbabka@...e.cz>,
Christoph Hellwig <hch@...radead.org>,
Roman Gushchin <guro@...com>,
Mike Kravetz <mike.kravetz@...cle.com>,
"Naoya Horiguchi" <n-horiguchi@...jp.nec.com>,
Michal Hocko <mhocko@...e.com>,
"Aneesh Kumar K . V" <aneesh.kumar@...ux.ibm.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
"stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: RE: [PATCH 1/4] mm/page_alloc: fix non cma alloc context
From: js1304@...il.com
> Sent: 15 July 2020 06:05
> From: Joonsoo Kim <iamjoonsoo.kim@....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)
Powered by blists - more mailing lists