[PATCH v5 2/5] mm: skip non-mirrored ZONE_NORMAL memory map init when kernelcore=mirror

From: Yuan Liu

Date: Wed May 20 2026 - 05:35:59 EST


Mirrored regions are already skipped when initializing ZONE_MOVABLE, but
overlapping PFNs can still be initialized from the ZONE_NORMAL path when
ZONE_MOVABLE is present on the node.

When zone_movable_pfn[nid] is set, skip ZONE_NORMAL initialization for
non-mirrored regions, keep skipping mirrored regions for ZONE_MOVABLE.

Reviewed-by: Wei Yang <richard.weiyang@xxxxxxxxx>
Reviewed-by: Jason Zeng <jason.zeng@xxxxxxxxx>
Co-developed-by: Wei Yang <richard.weiyang@xxxxxxxxx>
Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
Signed-off-by: Yuan Liu <yuan1.liu@xxxxxxxxx>
---
mm/mm_init.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 24e103a402b0..2a5ac175d5dd 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -941,9 +941,18 @@ static void __init memmap_init(void)
if (!populated_zone(zone))
continue;

- if (mirrored_kernelcore && j == ZONE_MOVABLE &&
- memblock_is_mirror(r))
- continue;
+ if (mirrored_kernelcore) {
+ /*
+ * Avoid double initialization of PFNs that overlap
+ * between Normal and Movable zones.
+ */
+ if (j == ZONE_NORMAL && !memblock_is_mirror(r) &&
+ zone_movable_pfn[nid])
+ continue;
+
+ if (j == ZONE_MOVABLE && memblock_is_mirror(r))
+ continue;
+ }

memmap_init_zone_range(zone, start_pfn, end_pfn,
&hole_pfn);
--
2.47.3