diff options
| author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-10-28 00:11:27 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-28 18:25:17 -0400 |
| commit | 54ef6df3f3f1353d99c80c437259d317b2cd1cbd (patch) | |
| tree | 22b1c691757577cb291430858def7d86d8449dfb /include/linux | |
| parent | 5fecf3a1e1a0af61eb34eb6976ec9f59cca65d3f (diff) | |
rcu: Provide counterpart to rcu_dereference() for non-RCU situations
Although rcu_dereference() and friends can be used in situations where
object lifetimes are being managed by something other than RCU, the
resulting sparse and lockdep-RCU noise can be annoying. This commit
therefore supplies a lockless_dereference(), which provides the
protection for dereferences without the RCU-related debugging noise.
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/rcupdate.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index a4a819ffb2d1..53ff1a752d7e 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
| @@ -617,6 +617,21 @@ static inline void rcu_preempt_sleep_check(void) | |||
| 617 | #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v) | 617 | #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v) |
| 618 | 618 | ||
| 619 | /** | 619 | /** |
| 620 | * lockless_dereference() - safely load a pointer for later dereference | ||
| 621 | * @p: The pointer to load | ||
| 622 | * | ||
| 623 | * Similar to rcu_dereference(), but for situations where the pointed-to | ||
| 624 | * object's lifetime is managed by something other than RCU. That | ||
| 625 | * "something other" might be reference counting or simple immortality. | ||
| 626 | */ | ||
| 627 | #define lockless_dereference(p) \ | ||
| 628 | ({ \ | ||
| 629 | typeof(p) _________p1 = ACCESS_ONCE(p); \ | ||
| 630 | smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ | ||
| 631 | (_________p1); \ | ||
| 632 | }) | ||
| 633 | |||
| 634 | /** | ||
| 620 | * rcu_assign_pointer() - assign to RCU-protected pointer | 635 | * rcu_assign_pointer() - assign to RCU-protected pointer |
| 621 | * @p: pointer to assign to | 636 | * @p: pointer to assign to |
| 622 | * @v: value to assign (publish) | 637 | * @v: value to assign (publish) |
