Re: [PATCH v2] mm/vmstat: fold stranded per-cpu node stats when a node comes online
From: Gregory Price
Date: Tue Jun 30 2026 - 16:58:02 EST
On Sat, Jun 27, 2026 at 04:10:07PM -0700, Andrew Morton wrote:
> On Sat, 27 Jun 2026 16:22:43 -0400 Gregory Price <gourry@xxxxxxxxxx> wrote:
>
> > + struct per_cpu_nodestat *p = per_cpu_ptr(pgdat->per_cpu_nodestats, cpu);
> >
> > - p = per_cpu_ptr(pgdat->per_cpu_nodestats, cpu);
> > + for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
>
> and that's a lot of items.
>
> I guess the overall loop count won't be large enough to cause issues,
> but it's large!
>
> Perhaps there's some simple test we can do on the per_cpu_nodestat to
> avoid the inner loop? Perhaps might need to add a field for this?
>
I took a look, but that would involve adding another per-cpu field and
then making sure all the races on that field are respected as well.
Not sure it's worth it for such an extremely rare event.
I can try to get clever on the folding logic if you'd like, let me know.
> btw, "for(int i..." is allowed nowadays. It'll make this code nicer, IMO.
>
Otherwise i can send you a respin for this.
> And... Sashiko seems to have found a pre-existing issue:
> https://sashiko.dev/#/patchset/20260627202243.758289-1-gourry@xxxxxxxxxx
>
Incoming patch for this shortly. Pretty trivial.
~Gregory