Skip to content

Commit 022d1b3

Browse files
committed
doc: Update rcu_access_pointer() advice in rcu_dereference.rst
This commit updates the rcu_access_pointer() advice, noting that its return value should not be assigned to a local variable, and also noting that there is little point in using rcu_access_pointer() within an RCU read-side critical section. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent ca8a439 commit 022d1b3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Documentation/RCU/rcu_dereference.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,16 @@ Follow these rules to keep your RCU code working properly:
128128
This sort of comparison occurs frequently when scanning
129129
RCU-protected circular linked lists.
130130

131-
Note that if checks for being within an RCU read-side
132-
critical section are not required and the pointer is never
133-
dereferenced, rcu_access_pointer() should be used in place
134-
of rcu_dereference().
131+
Note that if the pointer comparison is done outside
132+
of an RCU read-side critical section, and the pointer
133+
is never dereferenced, rcu_access_pointer() should be
134+
used in place of rcu_dereference(). In most cases,
135+
it is best to avoid accidental dereferences by testing
136+
the rcu_access_pointer() return value directly, without
137+
assigning it to a variable.
138+
139+
Within an RCU read-side critical section, there is little
140+
reason to use rcu_access_pointer().
135141

136142
- The comparison is against a pointer that references memory
137143
that was initialized "a long time ago." The reason

0 commit comments

Comments
 (0)