From: paulmck@kernel.org
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
mingo@kernel.org, jiangshanlai@gmail.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH tip/core/rcu 1/4] doc: Present the role of READ_ONCE()
Date: Thu, 5 Nov 2020 15:05:07 -0800 [thread overview]
Message-ID: <20201105230510.18660-1-paulmck@kernel.org> (raw)
In-Reply-To: <20201105230444.GA18574@paulmck-ThinkPad-P72>
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit adds an explanation of the special cases where READ_ONCE()
may be used in place of a member of the rcu_dereference() family.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
Documentation/RCU/checklist.rst | 7 +++++++
Documentation/RCU/rcu_dereference.rst | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/Documentation/RCU/checklist.rst b/Documentation/RCU/checklist.rst
index 2efed99..bb7128e 100644
--- a/Documentation/RCU/checklist.rst
+++ b/Documentation/RCU/checklist.rst
@@ -314,6 +314,13 @@ over a rather long period of time, but improvements are always welcome!
shared between readers and updaters. Additional primitives
are provided for this case, as discussed in lockdep.txt.
+ One exception to this rule is when data is only ever added to
+ the linked data structure, and is never removed during any
+ time that readers might be accessing that structure. In such
+ cases, READ_ONCE() may be used in place of rcu_dereference()
+ and the read-side markers (rcu_read_lock() and rcu_read_unlock(),
+ for example) may be omitted.
+
10. Conversely, if you are in an RCU read-side critical section,
and you don't hold the appropriate update-side lock, you -must-
use the "_rcu()" variants of the list macros. Failing to do so
diff --git a/Documentation/RCU/rcu_dereference.rst b/Documentation/RCU/rcu_dereference.rst
index c9667eb..f3e587a 100644
--- a/Documentation/RCU/rcu_dereference.rst
+++ b/Documentation/RCU/rcu_dereference.rst
@@ -28,6 +28,12 @@ Follow these rules to keep your RCU code working properly:
for an example where the compiler can in fact deduce the exact
value of the pointer, and thus cause misordering.
+- In the special case where data is added but is never removed
+ while readers are accessing the structure, READ_ONCE() may be used
+ instead of rcu_dereference(). In this case, use of READ_ONCE()
+ takes on the role of the lockless_dereference() primitive that
+ was removed in v4.15.
+
- You are only permitted to use rcu_dereference on pointer values.
The compiler simply knows too much about integral values to
trust it to carry dependencies through integer operations.
--
2.9.5
next prev parent reply other threads:[~2020-11-05 23:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 23:04 [PATCH tip/core/rcu 0/4] Documentations updates for v5.11 Paul E. McKenney
2020-11-05 23:05 ` paulmck [this message]
2020-11-09 12:21 ` [PATCH tip/core/rcu 1/4] doc: Present the role of READ_ONCE() Peter Zijlstra
2020-11-09 16:20 ` Paul E. McKenney
2020-11-05 23:05 ` [PATCH tip/core/rcu 2/4] docs: Update RCU's hotplug requirements with a bit about design paulmck
2020-11-09 12:23 ` Peter Zijlstra
2020-11-09 16:24 ` Paul E. McKenney
2020-11-09 17:14 ` Peter Zijlstra
2020-11-10 20:33 ` Joel Fernandes
2020-11-11 0:20 ` Paul E. McKenney
2020-11-05 23:05 ` [PATCH tip/core/rcu 3/4] docs: RCU: Requirements.rst: Fix a list block paulmck
2020-11-05 23:05 ` [PATCH tip/core/rcu 4/4] docs/rcu: Update the call_rcu() API paulmck
2020-11-09 12:24 ` Peter Zijlstra
2020-11-10 1:20 ` Paul E. McKenney
2020-11-10 9:25 ` Peter Zijlstra
2020-11-10 14:37 ` 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=20201105230510.18660-1-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome