X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=urcu-qsbr.c;h=25074d09063a60ae5c94a17b18cd9d241b1e2fb9;hb=7a5a38f52b8814d0188b74a91cb635bc205df96c;hp=155505abc7843385fafef29de57509ceb096519c;hpb=2dfb8b5e30bc2d268bcbc57eceb9c54d21b36d90;p=urcu.git diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 155505a..25074d0 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -113,13 +113,20 @@ static void update_counter_and_wait(void) struct rcu_reader *index, *tmp; #if (BITS_PER_LONG < 64) - /* Switch parity: 1 -> 0, 0 -> 1 */ + /* Switch parity: 0 -> 1, 1 -> 0 */ STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr ^ RCU_GP_CTR); #else /* !(BITS_PER_LONG < 64) */ /* Increment current G.P. */ 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. */