From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>,
Oscar Salvador <osalvador@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
"open list:MEMORY HOT(UN)PLUG" <linux-mm@kvack.org>,
open list <linux-kernel@vger.kernel.org>
Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com
Subject: Re: [PATCH] mm/memory_hotplug: Cache auto_movable stats to optimize online check
Date: Sun, 7 Dec 2025 14:30:00 +0100 [thread overview]
Message-ID: <7cf016ec-70e4-4244-82f6-32718dc38cc6@kernel.org> (raw)
In-Reply-To: <20251206212507.135503-1-swarajgaikwad1925@gmail.com>
On 12/6/25 22:25, Swaraj Gaikwad wrote:
> The auto_movable_can_online_movable() function currently walks all
> populated zones when nid == NUMA_NO_NODE,
>
> Since adjust_present_page_count() is called every time memory is
> onlined/offlined and already updates present page counts, we can
> maintain cached global statistics that are updated incrementally. This
> eliminates the need to walk all zones for the NUMA_NO_NODE case.
>
> This patch introduces a static global_auto_movable_stats structure that
> caches kernel_early_pages and movable_pages counts. The cache is updated
> in adjust_present_page_count() whenever pages are onlined/offlined, and
> is read directly in auto_movable_can_online_movable() when
> nid == NUMA_NO_NODE.
>
> Testing: Built and booted the kernel successfully. Ran the memory
> management test suite in tools/testing/selftests/mm/ with
> ./run_vmtests.sh - all tests passed.
>
> Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>
> ---
> mm/memory_hotplug.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 63b9d500ec6c..ba43edba8c92 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -50,6 +50,8 @@ enum {
>
> static int memmap_mode __read_mostly = MEMMAP_ON_MEMORY_DISABLE;
>
> +static struct auto_movable_stats global_auto_movable_stats;
> +
> static inline unsigned long memory_block_memmap_size(void)
> {
> return PHYS_PFN(memory_block_size_bytes()) * sizeof(struct page);
> @@ -851,9 +853,7 @@ static bool auto_movable_can_online_movable(int nid, struct memory_group *group,
>
> /* Walk all relevant zones and collect MOVABLE vs. KERNEL stats. */
> if (nid == NUMA_NO_NODE) {
> - /* TODO: cache values */
The TODO was a bit unspecific: should have been "cache values if walking
all zones becomes a performance problem".
Is there a performance impact, or are you able to show a performance
difference?
--
Cheers
David
next prev parent reply other threads:[~2025-12-07 13:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-06 21:25 Swaraj Gaikwad
2025-12-07 10:16 ` kernel test robot
2025-12-07 13:30 ` David Hildenbrand (Red Hat) [this message]
2025-12-07 23:10 ` Swaraj Gaikwad
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=7cf016ec-70e4-4244-82f6-32718dc38cc6@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david.hunter.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=skhan@linuxfoundation.org \
--cc=swarajgaikwad1925@gmail.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