Skip to content

Commit

Permalink
rcu: Make rcu_assign_pointer() unconditionally insert a memory barrier
Browse files Browse the repository at this point in the history
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 <shemminger@vyatta.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  • Loading branch information
Eric Dumazet authored and Paul E. McKenney committed Sep 29, 2011
1 parent 7eb4f45 commit d322f45
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions include/linux/rcupdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
})

Expand Down

0 comments on commit d322f45

Please sign in to comment.