From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH 2/3] doc: Add RCU guards to checklist.rst
Date: Fri, 15 Aug 2025 17:00:06 -0700 [thread overview]
Message-ID: <20250816000007.2622326-2-paulmck@kernel.org> (raw)
In-Reply-To: <9ea6b51e-b48a-474f-b7ae-4fb6414d0aaf@paulmck-laptop>
Also note that RCU guards can be easier to use.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
Documentation/RCU/checklist.rst | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/Documentation/RCU/checklist.rst b/Documentation/RCU/checklist.rst
index 7de3e308f330f6..c9bfb2b218e525 100644
--- a/Documentation/RCU/checklist.rst
+++ b/Documentation/RCU/checklist.rst
@@ -69,7 +69,13 @@ over a rather long period of time, but improvements are always welcome!
Explicit disabling of preemption (preempt_disable(), for example)
can serve as rcu_read_lock_sched(), but is less readable and
prevents lockdep from detecting locking issues. Acquiring a
- spinlock also enters an RCU read-side critical section.
+ raw spinlock also enters an RCU read-side critical section.
+
+ The guard(rcu)() and scoped_guard(rcu) primitives designate
+ the remainder of the current scope or the next statement,
+ respectively, as the RCU read-side critical section. Use of
+ these guards can be less error-prone than rcu_read_lock(),
+ rcu_read_unlock(), and friends.
Please note that you *cannot* rely on code known to be built
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!
13. Unlike most flavors of RCU, it *is* permissible to block in an
SRCU read-side critical section (demarked by srcu_read_lock()
and srcu_read_unlock()), hence the "SRCU": "sleepable RCU".
- Please note that if you don't need to sleep in read-side critical
- sections, you should be using RCU rather than SRCU, because RCU
- is almost always faster and easier to use than is SRCU.
+ As with RCU, guard(srcu)() and scoped_guard(srcu) forms are
+ available, and often provide greater ease of use. Please note
+ that if you don't need to sleep in read-side critical sections,
+ you should be using RCU rather than SRCU, because RCU is almost
+ always faster and easier to use than is SRCU.
Also unlike other forms of RCU, explicit initialization and
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!
real-time workloads than is synchronize_rcu_expedited().
It is also permissible to sleep in RCU Tasks Trace read-side
- critical section, which are delimited by rcu_read_lock_trace() and
- rcu_read_unlock_trace(). However, this is a specialized flavor
- of RCU, and you should not use it without first checking with
- its current users. In most cases, you should instead use SRCU.
+ critical section, which are delimited by rcu_read_lock_trace()
+ and rcu_read_unlock_trace(). However, this is a specialized
+ flavor of RCU, and you should not use it without first checking
+ with its current users. In most cases, you should instead
+ use SRCU. As with RCU and SRCU, guard(rcu_tasks_trace)() and
+ scoped_guard(rcu_tasks_trace) are available, and often provide
+ greater ease of use.
Note that rcu_assign_pointer() relates to SRCU just as it does to
other forms of RCU, but instead of rcu_dereference() you should
--
2.40.1
next prev parent reply other threads:[~2025-08-16 0:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 23:59 [PATCH 0/3] rcu: Documentation updates for v6.18 Paul E. McKenney
2025-08-16 0:00 ` [PATCH 1/3] doc: Update whatisRCU.rst for recent RCU API additions Paul E. McKenney
2025-08-16 3:54 ` Bagas Sanjaya
2025-08-16 4:54 ` Paul E. McKenney
2025-08-16 5:38 ` Bagas Sanjaya
2025-08-16 11:28 ` Paul E. McKenney
2025-08-16 0:00 ` Paul E. McKenney [this message]
2025-08-16 0:00 ` [PATCH 3/3] rcu: docs: Requirements.rst: Abide by conventions of kernel documentation Paul E. McKenney
2025-08-16 1:30 ` Akira Yokosawa
2025-08-16 2:02 ` Paul E. McKenney
2025-09-18 10:14 ` [PATCH 0/3] rcu: Documentation updates for v6.18 Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 1/8] doc: Update whatisRCU.rst for recent RCU API additions Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 2/8] doc: Add RCU guards to checklist.rst Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 3/8] rcu: docs: Requirements.rst: Abide by conventions of kernel documentation Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 4/8] Documentation: RCU: Wrap kvm-remote.sh rerun snippet in literal code block Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 5/8] Documentation: RCU: Reduce toctree depth Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 6/8] Documentation: RCU: Retitle toctree index Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 7/8] doc: Fix typo in RCU's torture.rst documentation Paul E. McKenney
2025-09-18 10:14 ` [PATCH v2 8/8] docs: rcu: Replace multiple dead OLS links in RTFP.txt Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250816000007.2622326-2-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox