summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2016-05-01 18:46:54 -0700
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2016-06-15 15:31:28 -0700
commit3a37f7275cda5ad25c1fe9be8f20c76c60d175fa (patch)
tree89e64cf1b726c48daf24663dd15be033589c7dba /include
parent810ce8b5df1c8338065f2ae1d2ec08cc566fbb8b (diff)
downloadlinux-3a37f7275cda5ad25c1fe9be8f20c76c60d175fa.tar.gz
linux-3a37f7275cda5ad25c1fe9be8f20c76c60d175fa.tar.bz2
linux-3a37f7275cda5ad25c1fe9be8f20c76c60d175fa.zip
rcu: No ordering for rcu_assign_pointer() of NULL
This commit does a compile-time check for rcu_assign_pointer() of NULL, and uses WRITE_ONCE() rather than smp_store_release() in that case. Reported-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/rcupdate.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index c61b6b9506e7..a8af79738a0e 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -650,7 +650,16 @@ static inline void rcu_preempt_sleep_check(void)
* please be careful when making changes to rcu_assign_pointer() and the
* other macros that it invokes.
*/
-#define rcu_assign_pointer(p, v) smp_store_release(&p, RCU_INITIALIZER(v))
+#define rcu_assign_pointer(p, v) \
+({ \
+ uintptr_t _r_a_p__v = (uintptr_t)(v); \
+ \
+ if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
+ WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
+ else \
+ smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
+ _r_a_p__v; \
+})
/**
* rcu_access_pointer() - fetch RCU pointer with no dereferencing