Re: [PATCH] mm/vmstat: flush per-cpu node stats when a node goes offline
From: Gregory Price
Date: Sat Jun 27 2026 - 16:42:30 EST
On Sat, Jun 27, 2026 at 03:31:07AM -0400, Gregory Price wrote:
> A per-node vmstat counter is pgdat->vm_stat[] plus per-cpu deltas.
> A balanced counter can sit split as global=+N / per-cpu=-N.
>
> The folds reconciling the split only walk online nodes, so when
> try_offline_node() marks a node offline - per-cpu deltas are stranded.
>
> A subsequent online zeroes the per-cpu area but not pgdat->vm_stat[],
> orphaning the +N permanently. All NR_VM_NODE_STAT_ITEMS are affected.
>
> Flush the deltas before the node leaves the online set. A remote
> fold races the periodic per-cpu fold, so do it as per-cpu work.
>
> Discovered when a node/compact call hung for a nearly empty node, as
> the math to determine throttling broke. Reproduced by repeated memory
> hotplug/unplug cycles on a node under pressure. NR_ISOLATED_ANON
> ratchets up and never returns to zero.
>
> Fixes: 75ef71840539 ("mm, vmstat: add infrastructure for per-node vmstats")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Gregory Price <gourry@xxxxxxxxxx>
Realized I changed the title on v2:
https://lore.kernel.org/linux-mm/20260627073107.523499-1-gourry@xxxxxxxxxx/
Core issue was the zeroing at online time causing the skew, just have to
do the fold there instead. disregard this version please