From: Eric Dumazet Date: Mon, 1 Aug 2011 05:09:25 +0000 (-0700) Subject: rcu: Make rcu_assign_pointer() unconditionally insert a memory barrier X-Git-Tag: firefly_0821_release~3680^2~4309^2^2~14 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d322f45ceed525daa9401154590bbae3222cfefb;p=firefly-linux-kernel-4.4.55.git rcu: Make rcu_assign_pointer() unconditionally insert a memory barrier Recent changes to gcc give warning messages on rcu_assign_pointers()'s checks that allow it to determine when it is OK to omit the memory barrier. Stephen Hemminger tried a number of gcc tricks to silence this warning, but #pragmas and CPP macros do not work together in the way that would be required to make this work. However, we now have RCU_INIT_POINTER(), which already omits this memory barrier, and which therefore may be used when assigning NULL to an RCU-protected pointer that is accessible to readers. This commit therefore makes rcu_assign_pointer() unconditionally emit the memory barrier. Reported-by: Stephen Hemminger Signed-off-by: Eric Dumazet Acked-by: David S. Miller Signed-off-by: Paul E. McKenney --- diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index caf22e84a743..d7accc5f8892 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -443,9 +443,7 @@ extern int rcu_my_thread_group_empty(void); }) #define __rcu_assign_pointer(p, v, space) \ ({ \ - if (!__builtin_constant_p(v) || \ - ((v) != NULL)) \ - smp_wmb(); \ + smp_wmb(); \ (p) = (typeof(*v) __force space *)(v); \ })