linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, lorenzo.stoakes@oracle.com,
	vbabka@suse.cz
Cc: linux-mm@kvack.org, Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH 2/2] mm/pageblock-flags: simplify MIGRATETYPE_MASK definition
Date: Tue, 26 Aug 2025 15:34:13 +0200	[thread overview]
Message-ID: <a78883c4-5b71-4880-8d6f-ebaebba7d1d6@redhat.com> (raw)
In-Reply-To: <20250826093148.30190-3-richard.weiyang@gmail.com>

On 26.08.25 11:31, Wei Yang wrote:
> MIGRATETYPE_MASK is defined to be the mask of possible migratetype.
> 
> Define it with PB_migratetype_bits directly would be more clear.
> 
> Also, MIGRATETYPE_AND_ISO_MASK is MIGRATETYPE_MASK add isolation bit.
> Use MIGRATETYPE_MASK in the definition of MIGRATETYPE_AND_ISO_MASK looks
> cleaner.
> 
> No functional change intended.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: David Hildenbrand <david@redhat.com>
> ---
>   include/linux/pageblock-flags.h | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
> index 6a44be0f39f4..1489c062a5a7 100644
> --- a/include/linux/pageblock-flags.h
> +++ b/include/linux/pageblock-flags.h
> @@ -37,11 +37,10 @@ enum pageblock_bits {
>   
>   #define NR_PAGEBLOCK_BITS (roundup_pow_of_two(__NR_PAGEBLOCK_BITS))
>   
> -#define MIGRATETYPE_MASK ((1UL << (PB_migrate_end + 1)) - 1)
> +#define MIGRATETYPE_MASK (BIT(PB_migratetype_bits) - 1)
>   
>   #ifdef CONFIG_MEMORY_ISOLATION
> -#define MIGRATETYPE_AND_ISO_MASK \
> -	(((1UL << (PB_migrate_end + 1)) - 1) | BIT(PB_migrate_isolate))
> +#define MIGRATETYPE_AND_ISO_MASK (MIGRATETYPE_MASK | BIT(PB_migrate_isolate))
>   #else
>   #define MIGRATETYPE_AND_ISO_MASK MIGRATETYPE_MASK
>   #endif


Hm, I wonder if we can get rid of PB_migratetype_bits

diff --git a/include/linux/pageblock-flags.h 
b/include/linux/pageblock-flags.h
index 6a44be0f39f45..70c988dbdddc8 100644
--- a/include/linux/pageblock-flags.h
+++ b/include/linux/pageblock-flags.h
@@ -13,12 +13,11 @@

  #include <linux/types.h>

-#define PB_migratetype_bits 3
  /* Bit indices that affect a whole block of pages */
  enum pageblock_bits {
-       PB_migrate,
-       PB_migrate_end = PB_migrate + PB_migratetype_bits - 1,
-                       /* 3 bits required for migrate types */
+       PB_migrate_0,
+       PB_migrate_1,
+       PB_migrate_2,
         PB_compact_skip,/* If set the block is skipped by compaction */

  #ifdef CONFIG_MEMORY_ISOLATION

And then just work with the bits. No magical computations.

-- 
Cheers

David / dhildenb



  reply	other threads:[~2025-08-26 13:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  9:31 [PATCH 0/2] mm/pageblock: improve readability of some pageblock handling Wei Yang
2025-08-26  9:31 ` [PATCH 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading Wei Yang
2025-08-26 13:26   ` Zi Yan
2025-08-26 13:28   ` David Hildenbrand
2025-08-26  9:31 ` [PATCH 2/2] mm/pageblock-flags: simplify MIGRATETYPE_MASK definition Wei Yang
2025-08-26 13:34   ` David Hildenbrand [this message]
2025-08-26 15:19     ` Wei Yang
2025-08-26 15:29       ` David Hildenbrand
2025-08-26 13:35   ` Zi Yan

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=a78883c4-5b71-4880-8d6f-ebaebba7d1d6@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=richard.weiyang@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=ziy@nvidia.com \
    /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