From: "Liu, Yuan1" <yuan1.liu@intel.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
Mike Rapoport <rppt@kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"Hu, Yong" <yong.hu@intel.com>,
"Zou, Nanhai" <nanhai.zou@intel.com>,
"Tim Chen" <tim.c.chen@linux.intel.com>,
"Zhuo, Qiuxu" <qiuxu.zhuo@intel.com>,
"Chen, Yu C" <yu.c.chen@intel.com>,
"Deng, Pan" <pan.deng@intel.com>,
"Li, Tianyou" <tianyou.li@intel.com>,
Chen Zhang <zhangchen.kidd@jd.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v4 1/2] mm: move overlap memory map init check to memmap_init()
Date: Wed, 22 Apr 2026 07:08:01 +0000 [thread overview]
Message-ID: <MW4PR11MB69364A3A1AB994425E53DBE5A32D2@MW4PR11MB6936.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20260422011126.thu67icgj5qfbecj@master>
> -----Original Message-----
> From: Wei Yang <richard.weiyang@gmail.com>
> Sent: Wednesday, April 22, 2026 9:11 AM
> To: Liu, Yuan1 <yuan1.liu@intel.com>
> Cc: David Hildenbrand <david@kernel.org>; Oscar Salvador
> <osalvador@suse.de>; Mike Rapoport <rppt@kernel.org>; Wei Yang
> <richard.weiyang@gmail.com>; linux-mm@kvack.org; Hu, Yong
> <yong.hu@intel.com>; Zou, Nanhai <nanhai.zou@intel.com>; Tim Chen
> <tim.c.chen@linux.intel.com>; Zhuo, Qiuxu <qiuxu.zhuo@intel.com>; Chen, Yu
> C <yu.c.chen@intel.com>; Deng, Pan <pan.deng@intel.com>; Li, Tianyou
> <tianyou.li@intel.com>; Chen Zhang <zhangchen.kidd@jd.com>; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH v4 1/2] mm: move overlap memory map init check to
> memmap_init()
>
> On Tue, Apr 21, 2026 at 08:55:07AM -0400, Yuan Liu wrote:
> >Move the overlap memmap init check from memmap_init_range() into
> >memmap_init().
> >
> >When mirrored kernelcore is enabled, avoid memory map initialization
> >for overlap regions. There are two cases that may overlap: a mirror
> >memory region assigned to movable zone, or a non-mirror memory region
> >assigned to a non-movable zone but falling within the movable zone
> >range.
> >
> >Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
> >---
> > mm/mm_init.c | 37 +++++++++++++------------------------
> > 1 file changed, 13 insertions(+), 24 deletions(-)
> >
> >diff --git a/mm/mm_init.c b/mm/mm_init.c
> >index df34797691bd..2b5233060504 100644
> >--- a/mm/mm_init.c
> >+++ b/mm/mm_init.c
> >@@ -797,28 +797,6 @@ void __meminit reserve_bootmem_region(phys_addr_t
> start,
> > }
> > }
> >
> >-/* 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;
> >-
> >- 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
> >@@ -905,8 +883,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;
> >@@ -971,6 +947,7 @@ static void __init memmap_init(void)
> >
> > for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid)
> {
> > struct pglist_data *node = NODE_DATA(nid);
> >+ struct memblock_region *r = &memblock.memory.regions[i];
> >
> > for (j = 0; j < MAX_NR_ZONES; j++) {
> > struct zone *zone = node->node_zones + j;
> >@@ -978,6 +955,18 @@ static void __init memmap_init(void)
> > if (!populated_zone(zone))
> > continue;
> >
> >+ if (mirrored_kernelcore) {
> >+ const bool is_mirror = memblock_is_mirror(r);
> >+ const bool is_movable_zone = (j == ZONE_MOVABLE);
> >+
> >+ if (is_mirror && is_movable_zone)
> >+ continue;
> >+
> >+ if (!is_mirror && !is_movable_zone &&
> >+ start_pfn >= zone_movable_pfn[nid])
> >+ continue;
>
> IIUC, when mirrored_kernelcore is set but !memblock_has_mirror() or
> is_kdump_kernel(), zone_movable_pfn[nid] is kept to be 0.
>
> This means it will skip all memory regions.
You're right. I verified the case you mentioned that mirrored_kernelcore
is enabled but there are no mirrored memory blocks, it indeed has a problem.
Thank you very much for pointing that out.
> >+ }
> >+
> > memmap_init_zone_range(zone, start_pfn, end_pfn,
> > &hole_pfn);
> > zone_id = j;
> >--
> >2.47.3
>
> --
> Wei Yang
> Help you, Help me
next prev parent reply other threads:[~2026-04-22 7:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 12:55 [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range Yuan Liu
2026-04-21 12:55 ` [PATCH v4 1/2] mm: move overlap memory map init check to memmap_init() Yuan Liu
2026-04-22 1:11 ` Wei Yang
2026-04-22 3:26 ` Wei Yang
2026-04-22 9:28 ` Liu, Yuan1
2026-04-22 7:08 ` Liu, Yuan1 [this message]
2026-04-21 12:55 ` [PATCH v4 2/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range Yuan Liu
2026-04-22 7:46 ` [PATCH v4 0/2] " David Hildenbrand (Arm)
2026-04-22 7:56 ` Liu, Yuan1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW4PR11MB69364A3A1AB994425E53DBE5A32D2@MW4PR11MB6936.namprd11.prod.outlook.com \
--to=yuan1.liu@intel.com \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nanhai.zou@intel.com \
--cc=osalvador@suse.de \
--cc=pan.deng@intel.com \
--cc=qiuxu.zhuo@intel.com \
--cc=richard.weiyang@gmail.com \
--cc=rppt@kernel.org \
--cc=tianyou.li@intel.com \
--cc=tim.c.chen@linux.intel.com \
--cc=yong.hu@intel.com \
--cc=yu.c.chen@intel.com \
--cc=zhangchen.kidd@jd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox