From: Wei Yang <richard.weiyang@gmail.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: Yuan Liu <yuan1.liu@intel.com>,
David Hildenbrand <david@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
Wei Yang <richard.weiyang@gmail.com>,
linux-mm@kvack.org, Yong Hu <yong.hu@intel.com>,
Nanhai Zou <nanhai.zou@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Qiuxu Zhuo <qiuxu.zhuo@intel.com>,
Yu C Chen <yu.c.chen@intel.com>, Pan Deng <pan.deng@intel.com>,
Tianyou Li <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()
Date: Sun, 26 Apr 2026 04:00:48 +0000 [thread overview]
Message-ID: <20260426040048.43sh3dgtp52eqcjw@master> (raw)
In-Reply-To: <aeyC9i2TziSzY8_Z@kernel.org>
On Sat, Apr 25, 2026 at 11:01:42AM +0200, Mike Rapoport wrote:
[...]
>>
>> 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;
>> + }
>> +
>
Hi, Mike
Thanks for your review.
>I think this:
>
> if (mirrored_kernelcore && j == ZONE_MOVABLE &&
> memblock_is_mirror(r))
> continue;
>
>would be enough to remove overlap_memmap_init() and keep the existing
>logic.
>
>I wouldn't deal the theoretical cases Wei mentioned in this thread for
>now and prefer to keep the things simple.
That would be great to keep things simple.
>The assumptions that mirrored memory spans a contiguous range below some
>limit and that mirrored memory is not removable existed for years and I
>don't see why we should change the logic now and complicate the code for
>exotic theoretical memory layouts.
>
I don't follow here. Still not clear what the memory layout should be.
IIUC, case C is not real, but case A/B are.
I took case B as an example and do some tests. Below is my finding.
Here is memblock layout for case B, with the head 1G of ZONE_NORMAL is mirror
memory.
MEMBLOCK configuration:
memory size = 0x000000017ff7dc00 reserved size = 0x0000000005a939c2
memory.cnt = 0x4
memory[0x0] [0x0000000000001000-0x000000000009efff], node 0 flags: 0x2
memory[0x1] [0x0000000000100000-0x00000000bffdefff], node 0 flags: 0x2
memory[0x2] [0x0000000100000000-0x000000013fffffff], node 1 flags: 0x2
memory[0x3] [0x0000000140000000-0x00000001bfffffff], node 1 flags: 0x0
This meets:
* mirrored memory span from low to 0x13fffffff
Then I add below change along with your suggested change.
@@ -964,6 +964,8 @@ static void __init memmap_init_zone_range(struct zone *zone,
if (start_pfn >= end_pfn)
return;
+ pr_info(" [%lx, %lx] init to %s\n",
+ start_pfn, end_pfn, zone->name);
memmap_init_range(end_pfn - start_pfn, nid, zone_id, start_pfn,
zone_end_pfn, MEMINIT_EARLY, NULL, MIGRATE_MOVABLE,
false);
And see the last normal memory range is initialized twice.
[140000, 1c0000] init to Normal
[140000, 1c0000] init to Movable
Then I removed your suggested change and adjust code like below.
@@ -954,6 +954,7 @@ static void __init memmap_init_zone_range(struct zone *zone,
unsigned long end_pfn,
unsigned long *hole_pfn)
{
+ unsigned long old_start = start_pfn, old_end = end_pfn;
unsigned long zone_start_pfn = zone->zone_start_pfn;
unsigned long zone_end_pfn = zone_start_pfn + zone->spanned_pages;
int nid = zone_to_nid(zone), zone_id = zone_idx(zone);
,
start_pfn = clamp(start_pfn, zone_start_pfn, zone_end_pfn);
end_pfn = clamp(end_pfn, zone_start_pfn, zone_end_pfn);
- if (start_pfn >= end_pfn)
+ if (start_pfn >= end_pfn) {
+ pr_info(" [%lx, %lx] skipped to %s\n",
+ old_start, old_end, zone->name);
return;
+ }
+ pr_info(" [%lx, %lx] init to %s\n",
+ start_pfn, end_pfn, zone->name);
memmap_init_range(end_pfn - start_pfn, nid, zone_id, start_pfn,
zone_end_pfn, MEMINIT_EARLY, NULL, MIGRATE_MOVABLE,
false);
This shows current code already could skip the mirror range to ZONE_MOVABLE
for this kind memory layout, since ZONE_MOVABLE doesn't span to it.
[100000, 140000] skipped to Movable
[140000, 1c0000] init to Normal
[140000, 1c0000] init to Movable
So I am not sure the real mirrored memory layout could be. Would you mind
giving more detail to help me get on the right track?
>> memmap_init_zone_range(zone, start_pfn, end_pfn,
>> &hole_pfn);
>> zone_id = j;
>> --
>> 2.47.3
>>
>
>--
>Sincerely yours,
>Mike.
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2026-04-26 4:00 UTC|newest]
Thread overview: 16+ 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-24 1:05 ` Wei Yang
2026-04-24 7:49 ` Liu, Yuan1
2026-04-22 7:08 ` Liu, Yuan1
2026-04-25 9:01 ` Mike Rapoport
2026-04-26 4:00 ` Wei Yang [this message]
2026-04-27 0:31 ` Liu, Yuan1
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
2026-04-22 19:13 ` David Hildenbrand (Arm)
2026-04-23 3:17 ` 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=20260426040048.43sh3dgtp52eqcjw@master \
--to=richard.weiyang@gmail.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=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