From: Mathieu Desnoyers Date: Sun, 20 Sep 2009 16:03:37 +0000 (-0400) Subject: urcu-defer: remove unnecessary memory barrier X-Git-Tag: v0.1~60 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9374f873bd741e91b0b5c78a8e0406d849ca752e;p=userspace-rcu.git urcu-defer: remove unnecessary memory barrier All synchronization between queue producer/consumer is performed by the write to "head". Before this write, none of the queued data is visible from the consumer point of view. Therefore, just a single wmb() is required before writing to head to ensure correct synchronization. This matches with the rmb() after reading head on the consumer side. Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-defer-static.h b/urcu-defer-static.h index 4cfa837..a00ced0 100644 --- a/urcu-defer-static.h +++ b/urcu-defer-static.h @@ -150,7 +150,6 @@ static inline void _rcu_defer_queue(void (*fct)(void *p), void *p) assert(head - LOAD_SHARED(defer_queue.tail) == 0); } - smp_wmb(); /* Publish new pointer before write q[] */ if (unlikely(defer_queue.last_fct_in != fct)) { defer_queue.last_fct_in = fct; if (unlikely(DQ_IS_FCT_BIT(fct) || fct == DQ_FCT_MARK)) { @@ -181,7 +180,8 @@ static inline void _rcu_defer_queue(void (*fct)(void *p), void *p) } } _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK], p); - smp_wmb(); /* Write q[] before head. */ + smp_wmb(); /* Publish new pointer before head */ + /* Write q[] before head. */ STORE_SHARED(defer_queue.head, head); }