[PATCH v2 60/69] mm/mm_init: Check zone consistency on optimized vmemmap sections
From: Muchun Song
Date: Wed May 13 2026 - 09:46:01 EST
For vmemmap-optimized sections, the shared tail struct pages are reused
across compound pages and should already carry the expected zone and
node.
Warn in __init_single_page() if such a shared tail page is seen with a
different zone or node, which would indicate inconsistent initialization.
Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
---
mm/mm_init.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 4ea39392993b..95422e92ede8 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -605,6 +605,9 @@ void __meminit __init_single_page(struct page *page, unsigned long pfn,
if (!is_highmem_idx(zone))
set_page_address(page, __va(pfn << PAGE_SHIFT));
#endif
+ VM_WARN_ON_ONCE(order_vmemmap_optimizable(pfn_to_section_order(pfn)) &&
+ page_zone_id(page + OPTIMIZED_FOLIO_VMEMMAP_NR_STRUCT_PAGES) !=
+ page_zone_id(page));
}
#ifdef CONFIG_NUMA
--
2.54.0