Re: [PATCH] mm/vmstat: flush per-cpu node stats when a node goes offline
From: Gregory Price
Date: Sat Jun 27 2026 - 04:24:04 EST
On Sat, Jun 27, 2026 at 03:31:07AM -0400, Gregory Price wrote:
>
> /*
> * all memory/cpu of this node are removed, we can offline this
> - * node now.
> + * node now. Fold any pending per-cpu vmstat diffs into the global
> + * counters first: once the node leaves the online set the periodic
> + * fold skips it, orphaning the residual on a later online.
> */
> + sync_vm_stats();
Sashiko points out this can deadlock on concurrent cpu hotplug, which
after a quick look seems accurate.
Has also made me realize the sync code is also racy with cpu hotplug
as well as it iterates per-online-cpu.
There are probably more races like this out there.
Will need to give this a little more thought.
> node_set_offline(nid);
> unregister_node(nid);
> }