mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: rppt@kernel.org, akpm@linux-foundation.org, izumi.taku@jp.fujitsu.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	david@kernel.org, yuan1.liu@intel.com,
	Wei Yang <richard.weiyang@gmail.com>
Subject: [RFC Patch 1/3] mm/mm_init: adjust overlapped zone for mirror memory too
Date: Tue, 23 Jun 2026 09:23:49 +0000	[thread overview]
Message-ID: <20260623092351.13031-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20260623092351.13031-1-richard.weiyang@gmail.com>

When mirrored_kernelcore is set, adjust_zone_range_for_zone_movable() would
skip the adjustment if ZONE_MOVABLE starts within one zone.

This makes the zone, usually ZONE_NORMAL, ends the same as ZONE_MOVABLE.

For example, we have a system with following memory layout:

  memory[0x0]     [0x0000000000001000-0x000000000009efff], 0x000000000009e000 bytes on node 0 flags: 0x2
  memory[0x1]     [0x0000000000100000-0x00000000bffdefff], 0x00000000bfedf000 bytes on node 0 flags: 0x2
  memory[0x2]     [0x0000000100000000-0x000000013fffffff], 0x0000000040000000 bytes on node 0 flags: 0x2
  memory[0x3]     [0x0000000140000000-0x00000001bfffffff], 0x0000000080000000 bytes on node 0 flags: 0x0

With kernelcore=mirror set, current kernel set zone with below range:

  Normal  [100000, 1c0000]
  Movable [140000, 1c0000]

This changes the expected behavior of defer_init(), because it only expect to
defer_init() memory in last zone. As Zone Normal and Movable stops at the same
end_pfn, defer_init() would set first_deferred_pfn in Zone Normal. And what is
worse, pages belongs to Zone Normal would be counted as Zone Movable.

  Node 0, zone   Normal
          spanned  786432
          present  262144
          managed  34390
  Node 0, zone  Movable
          spanned  524288
          present  524288
          managed  715855    <- manage more pages than present

While when we look at the memory layout, we can see Zone Normal and Movable
could be not overlapped if we adjust Zone Normal just other movable zone case.
And we don't expect they would interleave.

After doing so, we have non-overlap Zones:

  Normal  [100000, 140000]
  Movable [140000, 1c0000]

And the page locality looks correct:

  Node 0, zone   Normal
          spanned  262144
          present  262144
          managed  233614
  Node 0, zone  Movable
          spanned  524288
          present  524288
          managed  524242

Fixes: 342332e6a925 ("mm/page_alloc.c: introduce kernelcore=mirror option")
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Yuan Liu <yuan1.liu@intel.com>
---
 mm/mm_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 7c4af27a6557..b8ff4aff19c0 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1170,8 +1170,7 @@ 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] &&
+		} else if (*zone_start_pfn < zone_movable_pfn[nid] &&
 			*zone_end_pfn > zone_movable_pfn[nid]) {
 			*zone_end_pfn = zone_movable_pfn[nid];
 
-- 
2.34.1


  reply	other threads:[~2026-06-23  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23  9:23 [RFC Patch 0/3] mm/mm_init: fix and cleanup mirrored_kernelcore Wei Yang
2026-06-23  9:23 ` Wei Yang [this message]
2026-06-23  9:23 ` [RFC Patch 2/3] mm/mm_init: remove overlap_memmap_init() as no overlapped zone Wei Yang
2026-06-23  9:23 ` [RFC Patch 3/3] mm/mm_init: remove special handling absent pages for mirrored_kernelcore Wei Yang
2026-06-25  6:36 ` [RFC Patch 0/3] mm/mm_init: fix and cleanup mirrored_kernelcore David Hildenbrand (Arm)

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=20260623092351.13031-2-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    --cc=yuan1.liu@intel.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

Powered by JetHome