mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: "Liu, Yuan1" <yuan1.liu@intel.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	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>,
	"Zeng, Jason" <jason.zeng@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 1/5] mm: move mirrored memory overlap checking to the outer loop
Date: Fri, 12 Jun 2026 02:44:04 +0000	[thread overview]
Message-ID: <20260612024404.suzszzpzj3x7e7cu@master> (raw)
In-Reply-To: <MW4PR11MB69363A902465ABC015CE5E2BA3122@MW4PR11MB6936.namprd11.prod.outlook.com>

On Tue, Jun 02, 2026 at 07:55:11AM +0000, Liu, Yuan1 wrote:
>> -----Original Message-----
>> From: Wei Yang <richard.weiyang@gmail.com>
>> Sent: Monday, May 25, 2026 4:36 PM
>> To: Liu, Yuan1 <yuan1.liu@intel.com>
>> Cc: Wei Yang <richard.weiyang@gmail.com>; David Hildenbrand
>> <david@kernel.org>; Oscar Salvador <osalvador@suse.de>; Mike Rapoport
>> <rppt@kernel.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>; Zeng, Jason <jason.zeng@intel.com>; linux-
>> kernel@vger.kernel.org
>> Subject: Re: [PATCH v5 1/5] mm: move mirrored memory overlap checking to
>> the outer loop
>> 
>> On Fri, May 22, 2026 at 07:43:38AM +0000, Liu, Yuan1 wrote:
>> >> Subject: Re: [PATCH v5 1/5] mm: move mirrored memory overlap checking
>> to
>> >> the outer loop
>> >>
>> >> 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.
>> >
>> >Thanks for the review.
>> >I will try to rephrase it and provide a clearer description in the next
>> version.
>> >
>> >> >
>> >> >Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
>> >> >Reviewed-by: Jason Zeng <jason.zeng@intel.com>
>> >> >Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
>> >> >---
>> >> > 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?
>> >
>> >I have a Xeon server, collected mirror memory layout information as below
>> by using follow changes:
>> >
>> >int __init_memblock memblock_mark_mirror(phys_addr_t base, phys_addr_t
>> size)
>> > {
>> >-       if (!mirrored_kernelcore)
>> >+       int ret;
>> >+       phys_addr_t end = base + size - 1;
>> >+
>> >+       pr_info("memblock_mark_mirror: base=%pa, size=%pa,
>> mirrored_kernelcore=%d\n",
>> >+               &base, &size, mirrored_kernelcore);
>> >+
>> >+       if (!mirrored_kernelcore) {
>> >+               pr_info("memblock_mark_mirror: mirrored_kernelcore not
>> enabled, skipping\n");
>> >                return 0;
>> >+       }
>> >
>> >        system_has_some_mirror = true;
>> >
>> >-       return memblock_setclr_flag(&memblock.memory, base, size, 1,
>> MEMBLOCK_MIRROR);
>> >+       ret = memblock_setclr_flag(&memblock.memory, base, size, 1,
>> MEMBLOCK_MIRROR);
>> >+       pr_info("memblock_mark_mirror: marked [%pa-%pa] as MIRROR,
>> ret=%d\n",
>> >+               &base, &end, ret);
>> >+       return ret;
>> > }
>> >
>> >Here is the detailed layout information:
>> >
>> 
>> Thanks for the detailed output.
>> 
>> After some investigation, I got two things to discuss here:
>> 
>>   * current mirror memory would disable memmap defer init
>>   * confirm the mirror memory layout and may simplify handling
>> 
>> Before discussion, let me mark the key point in the output below.
>> 
>> >Case 1: efibootmgr -m t -M 0
>> >Enable mirror memory below 4GB, and no mirror memory above 4G
>> >
>> >=== zoneinfo summary ===
>> >node   zone       start_pfn    end_pfn      start_addr         end_addr
>> >------ ---------- ------------ ------------ ------------------ ----------
>> ---
>> >0      DMA        0x1          0xfff        0x1000             0xffffff
>> >0      DMA32      0x1000       0xfffff      0x1000000          0xffffffff
>> >0      Normal     0x100000     0x7fbffff    0x100000000        0x7fbfffffff
>> >0      Movable    0x140000     0x7fbffff    0x140000000        0x7fbfffffff
>> 
>> (1) Normal and Movable zone end with the same address, so overlapped.
>> 
>> >1      Normal     0x7fc0000    0xff7ffff    0x7fc0000000
>> 0xff7fffffff
>> >1      Movable    0x8000000    0xff7ffff    0x8000000000
>> 0xff7fffffff
>> 
>> The same as (1).
>> 
>> >
>> >node  start                end                  size              flags   mirror   pfn_range
>> >----  -------------------- -------------------- ------------ ------------ --- -------- ------------------
>> >0     0x0000000000001000   0x000000000009dfff   0x000000000009d000 0x2    yes      0x1-0x9e
>> >0     0x000000000009f000   0x000000000009ffff   0x0000000000001000 0x2    yes      0x9f-0xa0
>> >0     0x0000000000100000   0x0000000066416fff   0x0000000066317000 0x2    yes      0x100-0x66417
>> >0     0x00000000777ff000   0x00000000777fffff   0x0000000000001000 0x2    yes      0x777ff-0x77800
>> >0     0x0000000100000000   0x000000013fffffff   0x0000000040000000 0x2    yes      0x100000-0x140000
>> 
>> (2) You mentioned no mirror memory above 4G. If my understanding is
>> correct, 4G's
>> address is 0x100000000. So why this range is marked mirror? Is there some
>> limitation for this?
>
>Hi Wei
>
>efibootmgr enables mirror memory below 4 GB through the -m (--mirror-below-4G)
>option, and configures the percentage of memory to be mirrored above 4 GB through
>the -M (--mirror-above-4G) option.
>

The efibootmgr command used here is: efibootmgr -m t -M 0

This means we expect it configure 0% memory to be mirrored above 4G. But we
see the range [0x100000000, 0x13ffffff] is mirrored, which is above 4G.

Also for the range in node 1, we have mirrored memory.

So I am afraid the behavior is not what it literally means. Or I missed
something?

While more critical thing to confirm is ...

>My understanding is that the layout of mirrored memory is determined by the BIOS.

... after the BIOS configuration, kernel would only see
contiguous mirrored memory for each NUMA node, right? So that we could handle
mirrored memory correctly.

BTW, I mentioned two issues in last reply:

  * error on node span calculation
  * defer_init misbehavior with mirrored memory

Have you checked about it? Is my finding reasonable?

-- 
Wei Yang
Help you, Help me

  reply	other threads:[~2026-06-12  2:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  9:34 [PATCH v5 0/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Yuan Liu
2026-05-20  9:34 ` [PATCH v5 1/5] mm: move mirrored memory overlap checking to the outer loop Yuan Liu
2026-05-21  3:33   ` Wei Yang
2026-05-22  7:43     ` Liu, Yuan1
2026-05-25  8:35       ` Wei Yang
2026-06-02  7:55         ` Liu, Yuan1
2026-06-12  2:44           ` Wei Yang [this message]
2026-06-25 12:04   ` David Hildenbrand (Arm)
2026-06-26  8:26     ` Liu, Yuan1
2026-07-02 13:19       ` David Hildenbrand (Arm)
2026-07-10  3:19         ` Liu, Yuan1
2026-05-20  9:34 ` [PATCH v5 2/5] mm: skip non-mirrored ZONE_NORMAL memory map init when kernelcore=mirror Yuan Liu
2026-05-20  9:34 ` [PATCH v5 3/5] mm: remove the special early-section handling from pfn_valid() and for_each_valid_pfn() Yuan Liu
2026-05-20  9:34 ` [PATCH v5 4/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Yuan Liu
2026-05-20  9:34 ` [PATCH v5 5/5] mm/memory_hotplug: improve shrink_zone_span() subsection boundary checks Yuan Liu
2026-05-21  2:59 ` [PATCH v5 0/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Wei Yang
2026-05-21  5:16   ` Liu, Yuan1
2026-06-01  7:17 ` Mike Rapoport
2026-06-02  7:37   ` 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=20260612024404.suzszzpzj3x7e7cu@master \
    --to=richard.weiyang@gmail.com \
    --cc=david@kernel.org \
    --cc=jason.zeng@intel.com \
    --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=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=yuan1.liu@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

all inboxes | Powered by JetHome®