Skip to contentSkip to conversation

rcu: Use WRITE_ONCE in RCU_INIT_POINTER

RFC PATCH In review Peter Zijlstra 2 participants 2 messages Jun 2, 2015 RCU

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 rcu: Use WRITE_ONCE in RCU_INIT_POINTER

For the paranoid amongst us GCC would be in its right to use byte stores to write our NULL value, tell it not to do that.

---
 include/linux/rcupdate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/rcupdate.h +1 -1
index 33a056bb886f..e173847b6543 100644
@@ -1046,7 +1046,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
 #define RCU_INIT_POINTER(p, v) \
 	do { \
 		rcu_dereference_sparse(p, __rcu); \
-		p = RCU_INITIALIZER(v); \
+		WRITE_ONCE(p, RCU_INITIALIZER(v)); \
 	} while (0)
 
 /**
#1 lore raw
Quoted 5 lines · Peter Zijlstra

For the paranoid amongst us GCC would be in its right to use byte stores to write our NULL value, tell it not to do that.

Good point, queued for 4.3.

Thanx, Paul

Quoted 18 lines
---
 include/linux/rcupdate.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/rcupdate.h +1 -1
index 33a056bb886f..e173847b6543 100644
@@ -1046,7 +1046,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
 #define RCU_INIT_POINTER(p, v) \
 	do { \
 		rcu_dereference_sparse(p, __rcu); \
-		p = RCU_INITIALIZER(v); \
+		WRITE_ONCE(p, RCU_INITIALIZER(v)); \
 	} while (0)
 
 /**