[PATCH tip/core/rcu 15/15] rcu: Add ACCESS_ONCE() for RCU_INIT_POINTER()
From: Paul E. McKenney
Date: Thu Aug 28 2014 - 14:28:29 EST
From: "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx>
It is permissible to use RCU_INIT_POINTER() instead of rcu_assign_pointer()
in a couple of cases where readers might be concurrently accessing the
pointer being assigned to: (1) When assigning NULL and (2) When assigning
a pointer that is already visible to readers. In these two cases, we
should really be using ACCESS_ONCE() to prevent compiler mischief. This
commit therefore adds the ACCESS_ONCE().
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
---
include/linux/rcupdate.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 321ed0d4e675..7ba3f2470396 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -989,7 +989,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
*/
#define RCU_INIT_POINTER(p, v) \
do { \
- p = RCU_INITIALIZER(v); \
+ ACCESS_ONCE(p) = (v); \
} while (0)
/**
--
1.8.1.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/