X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=urcu-bp.c;h=280dd0dac4c5e00b9775e73f7b86f3a5507e5ca5;hb=20da51e457e3e6a70141ccb40c911d44815f7f63;hp=59cc4bc8c76b7833d3e7573b4bb7f53802a28f8f;hpb=48bf2f76e0f1fe9a778359a8291134f80ce3e79a;p=urcu.git diff --git a/urcu-bp.c b/urcu-bp.c index 59cc4bc..280dd0d 100644 --- a/urcu-bp.c +++ b/urcu-bp.c @@ -79,8 +79,8 @@ void *mremap_wrapper(void *old_address, size_t old_size, } #endif -/* Sleep delay in us */ -#define RCU_SLEEP_DELAY 1000 +/* Sleep delay in ms */ +#define RCU_SLEEP_DELAY_MS 10 #define INIT_NR_THREADS 8 #define ARENA_INIT_ALLOC \ sizeof(struct registry_chunk) \ @@ -97,7 +97,7 @@ int rcu_bp_refcount; static void __attribute__((constructor)) rcu_bp_init(void); static -void __attribute__((destructor)) rcu_bp_exit(void); +void __attribute__((destructor)) _rcu_bp_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; @@ -174,7 +174,7 @@ static void mutex_unlock(pthread_mutex_t *mutex) void update_counter_and_wait(void) { CDS_LIST_HEAD(qsreaders); - int wait_loops = 0; + unsigned int wait_loops = 0; struct rcu_reader *index, *tmp; /* Switch parity: 0 -> 1, 1 -> 0 */ @@ -198,7 +198,9 @@ void update_counter_and_wait(void) * Wait for each thread rcu_reader.ctr count to become 0. */ for (;;) { - wait_loops++; + if (wait_loops < RCU_QS_ACTIVE_ATTEMPTS) + wait_loops++; + cds_list_for_each_entry_safe(index, tmp, ®istry, node) { if (!rcu_old_gp_ongoing(&index->ctr)) cds_list_move(&index->node, &qsreaders); @@ -207,8 +209,8 @@ void update_counter_and_wait(void) if (cds_list_empty(®istry)) { break; } else { - if (wait_loops == RCU_QS_ACTIVE_ATTEMPTS) - usleep(RCU_SLEEP_DELAY); + if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) + (void) poll(NULL, 0, RCU_SLEEP_DELAY_MS); else caa_cpu_relax(); } @@ -492,7 +494,7 @@ void rcu_bp_unregister(struct rcu_reader *rcu_reader_reg) ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); if (ret) abort(); - rcu_bp_exit(); + _rcu_bp_exit(); } /* @@ -522,7 +524,7 @@ void rcu_bp_init(void) } static -void rcu_bp_exit(void) +void _rcu_bp_exit(void) { mutex_lock(&init_lock); if (!--rcu_bp_refcount) { @@ -541,6 +543,15 @@ void rcu_bp_exit(void) mutex_unlock(&init_lock); } +/* + * Keep ABI compability within stable versions. This has never been + * exposed through a header, but needs to stay in the .so until the + * soname is bumped. + */ +void rcu_bp_exit(void) +{ +} + /* * Holding the rcu_gp_lock across fork will make sure we fork() don't race with * a concurrent thread executing with this same lock held. This ensures that the