From: Mathieu Desnoyers Date: Fri, 18 Sep 2009 13:12:35 +0000 (-0400) Subject: qsbr: Add write+read thread support to 32-bit QSBR X-Git-Tag: v0.1~70 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bc49c323c92d6809e534fd0bb78309922c1cd2bb;p=urcu.git qsbr: Add write+read thread support to 32-bit QSBR Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-qsbr.c b/urcu-qsbr.c index a86f6e9..3b9a054 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -135,12 +135,24 @@ static void switch_next_urcu_qparity(void) void synchronize_rcu(void) { + unsigned long was_online; + + was_online = rcu_reader_qs_gp; + /* All threads should read qparity before accessing data structure * where new ptr points to. */ /* Write new ptr before changing the qparity */ smp_mb(); + /* + * Mark the writer thread offline to make sure we don't wait for + * our own quiescent state. This allows using synchronize_rcu() in + * threads registered as readers. + */ + if (was_online) + STORE_SHARED(rcu_reader_qs_gp, 0); + internal_urcu_lock(); switch_next_urcu_qparity(); /* 0 -> 1 */ @@ -183,9 +195,12 @@ void synchronize_rcu(void) internal_urcu_unlock(); - /* Finish waiting for reader threads before letting the old ptr being + /* + * Finish waiting for reader threads before letting the old ptr being * freed. */ + if (was_online) + _STORE_SHARED(rcu_reader_qs_gp, LOAD_SHARED(urcu_gp_ctr)); smp_mb(); } #else /* !(BITS_PER_LONG < 64) */