When mirrored_kernelcore is set, adjust_zone_range_for_zone_movable() would skip the adjustment if ZONE_MOVABLE starts within one zone. This makes the zone, usually ZONE_NORMAL, ends the same as ZONE_MOVABLE. For example, we have a system with following memory layout: memory[0x0] [0x0000000000001000-0x000000000009efff], 0x000000000009e000 bytes on node 0 flags: 0x2 memory[0x1] [0x0000000000100000-0x00000000bffdefff], 0x00000000bfedf000 bytes on node 0 flags: 0x2 memory[0x2] [0x0000000100000000-0x000000013fffffff], 0x0000000040000000 bytes on node 0 flags: 0x2 memory[0x3] [0x0000000140000000-0x00000001bfffffff], 0x0000000080000000 bytes on node 0 flags: 0x0 With kernelcore=mirror set, current kernel set zone with below range: Normal [100000, 1c0000] Movable [140000, 1c0000] This changes the expected behavior of defer_init(), because it only expect to defer_init() memory in last zone. As Zone Normal and Movable stops at the same end_pfn, defer_init() would set first_deferred_pfn in Zone Normal. And what is worse, pages belongs to Zone Normal would be counted as Zone Movable. Node 0, zone Normal spanned 786432 present 262144 managed 34390 Node 0, zone Movable spanned 524288 present 524288 managed 715855 <- manage more pages than present While when we look at the memory layout, we can see Zone Normal and Movable could be not overlapped if we adjust Zone Normal just other movable zone case. And we don't expect they would interleave. After doing so, we have non-overlap Zones: Normal [100000, 140000] Movable [140000, 1c0000] And the page locality looks correct: Node 0, zone Normal spanned 262144 present 262144 managed 233614 Node 0, zone Movable spanned 524288 present 524288 managed 524242 Fixes: 342332e6a925 ("mm/page_alloc.c: introduce kernelcore=mirror option") Signed-off-by: Wei Yang Cc: "David Hildenbrand (Arm)" Cc: Yuan Liu --- mm/mm_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 7c4af27a6557..b8ff4aff19c0 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1170,8 +1170,7 @@ static void __init adjust_zone_range_for_zone_movable(int nid, arch_zone_highest_possible_pfn[movable_zone]); /* Adjust for ZONE_MOVABLE starting within this range */ - } else if (!mirrored_kernelcore && - *zone_start_pfn < zone_movable_pfn[nid] && + } else if (*zone_start_pfn < zone_movable_pfn[nid] && *zone_end_pfn > zone_movable_pfn[nid]) { *zone_end_pfn = zone_movable_pfn[nid]; -- 2.34.1