X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fworkqueue.c;h=3b7115356615576d80f309f3a103f9a350d964cb;hb=740d42ae21821082dc7f545f984253418a53bd87;hp=1e045fb7d4c40cf9d271878b8638d39a43b5fa49;hpb=0614a2e61ccbf150cc51d4fd3073b285983417c5;p=userspace-rcu.git diff --git a/src/workqueue.c b/src/workqueue.c index 1e045fb..3b71153 100644 --- a/src/workqueue.c +++ b/src/workqueue.c @@ -92,7 +92,7 @@ struct urcu_workqueue_completion_work { * Losing affinity can be caused by CPU hotunplug/hotplug, or by * cpuset(7). */ -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue) { cpu_set_t mask; @@ -121,7 +121,7 @@ static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue) return ret; } #else -static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue) +static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue __attribute__((unused))) { return 0; } @@ -131,16 +131,25 @@ static void futex_wait(int32_t *futex) { /* Read condition before read futex */ cmm_smp_mb(); - if (uatomic_read(futex) != -1) - return; - while (futex_async(futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + while (uatomic_read(futex) == -1) { + if (!futex_async(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);