From: Pierre Habouzit Date: Thu, 17 Sep 2009 12:30:19 +0000 (-0400) Subject: qsbr: save two full smp_mb() when the writer is also a reader. X-Git-Tag: v0.1~80 X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=8f50d1ce191ad5f85384c0afbf1ac5b7516ea79f qsbr: save two full smp_mb() when the writer is also a reader. Now that you've put the barriers before taking lock, and after releasing it, one can expand the _rcu_thread_{on,off}line call, and optimize two barrier calls away. (this is patch 1/2). Signed-off-by: Pierre Habouzit Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 4da10d6..3f21be3 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -148,18 +148,18 @@ void synchronize_rcu(void) * our own quiescent state. This allows using synchronize_rcu() in * threads registered as readers. */ + smp_mb(); if (was_online) - _rcu_thread_offline(); + STORE_SHARED(rcu_reader_qs_gp, 0); - smp_mb(); internal_urcu_lock(); STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr + 2); wait_for_quiescent_state(); internal_urcu_unlock(); - smp_mb(); if (was_online) - _rcu_thread_online(); + _STORE_SHARED(rcu_reader_qs_gp, LOAD_SHARED(urcu_gp_ctr) + 1); + smp_mb(); } /*