All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  2:11 [Patch v2 0/2] mm/pageblock: improve readability of some pageblock handling Wei Yang
@ 2025-08-27  2:11 ` Wei Yang
  2025-08-27  2:21   ` Zi Yan
  2025-08-27  9:38   ` Vlastimil Babka
  0 siblings, 2 replies; 8+ messages in thread
From: Wei Yang @ 2025-08-27  2:11 UTC (permalink / raw)
  To: akpm, david, lorenzo.stoakes, vbabka; +Cc: linux-mm, Wei Yang, Zi Yan

enum pageblock_bits defines the meaning of pageblock bits. Currently
PB_migratetype_bits says the lowest 3 bits represents migratetype and
PB_migrate_end/MIGRATETYPE_MASK's definition rely on it with magical
computation.

Remove the definition of PB_migratetype_bits/PB_migrate_end. Use
PB_migrate_[0|1|2] to represent lowest bits for migratetype. Then we can
simplify related definition.

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>
Suggested-by: David Hildenbrand <david@redhat.com>

---
v2: remove PB_migratetype_bits and PB_migrate_end
---
 include/linux/pageblock-flags.h | 12 +++++-------
 mm/page_alloc.c                 |  4 ++--
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
index 6a44be0f39f4..6e4c2da15706 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
@@ -37,11 +36,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 (PB_migrate_0|PB_migrate_1|PB_migrate_2)
 
 #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
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e534f31a6b39..c1a18aaf8b41 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -355,7 +355,7 @@ static inline int pfn_to_bitidx(const struct page *page, unsigned long pfn)
 
 static __always_inline bool is_standalone_pb_bit(enum pageblock_bits pb_bit)
 {
-	return pb_bit > PB_migrate_end && pb_bit < __NR_PAGEBLOCK_BITS;
+	return pb_bit >= PB_compact_skip && pb_bit < __NR_PAGEBLOCK_BITS;
 }
 
 static __always_inline void
@@ -370,7 +370,7 @@ get_pfnblock_bitmap_bitidx(const struct page *page, unsigned long pfn,
 #else
 	BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4);
 #endif
-	BUILD_BUG_ON(__MIGRATE_TYPE_END >= (1 << PB_migratetype_bits));
+	BUILD_BUG_ON(__MIGRATE_TYPE_END > MIGRATETYPE_MASK);
 	VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page);
 
 	bitmap = get_pageblock_bitmap(page, pfn);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  2:11 ` [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end Wei Yang
@ 2025-08-27  2:21   ` Zi Yan
  2025-08-27  6:43     ` Wei Yang
  2025-08-27  9:17     ` David Hildenbrand
  2025-08-27  9:38   ` Vlastimil Babka
  1 sibling, 2 replies; 8+ messages in thread
From: Zi Yan @ 2025-08-27  2:21 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, david, lorenzo.stoakes, vbabka, linux-mm

On 26 Aug 2025, at 22:11, Wei Yang wrote:

> enum pageblock_bits defines the meaning of pageblock bits. Currently
> PB_migratetype_bits says the lowest 3 bits represents migratetype and
> PB_migrate_end/MIGRATETYPE_MASK's definition rely on it with magical
> computation.
>
> Remove the definition of PB_migratetype_bits/PB_migrate_end. Use
> PB_migrate_[0|1|2] to represent lowest bits for migratetype. Then we can
> simplify related definition.
>
> 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>
> Suggested-by: David Hildenbrand <david@redhat.com>
>
> ---
> v2: remove PB_migratetype_bits and PB_migrate_end
> ---
>  include/linux/pageblock-flags.h | 12 +++++-------
>  mm/page_alloc.c                 |  4 ++--
>  2 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
> index 6a44be0f39f4..6e4c2da15706 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
> @@ -37,11 +36,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 (PB_migrate_0|PB_migrate_1|PB_migrate_2)

I think David meant

#define MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2))

Otherwise, LGTM. Feel free to add Reviewed-by: Zi Yan <ziy@nvidia.com>,
once you fix the above.

>
>  #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
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index e534f31a6b39..c1a18aaf8b41 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -355,7 +355,7 @@ static inline int pfn_to_bitidx(const struct page *page, unsigned long pfn)
>
>  static __always_inline bool is_standalone_pb_bit(enum pageblock_bits pb_bit)
>  {
> -	return pb_bit > PB_migrate_end && pb_bit < __NR_PAGEBLOCK_BITS;
> +	return pb_bit >= PB_compact_skip && pb_bit < __NR_PAGEBLOCK_BITS;
>  }
>
>  static __always_inline void
> @@ -370,7 +370,7 @@ get_pfnblock_bitmap_bitidx(const struct page *page, unsigned long pfn,
>  #else
>  	BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4);
>  #endif
> -	BUILD_BUG_ON(__MIGRATE_TYPE_END >= (1 << PB_migratetype_bits));
> +	BUILD_BUG_ON(__MIGRATE_TYPE_END > MIGRATETYPE_MASK);
>  	VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page);
>
>  	bitmap = get_pageblock_bitmap(page, pfn);
> -- 
> 2.34.1


