RCU documentation changes for v6.15
Subsystems (3)
cover RCU documentation changes for v6.15
Hi,
Please find the upcoming changes in RCU documentation for v6.15. The changes can also be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git docs.2025.02.04a
Regards,
Boqun
Paul E. McKenney (7):
doc: Add broken-timing possibility to stallwarn.rst
docs: Improve discussion of this_cpu_ptr(), add raw_cpu_ptr()
rcu: Document self-propagating callbacks
srcu: Point call_srcu() to call_rcu() for detailed memory ordering
rcu: Add CONFIG_RCU_LAZY delays to call_rcu() kernel-doc header
rcu: Clarify RCU_LAZY and RCU_LAZY_DEFAULT_OFF help text
rcu: Remove references to old grace-period-wait primitives
Documentation/RCU/rcubarrier.rst | 5 +---- Documentation/RCU/stallwarn.rst | 7 +++++++ Documentation/core-api/this_cpu_ops.rst | 22 ++++++++++++++++------ include/linux/rcupdate.h | 17 +++++++---------- kernel/rcu/Kconfig | 20 +++++++++++++------- kernel/rcu/srcutree.c | 8 ++++++-- kernel/rcu/tree.c | 15 ++++++++++++++- 7 files changed, 64 insertions(+), 30 deletions(-)
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 1/7 doc: Add broken-timing possibility to stallwarn.rst
From: "Paul E. McKenney" <[email protected]>
Currently, stallwarn.rst does not mention the fact that timer bugs can result in false-positive RCU CPU stall warnings. This commit therefore adds this to the list.
--- Documentation/RCU/stallwarn.rst | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/RCU/stallwarn.rst +7 -0
@@ -96,6 +96,13 @@ warnings: the ``rcu_.*timer wakeup didn't happen for`` console-log message, which will include additional debugging information. +- A timer issue causes time to appear to jump forward, so that RCU + believes that the RCU CPU stall-warning timeout has been exceeded + when in fact much less time has passed. This could be due to + timer hardware bugs, timer driver bugs, or even corruption of + the "jiffies" global variable. These sorts of timer hardware + and driver bugs are not uncommon when testing new hardware. + - A low-level kernel issue that either fails to invoke one of the variants of rcu_eqs_enter(true), rcu_eqs_exit(true), ct_idle_enter(), ct_idle_exit(), ct_irq_enter(), or ct_irq_exit() on the one
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 2/7 docs: Improve discussion of this_cpu_ptr(), add raw_cpu_ptr()
In reply to Boqun FengFrom: "Paul E. McKenney" <[email protected]>
Most of the this_cpu_*() operations may be used in preemptible code, but not this_cpu_ptr(), and for good reasons. Therefore, better explain the reasons and call out raw_cpu_ptr() as an alternative in certain very special cases.
--- Documentation/core-api/this_cpu_ops.rst | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
Documentation/core-api/this_cpu_ops.rst +16 -6
@@ -138,12 +138,22 @@ get_cpu/put_cpu sequence requires. No processor number is available. Instead, the offset of the local per cpu area is simply added to the per cpu offset. -Note that this operation is usually used in a code segment when -preemption has been disabled. The pointer is then used to -access local per cpu data in a critical section. When preemption -is re-enabled this pointer is usually no longer useful since it may -no longer point to per cpu data of the current processor. - +Note that this operation can only be used in code segments where +smp_processor_id() may be used, for example, where preemption has been +disabled. The pointer is then used to access local per cpu data in a +critical section. When preemption is re-enabled this pointer is usually +no longer useful since it may no longer point to per cpu data of the +current processor. + +The special cases where it makes sense to obtain a per-CPU pointer in +preemptible code are addressed by raw_cpu_ptr(), but such use cases need +to handle cases where two different CPUs are accessing the same per cpu +variable, which might well be that of a third CPU. These use cases are +typically performance optimizations. For example, SRCU implements a pair +of counters as a pair of per-CPU variables, and rcu_read_lock_nmisafe() +uses raw_cpu_ptr() to get a pointer to some CPU's counter, and uses +atomic_inc_long() to handle migration between the raw_cpu_ptr() and +the atomic_inc_long(). Per cpu variables and offsets -----------------------------
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 3/7 rcu: Document self-propagating callbacks
In reply to Boqun FengFrom: "Paul E. McKenney" <[email protected]>
This commit documents the fact that a given RCU callback function can repost itself.
--- kernel/rcu/tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +7 -1
@@ -3107,7 +3107,7 @@ module_param(enable_rcu_lazy, bool, 0444);* critical sections have completed. * * Use this API instead of call_rcu() if you don't want the callback to be -* invoked after very long periods of time, which can happen on systems without +* delayed for very long periods of time, which can happen on systems without * memory pressure and on systems which are lightly loaded or mostly idle. * This function will cause callbacks to be invoked sooner than later at the * expense of extra power. Other than that, this function is identical to, and
@@ -3138,6 +3138,12 @@ EXPORT_SYMBOL_GPL(call_rcu_hurry);* might well execute concurrently with RCU read-side critical sections * that started after call_rcu() was invoked. * +* It is perfectly legal to repost an RCU callback, potentially with +* a different callback function, from within its callback function. +* The specified function will be invoked after another full grace period +* has elapsed. This use case is similar in form to the common practice +* of reposting a timer from within its own handler. +* * RCU read-side critical sections are delimited by rcu_read_lock() * and rcu_read_unlock(), and may be nested. In addition, but only in * v5.0 and later, regions of code across which interrupts, preemption,
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 4/7 srcu: Point call_srcu() to call_rcu() for detailed memory ordering
In reply to Boqun FengFrom: "Paul E. McKenney" <[email protected]>
This commit causes the call_srcu() kernel-doc header to reference that of call_rcu() for detailed memory-ordering guarantees.
--- kernel/rcu/srcutree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/rcu/srcutree.c +6 -2
@@ -1398,8 +1398,12 @@ static void __call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp,* read-side critical sections are delimited by srcu_read_lock() and * srcu_read_unlock(), and may be nested. * -* The callback will be invoked from process context, but must nevertheless -* be fast and must not block. +* The callback will be invoked from process context, but with bh +* disabled. The callback function must therefore be fast and must +* not block. +* +* See the description of call_rcu() for more detailed information on +* memory ordering guarantees. */ void call_srcu (struct srcu_struct *ssp,struct rcu_head *rhp,rcu_callback_t func)
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 5/7 rcu: Add CONFIG_RCU_LAZY delays to call_rcu() kernel-doc header
In reply to Boqun FengFrom: "Paul E. McKenney" <[email protected]>
This commit adds a description of the energy-efficiency delays that call_rcu() can impose, along with a pointer to call_rcu_hurry() for latency-sensitive kernel code.
--- kernel/rcu/tree.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/rcu/tree.c +7 -0
@@ -3172,6 +3172,13 @@ EXPORT_SYMBOL_GPL(call_rcu_hurry);* * Implementation of these memory-ordering guarantees is described here: * Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst. +* +* Specific to call_rcu() (as opposed to the other call_rcu*() functions), +* in kernels built with CONFIG_RCU_LAZY=y, call_rcu() might delay for many +* seconds before starting the grace period needed by the corresponding +* callback. This delay can significantly improve energy-efficiency +* on low-utilization battery-powered devices. To avoid this delay, +* in latency-sensitive kernel code, use call_rcu_hurry(). */ void call_rcu (struct rcu_head *head,rcu_callback_t func) {
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 6/7 rcu: Clarify RCU_LAZY and RCU_LAZY_DEFAULT_OFF help text
In reply to Boqun FengFrom: "Paul E. McKenney" <[email protected]>
This commit wordsmiths the RCU_LAZY and RCU_LAZY_DEFAULT_OFF Kconfig options' help text.
--- kernel/rcu/Kconfig | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
kernel/rcu/Kconfig +13 -7
@@ -323,21 +323,27 @@ config RCU_LAZY depends on RCU_NOCB_CPU default n help - To save power, batch RCU callbacks and flush after delay, memory - pressure, or callback list growing too big. + To save power, batch RCU callbacks and delay starting the + corresponding grace period for multiple seconds. The grace + period will be started after this delay, in case of memory + pressure, or if the corresponding CPU's callback list grows + too large. - Requires rcu_nocbs=all to be set. + These delays happen only on rcu_nocbs CPUs, that is, CPUs + whose callbacks have been offloaded. - Use rcutree.enable_rcu_lazy=0 to turn it off at boot time. + Use the rcutree.enable_rcu_lazy=0 kernel-boot parameter to + globally disable these delays. config RCU_LAZY_DEFAULT_OFF bool "Turn RCU lazy invocation off by default" depends on RCU_LAZY default n help - Allows building the kernel with CONFIG_RCU_LAZY=y yet keep it default - off. Boot time param rcutree.enable_rcu_lazy=1 can be used to switch - it back on. + Build the kernel with CONFIG_RCU_LAZY=y, but cause the kernel + to boot with these energy-efficiency delays disabled. Use the + rcutree.enable_rcu_lazy=0 kernel-boot parameter to override + the this option at boot time, thus re-enabling these delays. config RCU_DOUBLE_CHECK_CB_TIME bool "RCU callback-batch backup time check"
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH 7/7 rcu: Remove references to old grace-period-wait primitives
In reply to Boqun FengFrom: "Paul E. McKenney" <[email protected]>
The rcu_barrier_sched(), synchronize_sched(), and synchronize_rcu_bh() RCU API members have been gone for many years. This commit therefore removes non-historical instances of them.
--- Documentation/RCU/rcubarrier.rst | 5 +---- include/linux/rcupdate.h | 17 +++++++---------- 2 files changed, 8 insertions(+), 14 deletions(-)
Documentation/RCU/rcubarrier.rst +1 -4
@@ -329,10 +329,7 @@ Answer: was first added back in 2005. This is because on_each_cpu() disables preemption, which acted as an RCU read-side critical section, thus preventing CPU 0's grace period from completing - until on_each_cpu() had dealt with all of the CPUs. However, - with the advent of preemptible RCU, rcu_barrier() no longer - waited on nonpreemptible regions of code in preemptible kernels, - that being the job of the new rcu_barrier_sched() function. + until on_each_cpu() had dealt with all of the CPUs. However, with the RCU flavor consolidation around v4.20, this possibility was once again ruled out, because the consolidated
include/linux/rcupdate.h +7 -10
@@ -806,11 +806,9 @@ do { \* sections, invocation of the corresponding RCU callback is deferred * until after the all the other CPUs exit their critical sections. * -* In v5.0 and later kernels, synchronize_rcu() and call_rcu() also -* wait for regions of code with preemption disabled, including regions of -* code with interrupts or softirqs disabled. In pre-v5.0 kernels, which -* define synchronize_sched(), only code enclosed within rcu_read_lock() -* and rcu_read_unlock() are guaranteed to be waited for. +* Both synchronize_rcu() and call_rcu() also wait for regions of code +* with preemption disabled, including regions of code with interrupts or +* softirqs disabled. * * Note, however, that RCU callbacks are permitted to run concurrently * with new RCU read-side critical sections. One way that this can happen
@@ -865,11 +863,10 @@ static __always_inline void rcu_read_lock(void)* rcu_read_unlock() - marks the end of an RCU read-side critical section. * * In almost all situations, rcu_read_unlock() is immune from deadlock. -* In recent kernels that have consolidated synchronize_sched() and -* synchronize_rcu_bh() into synchronize_rcu(), this deadlock immunity -* also extends to the scheduler's runqueue and priority-inheritance -* spinlocks, courtesy of the quiescent-state deferral that is carried -* out when rcu_read_unlock() is invoked with interrupts disabled. +* This deadlock immunity also extends to the scheduler's runqueue +* and priority-inheritance spinlocks, courtesy of the quiescent-state +* deferral that is carried out when rcu_read_unlock() is invoked with +* interrupts disabled. * * See rcu_read_lock() for more information. */
Signature · 1 line
2.39.5 (Apple Git-154)