From b3c4dd1a5c12b59efdee51be209767a9f406a715 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 26 Sep 2009 15:10:04 -0400 Subject: [PATCH] urcu-qsbr: repeat sched_yield() loop, yield at offline rather than online. Signed-off-by: Mathieu Desnoyers --- urcu-qsbr-static.h | 13 +++++-------- urcu-qsbr.c | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/urcu-qsbr-static.h b/urcu-qsbr-static.h index 1cb4246..9cc5db4 100644 --- a/urcu-qsbr-static.h +++ b/urcu-qsbr-static.h @@ -239,18 +239,15 @@ static inline void _rcu_thread_offline(void) { smp_mb(); STORE_SHARED(urcu_reader_status.qs_gp, 0); + if (unlikely(LOAD_SHARED(urcu_gp_ctr) & RCU_GP_ONGOING) && + unlikely(urcu_reader_status.gp_waiting)) { + sched_yield(); + } } static inline void _rcu_thread_online(void) { - long gp_ctr; - - if (unlikely((gp_ctr = LOAD_SHARED(urcu_gp_ctr)) & RCU_GP_ONGOING) && - unlikely(urcu_reader_status.gp_waiting)) { - sched_yield(); - gp_ctr = LOAD_SHARED(urcu_gp_ctr); - } - _STORE_SHARED(urcu_reader_status.qs_gp, gp_ctr); + _STORE_SHARED(urcu_reader_status.qs_gp, LOAD_SHARED(urcu_gp_ctr)); smp_mb(); } diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 8828ae8..c275b66 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -118,6 +118,7 @@ static void wait_for_quiescent_state(void) while (rcu_gp_ongoing(&index->urcu_reader_status->qs_gp)) { if (wait_loops++ == RCU_QS_ACTIVE_ATTEMPTS) { sched_yield(); /* ideally sched_yield_to() */ + wait_loops = 0; } else { #ifndef HAS_INCOHERENT_CACHES cpu_relax(); -- 2.34.1