--
Best Regards,
Yan, Zi


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  2:21   ` Zi Yan
@ 2025-08-27  6:43     ` Wei Yang
  2025-08-27  9:16       ` David Hildenbrand
  2025-08-27  9:17     ` David Hildenbrand
  1 sibling, 1 reply; 8+ messages in thread
From: Wei Yang @ 2025-08-27  6:43 UTC (permalink / raw)
  To: Zi Yan; +Cc: Wei Yang, akpm, david, lorenzo.stoakes, vbabka, linux-mm

On Tue, Aug 26, 2025 at 10:21:20PM -0400, Zi Yan wrote:
>On 26 Aug 2025, at 22:11, Wei Yang wrote:
>
>> enum pageblock_bits defines the meaning of pageblock bits. Currently
>> PB_migratetype_bits says the lowest 3 bits represents migratetype and
>> PB_migrate_end/MIGRATETYPE_MASK's definition rely on it with magical
>> computation.
>>
>> Remove the definition of PB_migratetype_bits/PB_migrate_end. Use
>> PB_migrate_[0|1|2] to represent lowest bits for migratetype. Then we can
>> simplify related definition.
>>
>> 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>
>> Suggested-by: David Hildenbrand <david@redhat.com>
>>
>> ---
>> v2: remove PB_migratetype_bits and PB_migrate_end
>> ---
>>  include/linux/pageblock-flags.h | 12 +++++-------
>>  mm/page_alloc.c                 |  4 ++--
>>  2 files changed, 7 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
>> index 6a44be0f39f4..6e4c2da15706 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
>> @@ -37,11 +36,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 (PB_migrate_0|PB_migrate_1|PB_migrate_2)
>
>I think David meant
>
>#define MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2))
>

Oops, I thinks you are right.

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
@ 2025-08-27  6:49 kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-08-27  6:49 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "__compiletime_assert_NNN"
:::::: 

BCC: lkp@intel.com
CC: llvm@lists.linux.dev
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250827021121.13645-3-richard.weiyang@gmail.com>
References: <20250827021121.13645-3-richard.weiyang@gmail.com>
TO: Wei Yang <richard.weiyang@gmail.com>
TO: akpm@linux-foundation.org
TO: david@redhat.com
TO: lorenzo.stoakes@oracle.com
TO: vbabka@suse.cz
CC: linux-mm@kvack.org
CC: Wei Yang <richard.weiyang@gmail.com>
CC: Zi Yan <ziy@nvidia.com>

