* [PATCH 0/2] mm/mm_init: don't overlap zones with kernelcore=mirror @ 2026-06-25 7:39 Mike Rapoport 2026-06-25 7:39 ` [PATCH 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE " Mike Rapoport 2026-06-25 7:39 ` [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() Mike Rapoport 0 siblings, 2 replies; 6+ messages in thread From: Mike Rapoport @ 2026-06-25 7:39 UTC (permalink / raw) To: linux-mm Cc: Andrew Morton, David Hildenbrand, Mike Rapoport, Taku Izumi, Wei Yang, Yuan Liu, linux-kernel From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, These patches make the behaviour of kernelcore= parameter uniform and treat mirror just as another way to size the zones and cleanup a weird part of the memory map initialization. Mike Rapoport (Microsoft) (2): mm/mm_init: don't overlap NORMAL and MOVABLE zones with kernelcore=mirror mm/mm_init: drop overlap_memmap_init() mm/mm_init.c | 60 +++------------------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) base-commit: 4549871118cf616eecdd2d939f78e3b9e1dddc48 -- 2.53.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE zones with kernelcore=mirror 2026-06-25 7:39 [PATCH 0/2] mm/mm_init: don't overlap zones with kernelcore=mirror Mike Rapoport @ 2026-06-25 7:39 ` Mike Rapoport 2026-06-25 10:42 ` David Hildenbrand (Arm) 2026-06-25 7:39 ` [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() Mike Rapoport 1 sibling, 1 reply; 6+ messages in thread From: Mike Rapoport @ 2026-06-25 7:39 UTC (permalink / raw) To: linux-mm Cc: Andrew Morton, David Hildenbrand, Mike Rapoport, Taku Izumi, Wei Yang, Yuan Liu, linux-kernel From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> When kernelcore or movablecore kernel parameters define size of the NORMAL and MOVABLE zones as percents of the total memory or by absolute value, ZONE_NORMAL is clamped at the beginning of ZONE_MOVABLE. However, when kernelcore=mirror the ZONE_NORMAL span is not changed but rather pages from ZONE_MOVABLE counted as absent in ZONE_NORMAL. Make the behaviour of kernelcore= parameter uniform and treat mirror just as another way to size the zones. Co-developed-by: Wei Yang <richard.weiyang@gmail.com> Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- mm/mm_init.c | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index f9f8e1af921c..dce9dc9f2302 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1159,9 +1159,8 @@ 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] && - *zone_end_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]; /* Check if this whole range is within ZONE_MOVABLE */ @@ -1209,40 +1208,11 @@ static unsigned long __init zone_absent_pages_in_node(int nid, unsigned long zone_start_pfn, unsigned long zone_end_pfn) { - unsigned long nr_absent; - /* zone is empty, we don't have any absent pages */ if (zone_start_pfn == zone_end_pfn) return 0; - nr_absent = __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn); - - /* - * ZONE_MOVABLE handling. - * Treat pages to be ZONE_MOVABLE in ZONE_NORMAL as absent pages - * and vice versa. - */ - if (mirrored_kernelcore && zone_movable_pfn[nid]) { - unsigned long start_pfn, end_pfn; - struct memblock_region *r; - - for_each_mem_region(r) { - start_pfn = clamp(memblock_region_memory_base_pfn(r), - zone_start_pfn, zone_end_pfn); - end_pfn = clamp(memblock_region_memory_end_pfn(r), - zone_start_pfn, zone_end_pfn); - - if (zone_type == ZONE_MOVABLE && - memblock_is_mirror(r)) - nr_absent += end_pfn - start_pfn; - - if (zone_type == ZONE_NORMAL && - !memblock_is_mirror(r)) - nr_absent += end_pfn - start_pfn; - } - } - - return nr_absent; + return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn); } /* -- 2.53.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE zones with kernelcore=mirror 2026-06-25 7:39 ` [PATCH 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE " Mike Rapoport @ 2026-06-25 10:42 ` David Hildenbrand (Arm) 0 siblings, 0 replies; 6+ messages in thread From: David Hildenbrand (Arm) @ 2026-06-25 10:42 UTC (permalink / raw) To: Mike Rapoport, linux-mm Cc: Andrew Morton, Taku Izumi, Wei Yang, Yuan Liu, linux-kernel On 6/25/26 09:39, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > > When kernelcore or movablecore kernel parameters define size of the > NORMAL and MOVABLE zones as percents of the total memory or by absolute > value, ZONE_NORMAL is clamped at the beginning of ZONE_MOVABLE. > > However, when kernelcore=mirror the ZONE_NORMAL span is not changed but > rather pages from ZONE_MOVABLE counted as absent in ZONE_NORMAL. > > Make the behaviour of kernelcore= parameter uniform and treat mirror > just as another way to size the zones. That sounds just about right to me. Hard to imagine that any code would have relied on the old behavior. Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() 2026-06-25 7:39 [PATCH 0/2] mm/mm_init: don't overlap zones with kernelcore=mirror Mike Rapoport 2026-06-25 7:39 ` [PATCH 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE " Mike Rapoport @ 2026-06-25 7:39 ` Mike Rapoport 2026-06-25 9:58 ` Wei Yang 2026-06-25 10:43 ` David Hildenbrand (Arm) 1 sibling, 2 replies; 6+ messages in thread From: Mike Rapoport @ 2026-06-25 7:39 UTC (permalink / raw) To: linux-mm Cc: Andrew Morton, David Hildenbrand, Mike Rapoport, Taku Izumi, Wei Yang, Yuan Liu, linux-kernel From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> When ZONE_NORMAL and ZONE_MOVABLE could overlap because kernelcore=mirror didn't reduce the span of ZONE_NORMAL, initialization of the memory map had to skip overlapping pages during initialization of ZONE_MOVABLE to avoid double initialization of the same struct pages. Since kernelcore=mirror works now the same way as other variants of kernelcore=/movablecore=, and adjusts the span of ZONE_NORMAL, there can't be an overlap between ZONE_NORMAL and ZONE_MOVABLE. Remove overlap_memmap_init(). Co-developed-by: Wei Yang <richard.weiyang@gmail.com> Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- mm/mm_init.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index dce9dc9f2302..6f0a71ccca30 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; -- 2.53.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() 2026-06-25 7:39 ` [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() Mike Rapoport @ 2026-06-25 9:58 ` Wei Yang 2026-06-25 10:43 ` David Hildenbrand (Arm) 1 sibling, 0 replies; 6+ messages in thread From: Wei Yang @ 2026-06-25 9:58 UTC (permalink / raw) To: Mike Rapoport Cc: linux-mm, Andrew Morton, David Hildenbrand, Taku Izumi, Wei Yang, Yuan Liu, linux-kernel On Thu, Jun 25, 2026 at 10:39:40AM +0300, Mike Rapoport wrote: >From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > >When ZONE_NORMAL and ZONE_MOVABLE could overlap because kernelcore=mirror >didn't reduce the span of ZONE_NORMAL, initialization of the memory map had >to skip overlapping pages during initialization of ZONE_MOVABLE to avoid >double initialization of the same struct pages. > >Since kernelcore=mirror works now the same way as other variants of >kernelcore=/movablecore=, and adjusts the span of ZONE_NORMAL, there can't >be an overlap between ZONE_NORMAL and ZONE_MOVABLE. > >Remove overlap_memmap_init(). > Hi, Mike Do you think this is valuable to mention the double init for the overlapped range? >Co-developed-by: Wei Yang <richard.weiyang@gmail.com> >Signed-off-by: Wei Yang <richard.weiyang@gmail.com> >Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> >--- > mm/mm_init.c | 24 ------------------------ > 1 file changed, 24 deletions(-) > >diff --git a/mm/mm_init.c b/mm/mm_init.c >index dce9dc9f2302..6f0a71ccca30 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; >-- >2.53.0 -- Wei Yang Help you, Help me ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() 2026-06-25 7:39 ` [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() Mike Rapoport 2026-06-25 9:58 ` Wei Yang @ 2026-06-25 10:43 ` David Hildenbrand (Arm) 1 sibling, 0 replies; 6+ messages in thread From: David Hildenbrand (Arm) @ 2026-06-25 10:43 UTC (permalink / raw) To: Mike Rapoport, linux-mm Cc: Andrew Morton, Taku Izumi, Wei Yang, Yuan Liu, linux-kernel On 6/25/26 09:39, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > > When ZONE_NORMAL and ZONE_MOVABLE could overlap because kernelcore=mirror > didn't reduce the span of ZONE_NORMAL, initialization of the memory map had > to skip overlapping pages during initialization of ZONE_MOVABLE to avoid > double initialization of the same struct pages. > > Since kernelcore=mirror works now the same way as other variants of > kernelcore=/movablecore=, and adjusts the span of ZONE_NORMAL, there can't > be an overlap between ZONE_NORMAL and ZONE_MOVABLE. > > Remove overlap_memmap_init(). > > Co-developed-by: Wei Yang <richard.weiyang@gmail.com> > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > --- Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-25 10:43 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-25 7:39 [PATCH 0/2] mm/mm_init: don't overlap zones with kernelcore=mirror Mike Rapoport 2026-06-25 7:39 ` [PATCH 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE " Mike Rapoport 2026-06-25 10:42 ` David Hildenbrand (Arm) 2026-06-25 7:39 ` [PATCH 2/2] mm/mm_init: drop overlap_memmap_init() Mike Rapoport 2026-06-25 9:58 ` Wei Yang 2026-06-25 10:43 ` David Hildenbrand (Arm)
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.