Re: [PATCH] lib/percpu_counter: allow concurrent sums with an rwlock

From: Andrew Morton

Date: Sun Nov 15 2026 - 22:44:09 EST


On Sun, 15 Nov 2026 19:16:36 -0800 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:

> > stress-ng dentry test average throughput change:
> >
> > +------------------------+------------+--------------------+
> > | Case | Unit | Average change (%) |
> > +------------------------+------------+--------------------+
> > | Dentry, 64 workers | bogo ops/s | +47.34 |
> > +------------------------+------------+--------------------+
> >
> > Dentry ran on ext4 with 64 workers pinned to physical CPUs:
> >
> > stress-ng --dentry 64 --dentries 4096 --timeout 20s
>
> lol, this is a fun patch

It's *probably* OK, for sane workloads.

But if some workload is busily running percpu_counter_sum on 1000 CPUs,
how is a writer ever to get in there to spill ->counters into ->count?

Modern rwlock_t does implement queuing, so the writer will get in
there eventually. But nothing is simple any more - there are
complications with rwlocks on PREEMPT_RT and with interrupt-time reads
(do we even do that?).

So I think indefinite writer starvation is a risk here?