Skip to content

Commit 820f8da

Browse files
committed
doc: Add RCU guards to checklist.rst
Also note that RCU guards can be easier to use. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 46e2c5d commit 820f8da

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

Documentation/RCU/checklist.rst

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ over a rather long period of time, but improvements are always welcome!
6969
Explicit disabling of preemption (preempt_disable(), for example)
7070
can serve as rcu_read_lock_sched(), but is less readable and
7171
prevents lockdep from detecting locking issues. Acquiring a
72-
spinlock also enters an RCU read-side critical section.
72+
raw spinlock also enters an RCU read-side critical section.
73+
74+
The guard(rcu)() and scoped_guard(rcu) primitives designate
75+
the remainder of the current scope or the next statement,
76+
respectively, as the RCU read-side critical section. Use of
77+
these guards can be less error-prone than rcu_read_lock(),
78+
rcu_read_unlock(), and friends.
7379

7480
Please note that you *cannot* rely on code known to be built
7581
only in non-preemptible kernels. Such code can and will break,
@@ -405,9 +411,11 @@ over a rather long period of time, but improvements are always welcome!
405411
13. Unlike most flavors of RCU, it *is* permissible to block in an
406412
SRCU read-side critical section (demarked by srcu_read_lock()
407413
and srcu_read_unlock()), hence the "SRCU": "sleepable RCU".
408-
Please note that if you don't need to sleep in read-side critical
409-
sections, you should be using RCU rather than SRCU, because RCU
410-
is almost always faster and easier to use than is SRCU.
414+
As with RCU, guard(srcu)() and scoped_guard(srcu) forms are
415+
available, and often provide greater ease of use. Please note
416+
that if you don't need to sleep in read-side critical sections,
417+
you should be using RCU rather than SRCU, because RCU is almost
418+
always faster and easier to use than is SRCU.
411419

412420
Also unlike other forms of RCU, explicit initialization and
413421
cleanup is required either at build time via DEFINE_SRCU()
@@ -443,10 +451,13 @@ over a rather long period of time, but improvements are always welcome!
443451
real-time workloads than is synchronize_rcu_expedited().
444452

445453
It is also permissible to sleep in RCU Tasks Trace read-side
446-
critical section, which are delimited by rcu_read_lock_trace() and
447-
rcu_read_unlock_trace(). However, this is a specialized flavor
448-
of RCU, and you should not use it without first checking with
449-
its current users. In most cases, you should instead use SRCU.
454+
critical section, which are delimited by rcu_read_lock_trace()
455+
and rcu_read_unlock_trace(). However, this is a specialized
456+
flavor of RCU, and you should not use it without first checking
457+
with its current users. In most cases, you should instead
458+
use SRCU. As with RCU and SRCU, guard(rcu_tasks_trace)() and
459+
scoped_guard(rcu_tasks_trace) are available, and often provide
460+
greater ease of use.
450461

451462
Note that rcu_assign_pointer() relates to SRCU just as it does to
452463
other forms of RCU, but instead of rcu_dereference() you should

0 commit comments

Comments
 (0)