Re: [PATCH v5 1/5] mm: move mirrored memory overlap checking to the outer loop
From: Wei Yang
Date: Wed May 20 2026 - 23:34:44 EST
On Wed, May 20, 2026 at 05:34:53AM -0400, Yuan Liu wrote:
>Move the overlap memmap initialization check from memmap_init_range()
>to memmap_init(), and replace the per-PFN check with a memblock-based
>check.
The description is a little simple.
Even I know the purpose, I feel confused at the first glance.
>
>Reviewed-by: Wei Yang <richard.weiyang@xxxxxxxxx>
>Reviewed-by: Jason Zeng <jason.zeng@xxxxxxxxx>
>Signed-off-by: Yuan Liu <yuan1.liu@xxxxxxxxx>
>---
> mm/mm_init.c | 29 +++++------------------------
> 1 file changed, 5 insertions(+), 24 deletions(-)
>
>diff --git a/mm/mm_init.c b/mm/mm_init.c
>index f9f8e1af921c..24e103a402b0 100644
>--- a/mm/mm_init.c
>+++ b/mm/mm_init.c
>@@ -783,28 +783,6 @@ void __meminit init_deferred_page(unsigned long pfn, int nid)
> __init_deferred_page(pfn, nid);
> }
>
>-/* If zone is ZONE_MOVABLE but memory is mirrored, it is an overlapped init */
>-static bool __meminit
>-overlap_memmap_init(unsigned long zone, unsigned long *pfn)
>-{
>- static struct memblock_region *r __meminitdata;
>-
>- if (mirrored_kernelcore && zone == ZONE_MOVABLE) {
>- if (!r || *pfn >= memblock_region_memory_end_pfn(r)) {
>- for_each_mem_region(r) {
>- if (*pfn < memblock_region_memory_end_pfn(r))
>- break;
>- }
>- }
>- if (*pfn >= memblock_region_memory_base_pfn(r) &&
>- memblock_is_mirror(r)) {
>- *pfn = memblock_region_memory_end_pfn(r);
>- return true;
>- }
>- }
>- return false;
>-}
>-
> /*
> * Only struct pages that correspond to ranges defined by memblock.memory
> * are zeroed and initialized by going through __init_single_page() during
>@@ -891,8 +869,6 @@ void __meminit memmap_init_range(unsigned long size, int nid, unsigned long zone
> * function. They do not exist on hotplugged memory.
> */
> if (context == MEMINIT_EARLY) {
>- if (overlap_memmap_init(zone, &pfn))
>- continue;
> if (defer_init(nid, pfn, zone_end_pfn)) {
> deferred_struct_pages = true;
> break;
>@@ -956,6 +932,7 @@ static void __init memmap_init(void)
> int i, j, zone_id = 0, nid;
>
> for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) {
>+ struct memblock_region *r = &memblock.memory.regions[i];
> struct pglist_data *node = NODE_DATA(nid);
>
> for (j = 0; j < MAX_NR_ZONES; j++) {
>@@ -964,6 +941,10 @@ static void __init memmap_init(void)
> if (!populated_zone(zone))
> continue;
>
>+ if (mirrored_kernelcore && j == ZONE_MOVABLE &&
>+ memblock_is_mirror(r))
>+ continue;
>+
So you have figured out the memory layout of mirror memory?
Would you mind elaborate?
> memmap_init_zone_range(zone, start_pfn, end_pfn,
> &hole_pfn);
> zone_id = j;
>--
>2.47.3
--
Wei Yang
Help you, Help me