X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Furcu-defer-impl.h;h=f1fae9c0d15ce4364a44d511f2a4701febe0c4b5;hb=b47d409e2d55c101f396b47cfe4f2c909665ed2f;hp=58ca1ab2627e91ac62f452fcee9ec03196659717;hpb=4477a87021ffbfbfdb2a2084d05a084171343d36;p=urcu.git diff --git a/src/urcu-defer-impl.h b/src/urcu-defer-impl.h index 58ca1ab..f1fae9c 100644 --- a/src/urcu-defer-impl.h +++ b/src/urcu-defer-impl.h @@ -194,17 +194,25 @@ static void wait_defer(void) uatomic_set(&defer_thread_futex, 0); } else { cmm_smp_rmb(); /* Read queue before read futex */ - if (uatomic_read(&defer_thread_futex) != -1) - return; - while (futex_noasync(&defer_thread_futex, FUTEX_WAIT, -1, - NULL, NULL, 0)) { + while (uatomic_read(&defer_thread_futex) == -1) { + if (!futex_noasync(&defer_thread_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); @@ -265,7 +273,7 @@ void rcu_defer_barrier_thread(void) _rcu_defer_barrier_thread(); mutex_unlock(&rcu_defer_mutex); } -__attribute__((alias(urcu_stringify(rcu_defer_barrier_thread)))) +URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_barrier_thread)) void alias_rcu_defer_barrier_thread(); /* @@ -307,7 +315,7 @@ void rcu_defer_barrier(void) end: mutex_unlock(&rcu_defer_mutex); } -__attribute__((alias(urcu_stringify(rcu_defer_barrier)))) +URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_barrier)) void alias_rcu_defer_barrier(); /* @@ -376,7 +384,7 @@ static void _defer_rcu(void (*fct)(void *p), void *p) wake_up_defer(); } -static void *thr_defer(void *args) +static void *thr_defer(void *args __attribute__((unused))) { for (;;) { /* @@ -401,7 +409,7 @@ void defer_rcu(void (*fct)(void *p), void *p) { _defer_rcu(fct, p); } -__attribute__((alias(urcu_stringify(defer_rcu)))) void alias_defer_rcu(); +URCU_ATTR_ALIAS(urcu_stringify(defer_rcu)) void alias_defer_rcu(); static void start_defer_thread(void) { @@ -450,7 +458,7 @@ int rcu_defer_register_thread(void) mutex_unlock(&defer_thread_mutex); return 0; } -__attribute__((alias(urcu_stringify(rcu_defer_register_thread)))) +URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_register_thread)) int alias_rcu_defer_register_thread(); void rcu_defer_unregister_thread(void) @@ -470,14 +478,14 @@ void rcu_defer_unregister_thread(void) stop_defer_thread(); mutex_unlock(&defer_thread_mutex); } -__attribute__((alias(urcu_stringify(rcu_defer_unregister_thread)))) +URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_unregister_thread)) void alias_rcu_defer_unregister_thread(); void rcu_defer_exit(void) { assert(cds_list_empty(®istry_defer)); } -__attribute__((alias(urcu_stringify(rcu_defer_exit)))) +URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_exit)) void alias_rcu_defer_exit(); #endif /* _URCU_DEFER_IMPL_H */