FAILED: patch "[PATCH] mm/page_alloc: remove the zone_spans_pfn() check from" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 2122887b04f3f2d76daa80055c2c273926032fa0
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112410-negligent-mutiny-06fc@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2122887b04f3f2d76daa80055c2c273926032fa0 Mon Sep 17 00:00:00 2001
From: "Vlastimil Babka (SUSE)" <[email protected]>
Date: Tue, 3 Nov 2026 17:16:51 +0100
Subject: [PATCH] mm/page_alloc: remove the zone_spans_pfn() check from
get_pfnblock_bitmap_bitidx()
Whenever the flags of a pageblock are read or written, a kernel with CONFIG_DEBUG_VM makes sure that the pfn lies within the zone of the page. Unlike bad_range(), that check reads zone->zone_start_pfn and zone->spanned_pages without zone->span_seqlock.
Memory hotplug changes the two fields one after the other. If the lower end of a zone moves, the zone seems to end before its last pages in between. A page of that part which is freed at that moment, on another CPU, ends in
page dumped because: VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn)) kernel BUG at mm/page_alloc.c:372! free_unref_folios+0x55e/0xed0 folios_put_refs+0x2b5/0x530
An attempt has been made [1] to fix this with the span seqlock check. But that can trigger all sorts of problems in restricted contexts, as noted by sashiko [2].
Since this is just a sanity debug check and anything with BUG_ON is frowned upon anyway, just remove it altogether.
mm/page_alloc.c +0 -1
@@ -370,7 +370,6 @@ get_pfnblock_bitmap_bitidx(const struct page *page, unsigned long pfn,BUILD_BUG_ON (NR_PAGEBLOCK_BITS !=4 );#endif BUILD_BUG_ON (__MIGRATE_TYPE_END >PAGEBLOCK_MIGRATETYPE_MASK ); -VM_BUG_ON_PAGE (!zone_spans_pfn (page_zone (page), pfn), page); bitmap =get_pageblock_bitmap (page, pfn); *bitidx =pfn_to_bitidx (page, pfn);
Sasha Levin
maintainerPATCH 1/2 mm: rejig pageblock mask definitions
From: Brendan Jackman <[email protected]>
[ Upstream commit 3687c0fd67249cb971990b382a47f02f19ed9f67 ]
- Add a PAGEBLOCK_ prefix to the names to avoid polluting the "global namespace" too much.
- This new prefix makes MIGRATETYPE_AND_ISO_MASK look pretty long. Well, that global mask only exists for quite a specific purpose, and is quite a weird thing to have a name for anyway. So drop it and take advantage of the newly-defined PAGEBLOCK_ISO_MASK.
Stable-dep-of: 2122887b04f3 ("mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx()")
--- include/linux/pageblock-flags.h | 6 +++--- mm/page_alloc.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-)
include/linux/pageblock-flags.h +3 -3
@@ -36,12 +36,12 @@ enum pageblock_bits {#define NR_PAGEBLOCK_BITS (roundup_pow_of_two(__NR_PAGEBLOCK_BITS)) -#define MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2)) +#define PAGEBLOCK_MIGRATETYPE_MASK (BIT(PB_migrate_0)|BIT(PB_migrate_1)|BIT(PB_migrate_2))#ifdef CONFIG_MEMORY_ISOLATION -#define MIGRATETYPE_AND_ISO_MASK (MIGRATETYPE_MASK | BIT(PB_migrate_isolate)) +#define PAGEBLOCK_ISO_MASK BIT(PB_migrate_isolate)#else -#define MIGRATETYPE_AND_ISO_MASK MIGRATETYPE_MASK +#define PAGEBLOCK_ISO_MASK 0#endif #if defined(CONFIG_HUGETLB_PAGE )
mm/page_alloc.c +9 -9
@@ -398,7 +398,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 >MIGRATETYPE_MASK ); +BUILD_BUG_ON (__MIGRATE_TYPE_END >PAGEBLOCK_MIGRATETYPE_MASK );VM_BUG_ON_PAGE (!zone_spans_pfn (page_zone (page), pfn), page); bitmap =get_pageblock_bitmap (page, pfn);
@@ -471,7 +471,7 @@ bool get_pfnblock_bit(const struct page *page, unsigned long pfn, __always_inline enum migratetypeget_pfnblock_migratetype (const struct page *page,unsigned long pfn) { -unsigned long mask =MIGRATETYPE_AND_ISO_MASK ; +unsigned long mask =PAGEBLOCK_MIGRATETYPE_MASK |PAGEBLOCK_ISO_MASK ;unsigned long flags; flags =__get_pfnblock_flags_mask (page, pfn, mask);
@@ -480,7 +480,7 @@ get_pfnblock_migratetype(const struct page *page, unsigned long pfn)if (flags &BIT (PB_migrate_isolate))return MIGRATE_ISOLATE ;#endif -return flags &MIGRATETYPE_MASK ; +return flags &PAGEBLOCK_MIGRATETYPE_MASK ; }/**
@@ -568,11 +568,11 @@ static void set_pageblock_migratetype(struct page *page, }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 */ +/* PAGEBLOCK_ISO_MASK clears PB_migrate_isolate if it is set */ #endif __set_pfnblock_flags_mask (page,page_to_pfn (page), (unsigned long )migratetype, -MIGRATETYPE_AND_ISO_MASK ); +PAGEBLOCK_MIGRATETYPE_MASK |PAGEBLOCK_ISO_MASK ); } void __meminit init_pageblock_migratetype(struct page *page,
@@ -598,7 +598,7 @@ void __meminit init_pageblock_migratetype(struct page *page, flags |=BIT (PB_migrate_isolate);#endif __set_pfnblock_flags_mask (page,page_to_pfn (page), flags, -MIGRATETYPE_AND_ISO_MASK ); +PAGEBLOCK_MIGRATETYPE_MASK |PAGEBLOCK_ISO_MASK ); }#ifdef CONFIG_DEBUG_VM
@@ -2179,15 +2179,15 @@ static bool __move_freepages_block_isolate(struct zone *zone, } move: -/* Use MIGRATETYPE_MASK to get non-isolate migratetype */ +/* Use PAGEBLOCK_MIGRATETYPE_MASK to get non-isolate migratetype */ if (isolate) { from_mt =__get_pfnblock_flags_mask (page,page_to_pfn (page), -MIGRATETYPE_MASK ); +PAGEBLOCK_MIGRATETYPE_MASK ); to_mt =MIGRATE_ISOLATE ; }else { from_mt =MIGRATE_ISOLATE ; to_mt =__get_pfnblock_flags_mask (page,page_to_pfn (page), -MIGRATETYPE_MASK ); +PAGEBLOCK_MIGRATETYPE_MASK ); }__move_freepages_block (zone, start_pfn, from_mt, to_mt);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx()
From: "Vlastimil Babka (SUSE)" <[email protected]>
[ Upstream commit 2122887b04f3f2d76daa80055c2c273926032fa0 ]
Whenever the flags of a pageblock are read or written, a kernel with CONFIG_DEBUG_VM makes sure that the pfn lies within the zone of the page. Unlike bad_range(), that check reads zone->zone_start_pfn and zone->spanned_pages without zone->span_seqlock.
Memory hotplug changes the two fields one after the other. If the lower end of a zone moves, the zone seems to end before its last pages in between. A page of that part which is freed at that moment, on another CPU, ends in
page dumped because: VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn)) kernel BUG at mm/page_alloc.c:372! free_unref_folios+0x55e/0xed0 folios_put_refs+0x2b5/0x530
An attempt has been made [1] to fix this with the span seqlock check. But that can trigger all sorts of problems in restricted contexts, as noted by sashiko [2].
Since this is just a sanity debug check and anything with BUG_ON is frowned upon anyway, just remove it altogether.
--- mm/page_alloc.c | 1 - 1 file changed, 1 deletion(-)
mm/page_alloc.c +0 -1
@@ -399,7 +399,6 @@ get_pfnblock_bitmap_bitidx(const struct page *page, unsigned long pfn,BUILD_BUG_ON (NR_PAGEBLOCK_BITS !=4 );#endif BUILD_BUG_ON (__MIGRATE_TYPE_END >PAGEBLOCK_MIGRATETYPE_MASK ); -VM_BUG_ON_PAGE (!zone_spans_pfn (page_zone (page), pfn), page); bitmap =get_pageblock_bitmap (page, pfn); *bitidx =pfn_to_bitidx (page, pfn);
Signature · 1 line
2.53.0