Hi Wei,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Wei-Yang/mm-page_alloc-use-xxx_pageblock_isolate-for-better-reading/20250827-101755
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20250827021121.13645-3-richard.weiyang%40gmail.com
patch subject: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago
config: i386-buildonly-randconfig-004-20250827 (https://download.01.org/0day-ci/archive/20250827/202508271419.3bLlTMSZ-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250827/202508271419.3bLlTMSZ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202508271419.3bLlTMSZ-lkp@intel.com/

All errors (new ones prefixed by >>):

>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
     373 |         BUILD_BUG_ON(__MIGRATE_TYPE_END > MIGRATETYPE_MASK);
         |         ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
>> mm/page_alloc.c:373:2: error: call to '__compiletime_assert_499' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   include/linux/compiler_types.h:572:2: note: expanded from macro 'compiletime_assert'
     572 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:242:1: note: expanded from here
     242 | __compiletime_assert_499
         | ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.


vim +373 mm/page_alloc.c

42f46ed99ac6c0 Zi Yan   2025-06-16  360  
42f46ed99ac6c0 Zi Yan   2025-06-16  361  static __always_inline void
42f46ed99ac6c0 Zi Yan   2025-06-16  362  get_pfnblock_bitmap_bitidx(const struct page *page, unsigned long pfn,
42f46ed99ac6c0 Zi Yan   2025-06-16  363  			   unsigned long **bitmap_word, unsigned long *bitidx)
42f46ed99ac6c0 Zi Yan   2025-06-16  364  {
42f46ed99ac6c0 Zi Yan   2025-06-16  365  	unsigned long *bitmap;
42f46ed99ac6c0 Zi Yan   2025-06-16  366  	unsigned long word_bitidx;
42f46ed99ac6c0 Zi Yan   2025-06-16  367  
e904bce2d9d43e Zi Yan   2025-06-16  368  #ifdef CONFIG_MEMORY_ISOLATION
e904bce2d9d43e Zi Yan   2025-06-16  369  	BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 8);
e904bce2d9d43e Zi Yan   2025-06-16  370  #else
42f46ed99ac6c0 Zi Yan   2025-06-16  371  	BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4);
e904bce2d9d43e Zi Yan   2025-06-16  372  #endif
61e515c5edd709 Wei Yang 2025-08-27 @373  	BUILD_BUG_ON(__MIGRATE_TYPE_END > MIGRATETYPE_MASK);
42f46ed99ac6c0 Zi Yan   2025-06-16  374  	VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page);
42f46ed99ac6c0 Zi Yan   2025-06-16  375  
42f46ed99ac6c0 Zi Yan   2025-06-16  376  	bitmap = get_pageblock_bitmap(page, pfn);
42f46ed99ac6c0 Zi Yan   2025-06-16  377  	*bitidx = pfn_to_bitidx(page, pfn);
42f46ed99ac6c0 Zi Yan   2025-06-16  378  	word_bitidx = *bitidx / BITS_PER_LONG;
42f46ed99ac6c0 Zi Yan   2025-06-16  379  	*bitidx &= (BITS_PER_LONG - 1);
42f46ed99ac6c0 Zi Yan   2025-06-16  380  	*bitmap_word = &bitmap[word_bitidx];
42f46ed99ac6c0 Zi Yan   2025-06-16  381  }
42f46ed99ac6c0 Zi Yan   2025-06-16  382  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  6:43     ` Wei Yang
@ 2025-08-27  9:16       ` David Hildenbrand
  2025-08-27 14:41         ` Wei Yang
  0 siblings, 1 reply; 8+ messages in thread
From: David Hildenbrand @ 2025-08-27  9:16 UTC (permalink / raw)
  To: Wei Yang, Zi Yan; +Cc: akpm, lorenzo.stoakes, vbabka, linux-mm

On 27.08.25 08:43, Wei Yang wrote:
> On Tue, Aug 26, 2025 at 10:21:20PM -0400, Zi Yan wrote:
>> On 26 Aug 2025, at 22:11, Wei Yang wrote:
>>
>>> enum pageblock_bits defines the meaning of pageblock bits. Currently
>>> PB_migratetype_bits says the lowest 3 bits represents migratetype and
>>> PB_migrate_end/MIGRATETYPE_MASK's definition rely on it with magical
>>> computation.
>>>
>>> Remove the definition of PB_migratetype_bits/PB_migrate_end. Use
>>> PB_migrate_[0|1|2] to represent lowest bits for migratetype. Then we can
>>> simplify related definition.
>>>
>>> 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>
>>> Suggested-by: David Hildenbrand <david@redhat.com>
>>>
>>> ---
>>> v2: remove PB_migratetype_bits and PB_migrate_end
>>> ---
>>>   include/linux/pageblock-flags.h | 12 +++++-------
>>>   mm/page_alloc.c                 |  4 ++--
>>>   2 files changed, 7 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
>>> index 6a44be0f39f4..6e4c2da15706 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
>>> @@ -37,11 +36,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 (PB_migrate_0|PB_migrate_1|PB_migrate_2)
>>
>> I think David meant
>>
>> #define MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2))

Yes :)

>>
> 
> Oops, I thinks you are right.

It goes without saying: please test your patches before submitting ;)

-- 
Cheers

David / dhildenb



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  2:21   ` Zi Yan
  2025-08-27  6:43     ` Wei Yang
@ 2025-08-27  9:17     ` David Hildenbrand
  1 sibling, 0 replies; 8+ messages in thread
