diff options
author | Paul E. McKenney <paulmck@kernel.org> | 2022-08-04 21:23:19 +0300 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2022-08-31 14:58:15 +0300 |
commit | 022d1b356c8a687a58a74cbc90a92d56d3aa207d (patch) | |
tree | 5a11f53b1ab5532cf6218bbc48d601737df1f0be /Documentation/RCU/rcu_dereference.rst | |
parent | ca8a439e4611765b0e4bf5d4fd3fab54bab5ffe2 (diff) | |
download | linux-022d1b356c8a687a58a74cbc90a92d56d3aa207d.tar.xz |
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 <paulmck@kernel.org>
Diffstat (limited to 'Documentation/RCU/rcu_dereference.rst')
-rw-r--r-- | Documentation/RCU/rcu_dereference.rst | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Documentation/RCU/rcu_dereference.rst b/Documentation/RCU/rcu_dereference.rst index 0b418a5b243c..81e828c8313b 100644 --- a/Documentation/RCU/rcu_dereference.rst +++ b/Documentation/RCU/rcu_dereference.rst @@ -128,10 +128,16 @@ Follow these rules to keep your RCU code working properly: This sort of comparison occurs frequently when scanning RCU-protected circular linked lists. - Note that if checks for being within an RCU read-side - critical section are not required and the pointer is never - dereferenced, rcu_access_pointer() should be used in place - of rcu_dereference(). + Note that if the pointer comparison is done outside + of an RCU read-side critical section, and the pointer + is never dereferenced, rcu_access_pointer() should be + used in place of rcu_dereference(). In most cases, + it is best to avoid accidental dereferences by testing + the rcu_access_pointer() return value directly, without + assigning it to a variable. + + Within an RCU read-side critical section, there is little + reason to use rcu_access_pointer(). - The comparison is against a pointer that references memory that was initialized "a long time ago." The reason |