linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'js1304@gmail.com'" <js1304@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-team@lge.com" <kernel-team@lge.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Christoph Hellwig <hch@infradead.org>,
	Roman Gushchin <guro@fb.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	"Naoya Horiguchi" <n-horiguchi@ah.jp.nec.com>,
	Michal Hocko <mhocko@suse.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH 1/4] mm/page_alloc: fix non cma alloc context
Date: Fri, 17 Jul 2020 08:32:07 +0000	[thread overview]
Message-ID: <be55deff4ef1453983522d247bd36110@AcuMS.aculab.com> (raw)
In-Reply-To: <1594789529-6206-1-git-send-email-iamjoonsoo.kim@lge.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.

	David

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



  parent reply	other threads:[~2020-07-17  8:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15  5:05 js1304
2020-07-15  5:05 ` [PATCH 2/4] mm/gup: restrict CMA region by using allocation scope API js1304
2020-07-15  8:24   ` Michal Hocko
2020-07-17  7:46     ` Joonsoo Kim
2020-07-17  8:26       ` Michal Hocko
2020-07-17  9:28         ` Joonsoo Kim
2020-07-17 11:08           ` Michal Hocko
2020-07-15  5:05 ` [PATCH 3/4] mm/hugetlb: make hugetlb migration callback CMA aware js1304
2020-07-15  8:33   ` Michal Hocko
2020-07-15  9:51   ` Vlastimil Babka
2020-07-15  5:05 ` [PATCH 4/4] mm/gup: use a standard migration target allocation callback js1304
2020-07-15  8:36   ` Michal Hocko
2020-07-15  8:24 ` [PATCH 1/4] mm/page_alloc: fix non cma alloc context Vlastimil Babka
2020-07-16  7:27   ` Joonsoo Kim
2020-07-16  7:45     ` Vlastimil Babka
2020-07-17  7:29       ` Joonsoo Kim
2020-07-17  8:10         ` Vlastimil Babka
2020-07-17  8:15           ` Vlastimil Babka
2020-07-17  9:12             ` Joonsoo Kim
2020-07-15  8:28 ` Michal Hocko
2020-07-17  8:32 ` David Laight [this message]
2020-07-17  9:14   ` Joonsoo Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be55deff4ef1453983522d247bd36110@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=guro@fb.com \
    --cc=hch@infradead.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=js1304@gmail.com \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox