|
3 | 3 | PROPER CARE AND FEEDING OF RETURN VALUES FROM rcu_dereference()
|
4 | 4 | ===============================================================
|
5 | 5 |
|
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: |
13 | 26 |
|
14 | 27 | - You must use one of the rcu_dereference() family of primitives
|
15 | 28 | to load an RCU-protected pointer, otherwise CONFIG_PROVE_RCU
|
|
0 commit comments