From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Yuan Liu <yuan1.liu@intel.com>,
Oscar Salvador <osalvador@suse.de>,
Mike Rapoport <rppt@kernel.org>,
Wei Yang <richard.weiyang@gmail.com>
Cc: 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 2/2] mm/memory_hotplug: optimize zone contiguous check when changing pfn range
Date: Wed, 19 Aug 2026 17:53:45 +0200 [thread overview]
Message-ID: <ac77571f-4a10-4511-83e0-c6372d5b4a09@kernel.org> (raw)
In-Reply-To: <20260818085702.3395529-3-yuan1.liu@intel.com>
> /*
> * Only struct pages that correspond to ranges defined by memblock.memory
> * are zeroed and initialized by going through __init_single_page() during
> @@ -822,22 +844,27 @@ void __meminit init_deferred_page(unsigned long pfn, int nid)
> * zone/node above the hole except for the trailing pages in the last
> * section that will be appended to the zone/node below.
> */
> -static void __init init_unavailable_range(unsigned long spfn,
> - unsigned long epfn,
> - int zone, int node)
> +static unsigned long __init init_unavailable_range(unsigned long spfn,
> + unsigned long epfn,
> + int zone, int node)
> {
> unsigned long pfn;
> - u64 pgcnt = 0;
> + u64 pgcnt = 0, online_pgcnt = 0;
> + unsigned long last_subsection = -1;
> + bool is_online = false;
>
> for_each_valid_pfn(pfn, spfn, epfn) {
> __init_single_page(pfn_to_page(pfn), pfn, zone, node);
> __SetPageReserved(pfn_to_page(pfn));
> + if (unavailable_pfn_is_online(pfn, &last_subsection, &is_online))
> + online_pgcnt++;
Can we avoid these helpers?
const unsigned long subsection = pfn & PAGE_SUBSECTION_MASK;
/* We can have section-sized online holes with VMEMMAP. */
if (IS_ENMABLED(CONFIG_SPARSEMEM_VMEMMAP) &&
subsection != last_subsection) {
is_online = pfn_to_online_page(pfn);
last_subsection = subsection;
}
if (is_online)
online_pgcnt++;
An alternative is an inner loop that just walks in SUBSECTION chunks until epfn.
That would probably be even cleaner and faster.
I remember !vmemmap always only has early sections when they are actually
online. We could extent the comment to clarify that.
(I have patches to clean that init code up)
--
Cheers,
David
next prev parent reply other threads:[~2026-08-19 15:53 UTC|newest]
Thread overview: 12+ 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
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) [this message]
2026-08-20 13:21 ` Liu, Yuan1
2026-08-20 17:46 ` David Hildenbrand (Arm)
2026-08-21 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=ac77571f-4a10-4511-83e0-c6372d5b4a09@kernel.org \
--to=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=richard.weiyang@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.