diff options
| author | Joel Fernandes (Google) <joel@joelfernandes.org> | 2018-10-08 21:33:41 -0400 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@linux.ibm.com> | 2018-11-12 11:56:25 -0500 |
| commit | 93eb14201fc690687c2d94865bc38c1aa23356b8 (patch) | |
| tree | c724b95dbf03d099e65a96de629b7ea965e779db | |
| parent | 1c7d6d4411a1ce7530cbdc4605261c560e07d51a (diff) | |
doc: Make reader aware of rcu_dereference_protected
The whatisRCU.txt document says rcu_dereference() cannot be used
outside of rcu_read_lock() protected sections. The commit adds a
mention of rcu_dereference_protected(), so that the new reader knows
that this API can be used to avoid update-side use of rcu_read_lock()
and rcu_read_unlock().
Cc: tytso@mit.edu
Suggested-by: tytso@mit.edu
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
[ paulmck: Update wording, including further feedback from Joel. ]
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
| -rw-r--r-- | Documentation/RCU/whatisRCU.txt | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt index 7c33445fd0e5..4a6854318b17 100644 --- a/Documentation/RCU/whatisRCU.txt +++ b/Documentation/RCU/whatisRCU.txt | |||
| @@ -266,7 +266,7 @@ rcu_dereference() | |||
| 266 | unnecessary overhead on Alpha CPUs. | 266 | unnecessary overhead on Alpha CPUs. |
| 267 | 267 | ||
| 268 | Note that the value returned by rcu_dereference() is valid | 268 | Note that the value returned by rcu_dereference() is valid |
| 269 | only within the enclosing RCU read-side critical section. | 269 | only within the enclosing RCU read-side critical section [1]. |
| 270 | For example, the following is -not- legal: | 270 | For example, the following is -not- legal: |
| 271 | 271 | ||
| 272 | rcu_read_lock(); | 272 | rcu_read_lock(); |
| @@ -292,6 +292,19 @@ rcu_dereference() | |||
| 292 | typically used indirectly, via the _rcu list-manipulation | 292 | typically used indirectly, via the _rcu list-manipulation |
| 293 | primitives, such as list_for_each_entry_rcu(). | 293 | primitives, such as list_for_each_entry_rcu(). |
| 294 | 294 | ||
| 295 | [1] The variant rcu_dereference_protected() can be used outside | ||
| 296 | of an RCU read-side critical section as long as the usage is | ||
| 297 | protected by locks acquired by the update-side code. This variant | ||
| 298 | avoids the lockdep warning that would happen when using (for | ||
| 299 | example) rcu_dereference() without rcu_read_lock() protection. | ||
| 300 | Using rcu_dereference_protected() also has the advantage | ||
| 301 | of permitting compiler optimizations that rcu_dereference() | ||
| 302 | must prohibit. The rcu_dereference_protected() variant takes | ||
| 303 | a lockdep expression to indicate which locks must be acquired | ||
| 304 | by the caller. If the indicated protection is not provided, | ||
| 305 | a lockdep splat is emitted. See RCU/Design/Requirements.html | ||
| 306 | and the API's code comments for more details and example usage. | ||
| 307 | |||
| 295 | The following diagram shows how each API communicates among the | 308 | The following diagram shows how each API communicates among the |
| 296 | reader, updater, and reclaimer. | 309 | reader, updater, and reclaimer. |
| 297 | 310 | ||
