From: Wei Yang <richard.weiyang@gmail.com>
To: Yuan Liu <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, Nanhai Zou <nanhai.zou@intel.com>,
Chen Zhang <zhangchen.kidd@jd.com>,
Jason Zeng <jason.zeng@intel.com>, Chen Yu <yu.c.chen@intel.com>,
Pan Deng <pan.deng@intel.com>, Tianyou Li <tianyou.li@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 1/2] mm/memory_hotplug: make shrink_zone_span() more robust
Date: Fri, 21 Aug 2026 03:14:27 +0000 [thread overview]
Message-ID: <20260821031427.qq6mb3j2zqtzdl3n@master> (raw)
In-Reply-To: <20260818085702.3395529-2-yuan1.liu@intel.com>
On Tue, Aug 18, 2026 at 04:57:01AM -0400, Yuan Liu wrote:
>From: "David Hildenbrand (Arm)" <david@kernel.org>
>
>Let's make shrink_zone_span() more robust by checking in
>find_smallest_section_pfn() / find_biggest_section_pfn() that the
>start and end PFNs of the subsection are within the zone.
>
>While at it, clean up the function by factoring the core check out
>into subsection_overlaps_zone().
>
>There likely is no need to check the nid first. We require
>SPARSEMEM_VMEMMAP_ENABLE, where pfn_to_page() is cheap, and
>pfn_to_nid() on CONFIG_NUMA would call pfn_to_page() either way.
>So let's just drop that for now.
>
>Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>Tested-by: Yuan Liu <yuan1.liu@intel.com>
>Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
>---
> mm/memory_hotplug.c | 59 ++++++++++++++++++---------------------------
> 1 file changed, 24 insertions(+), 35 deletions(-)
>
>diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>index 7ac19fab2263..cd82e79f0782 100644
>--- a/mm/memory_hotplug.c
>+++ b/mm/memory_hotplug.c
>@@ -422,49 +422,39 @@ int __add_pages(int nid, unsigned long pfn, unsigned long nr_pages,
> return err;
> }
>
>-/* find the smallest valid pfn in the range [start_pfn, end_pfn) */
>-static unsigned long find_smallest_section_pfn(int nid, struct zone *zone,
>- unsigned long start_pfn,
>- unsigned long end_pfn)
>+static bool subsection_overlaps_zone(unsigned long pfn, struct zone *zone)
> {
>- for (; start_pfn < end_pfn; start_pfn += PAGES_PER_SUBSECTION) {
>- if (unlikely(!pfn_to_online_page(start_pfn)))
>- continue;
>+ const unsigned long start_pfn = ALIGN_DOWN(pfn, PAGES_PER_SUBSECTION);
>+ const unsigned long end_pfn = start_pfn + PAGES_PER_SUBSECTION - 1;
>
>- if (unlikely(pfn_to_nid(start_pfn) != nid))
>- continue;
Would we have a memory layout with node interleave?
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2026-08-21 3:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 8:57 [PATCH v7 0/2] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Yuan Liu
2026-08-18 8:57 ` [PATCH v7 1/2] mm/memory_hotplug: make shrink_zone_span() more robust Yuan Liu
2026-08-20 12:52 ` Liu, Yuan1
2026-08-21 3:14 ` Wei Yang [this message]
2026-08-21 9:32 ` David Hildenbrand (Arm)
2026-08-18 8:57 ` [PATCH v7 2/2] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Yuan Liu
2026-08-19 14:56 ` Mike Rapoport
2026-08-19 15:43 ` David Hildenbrand (Arm)
2026-08-19 15:53 ` David Hildenbrand (Arm)
2026-08-20 13:21 ` Liu, Yuan1
2026-08-20 17:46 ` David Hildenbrand (Arm)
2026-08-21 3:17 ` Liu, Yuan1
2026-08-26 9:06 ` 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=20260821031427.qq6mb3j2zqtzdl3n@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=rppt@kernel.org \
--cc=tianyou.li@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