linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Patch v2 0/2] mm/pageblock: improve readability of some pageblock handling
@ 2025-08-27  2:11 Wei Yang
  2025-08-27  2:11 ` [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading Wei Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ 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

During code reading, found two possible points to improve the readability of
pageblock handling.

Patch 1: isolate bit is standalone and there are dedicated helpers. Instead of
check the bit directly, we could use the helper to do it.

Patch 2: remove PB_migratetype_bits and PB_migrate_end to reduce magical
computation.

v1->v2:
    remove PB_migratetype_bits and PB_migrate_end

Wei Yang (2):
  mm/page_alloc: use xxx_pageblock_isolate() for better reading
  mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end

 include/linux/pageblock-flags.h | 12 +++++-------
 mm/page_alloc.c                 | 11 +++++------
 2 files changed, 10 insertions(+), 13 deletions(-)

-- 
2.34.1



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

* [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading
  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  9:33   ` Vlastimil Babka
  2025-08-27  2:11 ` [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end Wei Yang
  2025-08-27  8:04 ` [syzbot ci] Re: mm/pageblock: improve readability of some pageblock handling syzbot ci
  2 siblings, 1 reply; 12+ 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

Since commit e904bce2d9d4 ("mm/page_isolation: make page isolation a
standalone bit"), it provides dedicated helper to handle isolation.

Change to use these helpers to be better reading.

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>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
---
 mm/page_alloc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index baead29b3e67..e534f31a6b39 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -538,8 +538,7 @@ static void set_pageblock_migratetype(struct page *page,
 			"Use set_pageblock_isolate() for pageblock isolation");
 		return;
 	}
