X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Furcu-qsbr.c;h=8e5b3cd95a8b97c20a7f3539e063d663adb0ebc5;hb=refs%2Fheads%2Fstable-0.13;hp=6ff933af4c6e1ef482c9b73b5acd133f23f41e84;hpb=ce28e67a534dcf0b68ccad2218e5a2e552e6e469;p=userspace-rcu.git diff --git a/src/urcu-qsbr.c b/src/urcu-qsbr.c index 6ff933a..8e5b3cd 100644 --- a/src/urcu-qsbr.c +++ b/src/urcu-qsbr.c @@ -23,6 +23,7 @@ * IBM's contributions to this file may be relicensed under LGPLv2 or later. */ +#define URCU_NO_COMPAT_IDENTIFIERS #define _LGPL_SOURCE #include #include @@ -52,6 +53,7 @@ #define _LGPL_SOURCE void __attribute__((destructor)) urcu_qsbr_exit(void); +static void urcu_call_rcu_exit(void); /* * rcu_gp_lock ensures mutual exclusion between threads calling @@ -69,7 +71,6 @@ static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; */ static pthread_mutex_t rcu_registry_lock = PTHREAD_MUTEX_INITIALIZER; struct urcu_gp urcu_qsbr_gp = { .ctr = URCU_QSBR_GP_ONLINE }; -URCU_ATTR_ALIAS("urcu_qsbr_gp") extern struct urcu_gp rcu_gp_qsbr; /* * Active attempts to check for reader Q.S. before calling futex(). @@ -81,8 +82,6 @@ URCU_ATTR_ALIAS("urcu_qsbr_gp") extern struct urcu_gp rcu_gp_qsbr; * writers. */ DEFINE_URCU_TLS(struct urcu_qsbr_reader, urcu_qsbr_reader); -URCU_ATTR_ALIAS("urcu_qsbr_reader") -extern struct urcu_qsbr_reader rcu_reader_qsbr; static CDS_LIST_HEAD(registry); @@ -125,17 +124,25 @@ static void wait_gp(void) { /* Read reader_gp before read futex */ cmm_smp_rmb(); - if (uatomic_read(&urcu_qsbr_gp.futex) != -1) - return; - while (futex_noasync(&urcu_qsbr_gp.futex, FUTEX_WAIT, -1, - NULL, NULL, 0)) { + while (uatomic_read(&urcu_qsbr_gp.futex) == -1) { + if (!futex_noasync(&urcu_qsbr_gp.futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } switch (errno) { - case EWOULDBLOCK: + case EAGAIN: /* Value already changed. */ return; case EINTR: /* Retry if interrupted by signal. */ - break; /* Get out of switch. */ + break; /* Get out of switch. Check again. */ default: /* Unexpected error. */ urcu_die(errno); @@ -431,8 +438,6 @@ gp_end: cmm_smp_mb(); } #endif /* !(CAA_BITS_PER_LONG < 64) */ -URCU_ATTR_ALIAS("urcu_qsbr_synchronize_rcu") -void synchronize_rcu_qsbr(); /* * library wrappers to be used by non-LGPL compatible source code. @@ -442,41 +447,34 @@ void urcu_qsbr_read_lock(void) { _urcu_qsbr_read_lock(); } -URCU_ATTR_ALIAS("urcu_qsbr_read_lock") void rcu_read_lock_qsbr(); void urcu_qsbr_read_unlock(void) { _urcu_qsbr_read_unlock(); } -URCU_ATTR_ALIAS("urcu_qsbr_read_unlock") void rcu_read_unlock_qsbr(); int urcu_qsbr_read_ongoing(void) { return _urcu_qsbr_read_ongoing(); } -URCU_ATTR_ALIAS("urcu_qsbr_read_ongoing") void rcu_read_ongoing_qsbr(); void urcu_qsbr_quiescent_state(void) { _urcu_qsbr_quiescent_state(); } -URCU_ATTR_ALIAS("urcu_qsbr_quiescent_state") void rcu_quiescent_state_qsbr(); void urcu_qsbr_thread_offline(void) { _urcu_qsbr_thread_offline(); } -URCU_ATTR_ALIAS("urcu_qsbr_thread_offline") void rcu_thread_offline_qsbr(); void urcu_qsbr_thread_online(void) { _urcu_qsbr_thread_online(); } -URCU_ATTR_ALIAS("urcu_qsbr_thread_online") -void rcu_thread_online_qsbr(); void urcu_qsbr_register_thread(void) { @@ -490,8 +488,6 @@ void urcu_qsbr_register_thread(void) mutex_unlock(&rcu_registry_lock); _urcu_qsbr_thread_online(); } -URCU_ATTR_ALIAS("urcu_qsbr_register_thread") -void rcu_register_thread_qsbr(); void urcu_qsbr_unregister_thread(void) { @@ -506,8 +502,6 @@ void urcu_qsbr_unregister_thread(void) cds_list_del(&URCU_TLS(urcu_qsbr_reader).node); mutex_unlock(&rcu_registry_lock); } -URCU_ATTR_ALIAS("urcu_qsbr_unregister_thread") -void rcu_unregister_thread_qsbr(); void urcu_qsbr_exit(void) { @@ -516,11 +510,10 @@ void urcu_qsbr_exit(void) * readers, and left running at exit. * assert(cds_list_empty(®istry)); */ + urcu_call_rcu_exit(); } -URCU_ATTR_ALIAS("urcu_qsbr_exit") void rcu_exit_qsbr(); DEFINE_RCU_FLAVOR(rcu_flavor); -DEFINE_RCU_FLAVOR_ALIAS(rcu_flavor, alias_rcu_flavor); #include "urcu-call-rcu-impl.h" #include "urcu-defer-impl.h"