diff options
| author | Patrick McHardy <kaber@trash.net> | 2010-05-10 12:39:28 -0400 |
|---|---|---|
| committer | Patrick McHardy <kaber@trash.net> | 2010-05-10 12:39:28 -0400 |
| commit | 1e4b1057121bc756b91758a434b504d2010f6088 (patch) | |
| tree | b016cf2c728289c7e36d9e4e488f30ab0bd0ae6e /include/linux/rcupdate.h | |
| parent | 3b254c54ec46eb022cb26ee6ab37fae23f5f7d6a (diff) | |
| parent | 3ee943728fff536edaf8f59faa58aaa1aa7366e3 (diff) | |
Merge branch 'master' of /repos/git/net-next-2.6
Conflicts:
net/bridge/br_device.c
net/bridge/br_forward.c
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/linux/rcupdate.h')
| -rw-r--r-- | include/linux/rcupdate.h | 65 |
1 files changed, 56 insertions, 9 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 872a98e13d6a..07db2feb8572 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
| @@ -101,10 +101,7 @@ extern struct lockdep_map rcu_sched_lock_map; | |||
| 101 | # define rcu_read_release_sched() \ | 101 | # define rcu_read_release_sched() \ |
| 102 | lock_release(&rcu_sched_lock_map, 1, _THIS_IP_) | 102 | lock_release(&rcu_sched_lock_map, 1, _THIS_IP_) |
| 103 | 103 | ||
| 104 | static inline int debug_lockdep_rcu_enabled(void) | 104 | extern int debug_lockdep_rcu_enabled(void); |
| 105 | { | ||
| 106 | return likely(rcu_scheduler_active && debug_locks); | ||
| 107 | } | ||
| 108 | 105 | ||
| 109 | /** | 106 | /** |
| 110 | * rcu_read_lock_held - might we be in RCU read-side critical section? | 107 | * rcu_read_lock_held - might we be in RCU read-side critical section? |
| @@ -195,12 +192,30 @@ static inline int rcu_read_lock_sched_held(void) | |||
| 195 | 192 | ||
| 196 | /** | 193 | /** |
| 197 | * rcu_dereference_check - rcu_dereference with debug checking | 194 | * rcu_dereference_check - rcu_dereference with debug checking |
| 195 | * @p: The pointer to read, prior to dereferencing | ||
| 196 | * @c: The conditions under which the dereference will take place | ||
| 197 | * | ||
| 198 | * Do an rcu_dereference(), but check that the conditions under which the | ||
| 199 | * dereference will take place are correct. Typically the conditions indicate | ||
| 200 | * the various locking conditions that should be held at that point. The check | ||
| 201 | * should return true if the conditions are satisfied. | ||
| 202 | * | ||
| 203 | * For example: | ||
| 204 | * | ||
| 205 | * bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || | ||
| 206 | * lockdep_is_held(&foo->lock)); | ||
| 198 | * | 207 | * |
| 199 | * Do an rcu_dereference(), but check that the context is correct. | 208 | * could be used to indicate to lockdep that foo->bar may only be dereferenced |
| 200 | * For example, rcu_dereference_check(gp, rcu_read_lock_held()) to | 209 | * if either the RCU read lock is held, or that the lock required to replace |
| 201 | * ensure that the rcu_dereference_check() executes within an RCU | 210 | * the bar struct at foo->bar is held. |
| 202 | * read-side critical section. It is also possible to check for | 211 | * |
| 203 | * locks being held, for example, by using lockdep_is_held(). | 212 | * Note that the list of conditions may also include indications of when a lock |
| 213 | * need not be held, for example during initialisation or destruction of the | ||
| 214 | * target struct: | ||
| 215 | * | ||
| 216 | * bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || | ||
| 217 | * lockdep_is_held(&foo->lock) || | ||
| 218 | * atomic_read(&foo->usage) == 0); | ||
| 204 | */ | 219 | */ |
| 205 | #define rcu_dereference_check(p, c) \ | 220 | #define rcu_dereference_check(p, c) \ |
| 206 | ({ \ | 221 | ({ \ |
| @@ -209,13 +224,45 @@ static inline int rcu_read_lock_sched_held(void) | |||
| 209 | rcu_dereference_raw(p); \ | 224 | rcu_dereference_raw(p); \ |
| 210 | }) | 225 | }) |
| 211 | 226 | ||
| 227 | /** | ||
| 228 | * rcu_dereference_protected - fetch RCU pointer when updates prevented | ||
| 229 | * | ||
| 230 | * Return the value of the specified RCU-protected pointer, but omit | ||
| 231 | * both the smp_read_barrier_depends() and the ACCESS_ONCE(). This | ||
| 232 | * is useful in cases where update-side locks prevent the value of the | ||
| 233 | * pointer from changing. Please note that this primitive does -not- | ||
| 234 | * prevent the compiler from repeating this reference or combining it | ||
| 235 | * with other references, so it should not be used without protection | ||
| 236 | * of appropriate locks. | ||
| 237 | */ | ||
| 238 | #define rcu_dereference_protected(p, c) \ | ||
| 239 | ({ \ | ||
| 240 | if (debug_lockdep_rcu_enabled() && !(c)) \ | ||
| 241 | lockdep_rcu_dereference(__FILE__, __LINE__); \ | ||
| 242 | (p); \ | ||
| 243 | }) | ||
| 244 | |||
| 212 | #else /* #ifdef CONFIG_PROVE_RCU */ | 245 | #else /* #ifdef CONFIG_PROVE_RCU */ |
| 213 | 246 | ||
| 214 | #define rcu_dereference_check(p, c) rcu_dereference_raw(p) | 247 | #define rcu_dereference_check(p, c) rcu_dereference_raw(p) |
| 248 | #define rcu_dereference_protected(p, c) (p) | ||
| 215 | 249 | ||
| 216 | #endif /* #else #ifdef CONFIG_PROVE_RCU */ | 250 | #endif /* #else #ifdef CONFIG_PROVE_RCU */ |
| 217 | 251 | ||
| 218 | /** | 252 | /** |
| 253 | * rcu_access_pointer - fetch RCU pointer with no dereferencing | ||
| 254 | * | ||
| 255 | * Return the value of the specified RCU-protected pointer, but omit the | ||
| 256 | * smp_read_barrier_depends() and keep the ACCESS_ONCE(). This is useful | ||
| 257 | * when the value of this pointer is accessed, but the pointer is not | ||
| 258 | * dereferenced, for example, when testing an RCU-protected pointer against | ||
| 259 | * NULL. This may also be used in cases where update-side locks prevent | ||
| 260 | * the value of the pointer from changing, but rcu_dereference_protected() | ||
| 261 | * is a lighter-weight primitive for this use case. | ||
| 262 | */ | ||
| 263 | #define rcu_access_pointer(p) ACCESS_ONCE(p) | ||
| 264 | |||
| 265 | /** | ||
| 219 | * rcu_read_lock - mark the beginning of an RCU read-side critical section. | 266 | * rcu_read_lock - mark the beginning of an RCU read-side critical section. |
| 220 | * | 267 | * |
| 221 | * When synchronize_rcu() is invoked on one CPU while other CPUs | 268 | * When synchronize_rcu() is invoked on one CPU while other CPUs |
