Re: [PATCH] lib/percpu_counter: allow concurrent sums with an rwlock
From: Sebastian Andrzej Siewior
Date: Mon Nov 16 2026 - 02:41:37 EST
On 2026-11-15 19:44:04 [-0800], Andrew Morton wrote:
> Modern rwlock_t does implement queuing, so the writer will get in
> there eventually.
On the queued-rwlock implementation, if a writer blocks on the lock then
the readers will wait until the writer is done unless the reader is from
interrupt.
There is also seqcount_t where the reader would be fine as long as there
has been no writer during the read and plenty of readers don't block
each other. It might take a while if the writer performs multiple
updates and the reader can't query all CPUs in time.
So it is not easy.
> But nothing is simple any more - there are
> complications with rwlocks on PREEMPT_RT and with interrupt-time reads
> (do we even do that?).
There are a few users from preempt/irq disabled section on PREEMPT_RT
which mandate something like raw_spinlock_t. The rwlock_t will break.
Sebastian