[PATCH rcu 0/11] Add light-weight readers for SRCU

From: Paul E. McKenney
Date: Tue Sep 03 2024 - 12:33:07 EST


Hello!

This series provides light-weight readers for SRCU. This lightness
is selected by the caller by using the new srcu_read_lock_lite() and
srcu_read_unlock_lite() flavors instead of the usual srcu_read_lock() and
srcu_read_unlock() flavors. Although this passes significant rcutorture
testing, this should still be considered to be experimental.

There are a few restrictions: (1) If srcu_read_lock_lite() is called
on a given srcu_struct structure, then no other flavor may be used on
that srcu_struct structure, before, during, or after. (2) The _lite()
readers may only be invoked from regions of code where RCU is watching
(as in those regions in which rcu_is_watching() returns true). (3)
There is no auto-expediting for srcu_struct structures that have
been passed to _lite() readers. (4) SRCU grace periods for _lite()
srcu_struct structures invoke synchronize_rcu() at least twice, thus
having longer latencies than their non-_lite() counterparts. (5) Even
with synchronize_srcu_expedited(), the resulting SRCU grace period
will invoke synchronize_rcu() at least twice, as opposed to invoking
the IPI-happy synchronize_rcu_expedited() function. (6) Just as with
srcu_read_lock() and srcu_read_unlock(), the srcu_read_lock_lite() and
srcu_read_unlock_lite() functions may not (repeat, *not*) be invoked
from NMI handlers (that is what the _nmisafe() interface are for).
Although one could imagine readers that were both _lite() and _nmisafe(),
one might also imagine that the read-modify-write atomic operations that
are needed by any NMI-safe SRCU read marker would make this unhelpful
from a performance perspective.

All that said, the patches in this series are as follows:

1. Rename srcu_might_be_idle() to srcu_should_expedite().

2. Introduce srcu_gp_is_expedited() helper function.

3. Renaming in preparation for additional reader flavor.

4. Bit manipulation changes for additional reader flavor.

5. Standardize srcu_data pointers to "sdp" and similar.

6. Convert srcu_data ->srcu_reader_flavor to bit field.

7. Add srcu_read_lock_lite() and srcu_read_unlock_lite().

8. rcutorture: Expand RCUTORTURE_RDR_MASK_[12] to eight bits.

9. rcutorture: Add reader_flavor parameter for SRCU readers.

10. rcutorture: Add srcu_read_lock_lite() support to
rcutorture.reader_flavor.

11. refscale: Add srcu_read_lock_lite() support using "srcu-lite".

Thanx, Paul

------------------------------------------------------------------------

Documentation/admin-guide/kernel-parameters.txt | 4
b/Documentation/admin-guide/kernel-parameters.txt | 8 +
b/include/linux/srcu.h | 21 +-
b/include/linux/srcutree.h | 2
b/kernel/rcu/rcutorture.c | 28 +--
b/kernel/rcu/refscale.c | 54 +++++--
b/kernel/rcu/srcutree.c | 16 +-
include/linux/srcu.h | 86 +++++++++--
include/linux/srcutree.h | 5
kernel/rcu/rcutorture.c | 37 +++-
kernel/rcu/srcutree.c | 168 +++++++++++++++-------
11 files changed, 308 insertions(+), 121 deletions(-)