From: Mathieu Desnoyers Date: Sun, 14 Mar 2010 14:27:23 +0000 (-0400) Subject: urcu-qsbr: document compiler barrier X-Git-Tag: v0.4.4~8 X-Git-Url: https://git.lttng.org/?p=urcu.git;a=commitdiff_plain;h=7a5a38f52b8814d0188b74a91cb635bc205df96c urcu-qsbr: document compiler barrier This compiler barrier is, at the implementation level, already provided by the volatile accesses for STORE/LOAD_SHARED. However, given that these primitives does not provide this guarantee at the high-level (and might use lighter gcc primitives eventually), we need to add an explicit barrier(). Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 84789f2..25074d0 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -120,6 +120,13 @@ static void update_counter_and_wait(void) STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr + RCU_GP_CTR); #endif /* !(BITS_PER_LONG < 64) */ + /* + * Enforce compiler-order of store to rcu_gp_ctr before before + * load rcu_reader ctr. + * This ensures synchronize_rcu() cannot be starved by readers. + */ + barrier(); + /* * Wait for each thread rcu_reader_qs_gp count to become 0. */