rcu: Make rcu_assign_pointer's assignment volatile and type-safe
authorJosh Triplett <josh@joshtriplett.org>
Sun, 1 Sep 2013 23:42:52 +0000 (16:42 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 12 Dec 2013 20:19:22 +0000 (12:19 -0800)
The rcu_assign_pointer() primitive needs to use ACCESS_ONCE to make
the assignment to the destination pointer volatile, to protect against
compilers too clever for their own good.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
include/linux/rcupdate.h

index 00ad28168ef09fcd6874964f9eeaaf5d31f157e2..97853cd2d7b44e14a731fdc57e6cea9cc3c993cb 100644 (file)
@@ -551,7 +551,7 @@ static inline void rcu_preempt_sleep_check(void)
 #define __rcu_assign_pointer(p, v, space) \
        do { \
                smp_wmb(); \
-               (p) = (typeof(*v) __force space *)(v); \
+               ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \
        } while (0)