From 90095171a18712122ca666ac1ee32ef56bf7db67 Mon Sep 17 00:00:00 2001 From: Cheng Lingfei Date: Sun, 5 Jul 2026 12:25:47 +0000 Subject: [PATCH] mm: init hole_pfn from first memblock region instead of 0 In memmap_init(), hole_pfn starts at 0 and is used to track the start of the next hole in init_unavailable_range(). When the first memblock memory region does not start at PFN 0 (e.g., LKL with MMU where memory starts at ARCH_PFN_OFFSET), hole_pfn = 0 causes init_unavailable_range(0, start_pfn, ...) to be called for PFNs that have no corresponding struct page allocated. Currently this is safe because pfn_valid() returns false for those PFNs and the pageblock-skip logic in init_unavailable_range() prevents pfn_to_page() from being called. However, it wastes boot time iterating through empty pageblocks. Fix by initializing hole_pfn to the start_pfn of the first memblock memory region. With this fix, unnecessary init_unavailable_range() call is skipped entirely. Signed-off-by: Cheng Lingfei --- mm/mm_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 4ba5607aaf1943..77a185203a7a0b 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -940,7 +940,7 @@ static void __init memmap_init_zone_range(struct zone *zone, static void __init memmap_init(void) { unsigned long start_pfn, end_pfn; - unsigned long hole_pfn = 0; + unsigned long hole_pfn = ARCH_PFN_OFFSET; int i, j, zone_id = 0, nid; for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) {