-	VM_WARN_ONCE(get_pfnblock_bit(page, page_to_pfn(page),
-				      PB_migrate_isolate),
+	VM_WARN_ONCE(get_pageblock_isolate(page),
 		     "Use clear_pageblock_isolate() to unisolate pageblock");
 	/* MIGRATETYPE_AND_ISO_MASK clears PB_migrate_isolate if it is set */
 #endif
@@ -2058,9 +2057,9 @@ static unsigned long find_large_buddy(unsigned long start_pfn)
 static inline void toggle_pageblock_isolate(struct page *page, bool isolate)
 {
 	if (isolate)
-		set_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate);
+		set_pageblock_isolate(page);
 	else
-		clear_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate);
+		clear_pageblock_isolate(page);
 }
 
 /**
-- 
2.34.1



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

* [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 ` [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading Wei Yang
@ 2025-08-27  2:11 ` Wei Yang
  2025-08-27  2:21   ` Zi Yan
  2025-08-27  9:38   ` Vlastimil Babka
  2025-08-27  8:04 ` [syzbot ci] Re: mm/pageblock: improve readability of some pageblock handling syzbot ci
  2 siblings, 2 replies; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ messages in thread

* [syzbot ci] Re: mm/pageblock: improve readability of some pageblock handling
  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 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading 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  8:04 ` syzbot ci
  2025-08-27 14:43   ` Wei Yang
  2 siblings, 1 reply; 12+ messages in thread
From: syzbot ci @ 2025-08-27  8:04 UTC (permalink / raw)
  To: akpm, david, linux-mm, lorenzo.stoakes, richard.weiyang, vbabka,
	ziy
  Cc: syzbot, syzkaller-bugs

syzbot ci has tested the following series

[v2] mm/pageblock: improve readability of some pageblock handling
https://lore.kernel.org/all/20250827021121.13645-1-richard.weiyang@gmail.com
* [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading
* [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end

and found the following issue:
kernel build error

Full report is available here:
https://ci.syzbot.org/series/51db4b94-ae73-4ea0-8cf3-4ea5b7715cf1

***

kernel build error

tree:      torvalds
URL:       https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
base:      fab1beda7597fac1cecc01707d55eadb6bbe773c
arch:      amd64
compiler:  Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
config:    https://ci.syzbot.org/builds/49ee15fe-3add-4064-a3a9-1461fbba8c85/config

mm/page_alloc.c:373:2: error: call to '__compiletime_assert_1636' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK

***

If these findings have caused you to resend the series or submit a
separate fix, please add the following tag to your commit message:
  Tested-by: syzbot@syzkaller.appspotmail.com

---
This report is generated by a bot. It may contain errors.
syzbot ci engineers can be reached at syzkaller@googlegroups.com.


^ permalink raw reply	[flat|nested] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ messages in thread

* Re: [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading
  2025-08-27  2:11 ` [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading Wei Yang
@ 2025-08-27  9:33   ` Vlastimil Babka
  0 siblings, 0 replies; 12+ messages in thread
From: Vlastimil Babka @ 2025-08-27  9:33 UTC (permalink / raw)
  To: Wei Yang, akpm, david, lorenzo.stoakes; +Cc: linux-mm, Zi Yan

On 8/27/25 04:11, Wei Yang wrote:
> Since commit e904bce2d9d4 ("mm/page_isolation: make page isolation a
> standalone bit"), it provides dedicated helper to handle isolation.
> 
> Change to use these helpers to be better reading.
> 
> 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>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Acked-by: David Hildenbrand <david@redhat.com>

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

> ---
>  mm/page_alloc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index baead29b3e67..e534f31a6b39 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -538,8 +538,7 @@ static void set_pageblock_migratetype(struct page *page,
>  			"Use set_pageblock_isolate() for pageblock isolation");
>  		return;
>  	}
> -	VM_WARN_ONCE(get_pfnblock_bit(page, page_to_pfn(page),
> -				      PB_migrate_isolate),
> +	VM_WARN_ONCE(get_pageblock_isolate(page),
>  		     "Use clear_pageblock_isolate() to unisolate pageblock");
>  	/* MIGRATETYPE_AND_ISO_MASK clears PB_migrate_isolate if it is set */
>  #endif
> @@ -2058,9 +2057,9 @@ static unsigned long find_large_buddy(unsigned long start_pfn)
>  static inline void toggle_pageblock_isolate(struct page *page, bool isolate)
>  {
>  	if (isolate)
> -		set_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate);
> +		set_pageblock_isolate(page);
>  	else
> -		clear_pfnblock_bit(page, page_to_pfn(page), PB_migrate_isolate);
> +		clear_pageblock_isolate(page);
>  }
>  
>  /**



^ permalink raw reply	[flat|nested] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ messages in thread

* Re: [syzbot ci] Re: mm/pageblock: improve readability of some pageblock handling
  2025-08-27  8:04 ` [syzbot ci] Re: mm/pageblock: improve readability of some pageblock handling syzbot ci
@ 2025-08-27 14:43   ` Wei Yang
  0 siblings, 0 replies; 12+ messages in thread
From: Wei Yang @ 2025-08-27 14:43 UTC (permalink / raw)
  To: syzbot ci
  Cc: akpm, david, linux-mm, lorenzo.stoakes, richard.weiyang, vbabka,
	ziy, syzbot, syzkaller-bugs

On Wed, Aug 27, 2025 at 01:04:19AM -0700, syzbot ci wrote:
>syzbot ci has tested the following series
>
>[v2] mm/pageblock: improve readability of some pageblock handling
>https://lore.kernel.org/all/20250827021121.13645-1-richard.weiyang@gmail.com
>* [Patch v2 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading
>* [Patch v2 2/2] mm/pageblock-flags: remove PB_migratetype_bits/PB_migrate_end
>
>and found the following issue:
>kernel build error
>
>Full report is available here:
>https://ci.syzbot.org/series/51db4b94-ae73-4ea0-8cf3-4ea5b7715cf1
>
>***
>
>kernel build error
>
>tree:      torvalds
>URL:       https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
>base:      fab1beda7597fac1cecc01707d55eadb6bbe773c
>arch:      amd64
>compiler:  Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
>config:    https://ci.syzbot.org/builds/49ee15fe-3add-4064-a3a9-1461fbba8c85/config
>
>mm/page_alloc.c:373:2: error: call to '__compiletime_assert_1636' declared with 'error' attribute: BUILD_BUG_ON failed: __MIGRATE_TYPE_END > MIGRATETYPE_MASK
>

Thanks, this is noticed by Zi Yan.

>***
>
>If these findings have caused you to resend the series or submit a
>separate fix, please add the following tag to your commit message:
>  Tested-by: syzbot@syzkaller.appspotmail.com
>
>---
>This report is generated by a bot. It may contain errors.
>syzbot ci engineers can be reached at syzkaller@googlegroups.com.

-- 
Wei Yang
Help you, Help me


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

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

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 1/2] mm/page_alloc: use xxx_pageblock_isolate() for better reading Wei Yang
2025-08-27  9:33   ` Vlastimil Babka
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
2025-08-27  8:04 ` [syzbot ci] Re: mm/pageblock: improve readability of some pageblock handling syzbot ci
2025-08-27 14:43   ` Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).