Re: [PATCH] mm/memory_hotplug: cache zone stats for "auto-movable" online policy

From: David Hildenbrand (Arm)

Date: Tue Sep 22 2026 - 06:23:42 EST


On 9/22/26 10:22, Zhijian Han wrote:
> When onlining memory using the "auto-movable" online policy with
> nid == NUMA_NO_NODE, auto_movable_can_online_movable() walks all
> populated zones across all nodes on each invocation to collect the
> MOVABLE vs. KERNEL_EARLY stats. This walk happens twice for every
> memory block onlining decision (global check and, with NUMA awareness
> enabled, per-node check) and is repeated for every single memory block
> that gets onlined, although the underlying zone counters rarely change.
>
> Cache the stats for nid == NUMA_NO_NODE and only recalculate them when
> a zone counter actually changes. All modifications of the relevant
> zone counters (present_pages, present_early_pages) funnel through
> adjust_present_page_count(), which is only called while holding the
> mem_hotplug_lock in write mode and the device_lock() of the memory
> block device. Invalidate the cache there, such that the next
> auto-movable onlining decision recalculates the stats from scratch.
>
> CMA adjustments (zone->cma_pages) only happen during boot (via
> init_cma_reserved_pageblock()/init_cma_pageblock(), both __init) and
> cannot race with memory onlining. Boot-time zone initialization
> happens before any memory block can be onlined.
>
> The per-node path (nid != NUMA_NO_NODE) is left uncached; it only
> walks a single node's zones.
>
> Resolve a TODO that was left when the "auto-movable" online policy was
> introduced.

I have to ask

1) Why is this TODO a concern for you. Are you a frequent memory hotplug user or
somehow working on memory hotplug.

2) Did you use an LLM to come up with this idea or this patch.

3) Why is there no discussion / performance measurements whether the TODO should
be removed instead.

I'll point you at:
https://lore.kernel.org/linux-mm/20251206212507.135503-1-swarajgaikwad1925@xxxxxxxxx/


--
Cheers,

David