Skip to content

Commit c49956b

Browse files
paulmckrcuneeraju
authored andcommitted
doc: Mention address and data dependencies in rcu_dereference.rst
This commit adds discussion of address and data dependencies to the beginning of rcu_dereference.rst in order to enable readers to more easily make the connection to the Linux-kernel memory model in general and to memory-barriers.txt in particular. Reported-by: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com> Reported-by: Akira Yokosawa <akiyks@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.iitr10@gmail.com>
1 parent 1b7178b commit c49956b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Documentation/RCU/rcu_dereference.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33
PROPER CARE AND FEEDING OF RETURN VALUES FROM rcu_dereference()
44
===============================================================
55

6-
Most of the time, you can use values from rcu_dereference() or one of
7-
the similar primitives without worries. Dereferencing (prefix "*"),
8-
field selection ("->"), assignment ("="), address-of ("&"), addition and
9-
subtraction of constants, and casts all work quite naturally and safely.
10-
11-
It is nevertheless possible to get into trouble with other operations.
12-
Follow these rules to keep your RCU code working properly:
6+
Proper care and feeding of address and data dependencies is critically
7+
important to correct use of things like RCU. To this end, the pointers
8+
returned from the rcu_dereference() family of primitives carry address and
9+
data dependencies. These dependencies extend from the rcu_dereference()
10+
macro's load of the pointer to the later use of that pointer to compute
11+
either the address of a later memory access (representing an address
12+
dependency) or the value written by a later memory access (representing
13+
a data dependency).
14+
15+
Most of the time, these dependencies are preserved, permitting you to
16+
freely use values from rcu_dereference(). For example, dereferencing
17+
(prefix "*"), field selection ("->"), assignment ("="), address-of
18+
("&"), casts, and addition or subtraction of constants all work quite
19+
naturally and safely. However, because current compilers do not take
20+
either address or data dependencies into account it is still possible
21+
to get into trouble.
22+
23+
Follow these rules to preserve the address and data dependencies emanating
24+
from your calls to rcu_dereference() and friends, thus keeping your RCU
25+
readers working properly:
1326

1427
- You must use one of the rcu_dereference() family of primitives
1528
to load an RCU-protected pointer, otherwise CONFIG_PROVE_RCU

0 commit comments

Comments
 (0)