From: David Hildenbrand @ 2025-08-27  9:17 UTC (permalink / raw)
  To: Zi Yan, Wei Yang; +Cc: akpm, lorenzo.stoakes, vbabka, linux-mm

On 27.08.25 04:21, Zi Yan wrote:
> On 26 Aug 2025, at 22:11, Wei Yang wrote:
> 
>> enum pageblock_bits defines the meaning of pageblock bits. Currently
>> PB_migratetype_bits says the lowest 3 bits represents migratetype and
>> PB_migrate_end/MIGRATETYPE_MASK's definition rely on it with magical
>> computation.
>>
>> Remove the definition of PB_migratetype_bits/PB_migrate_end. Use
>> PB_migrate_[0|1|2] to represent lowest bits for migratetype. Then we can
>> simplify related definition.
>>
>> 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>
>> Suggested-by: David Hildenbrand <david@redhat.com>
>>
>> ---
>> v2: remove PB_migratetype_bits and PB_migrate_end
>> ---
>>   include/linux/pageblock-flags.h | 12 +++++-------
>>   mm/page_alloc.c                 |  4 ++--
>>   2 files changed, 7 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
>> index 6a44be0f39f4..6e4c2da15706 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
>> @@ -37,11 +36,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 (PB_migrate_0|PB_migrate_1|PB_migrate_2)
> 
> I think David meant
> 
> #define MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2))
> 
> Otherwise, LGTM. Feel free to add Reviewed-by: Zi Yan <ziy@nvidia.com>,
> once you fix the above.

Yes, with that this should just work

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  2:11 ` [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end Wei Yang
  2025-08-27  2:21   ` Zi Yan
@ 2025-08-27  9:38   ` Vlastimil Babka
  1 sibling, 0 replies; 8+ messages in thread
From: Vlastimil Babka @ 2025-08-27  9:38 UTC (permalink / raw)
  To: Wei Yang, akpm, david, lorenzo.stoakes; +Cc: linux-mm, Zi Yan

On 8/27/25 04:11, Wei Yang wrote:
> enum pageblock_bits defines the meaning of pageblock bits. Currently
> PB_migratetype_bits says the lowest 3 bits represents migratetype and
> PB_migrate_end/MIGRATETYPE_MASK's definition rely on it with magical
> computation.
> 
> Remove the definition of PB_migratetype_bits/PB_migrate_end. Use
> PB_migrate_[0|1|2] to represent lowest bits for migratetype. Then we can
> simplify related definition.
> 
> 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>
> Suggested-by: David Hildenbrand <david@redhat.com>

Once fixed as suggested,

Acked-by: Vlastimil Babka <vbabka@suse.cz>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
  2025-08-27  9:16       ` David Hildenbrand
@ 2025-08-27 14:41         ` Wei Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Wei Yang @ 2025-08-27 14:41 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Wei Yang, Zi Yan, akpm, lorenzo.stoakes, vbabka, linux-mm

On Wed, Aug 27, 2025 at 11:16:02AM +0200, David Hildenbrand wrote:
[...]
>> > > 
>> > >   #define NR_PAGEBLOCK_BITS (roundup_pow_of_two(__NR_PAGEBLOCK_BITS))
>> > > 
>> > > -#define MIGRATETYPE_MASK ((1UL << (PB_migrate_end + 1)) - 1)
>> > > +#define MIGRATETYPE_MASK (PB_migrate_0|PB_migrate_1|PB_migrate_2)
>> > 
>> > I think David meant
>> > 
>> > #define MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2))
>
>Yes :)
>
>> > 
>> 
>> Oops, I thinks you are right.
>
>It goes without saying: please test your patches before submitting ;)
>

To be honest, I tested before submitting. And I confused why I don't see
error.

Finally I found the reason is I don't set CONFIG_CMA... fortunate or
unfortunate...

>-- 
>Cheers
>
>David / dhildenb

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-08-27 14:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27  6:49 [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2025-08-27  2:11 [Patch v2 0/2] mm/pageblock: improve readability of some pageblock handling Wei Yang
2025-08-27  2:11 ` [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end Wei Yang
2025-08-27  2:21   ` Zi Yan
2025-08-27  6:43     ` Wei Yang
2025-08-27  9:16       ` David Hildenbrand
2025-08-27 14:41         ` Wei Yang
2025-08-27  9:17     ` David Hildenbrand
2025-08-27  9:38   ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.