X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Furcu-defer-impl.h;h=f1fae9c0d15ce4364a44d511f2a4701febe0c4b5;hb=070e8aeccb9f9dbfed57245e78839eb181c66db5;hp=b34a1a17b11adabd9cc8da0aca6d030106889755;hpb=ce28e67a534dcf0b68ccad2218e5a2e552e6e469;p=userspace-rcu.git diff --git a/src/urcu-defer-impl.h b/src/urcu-defer-impl.h index b34a1a1..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); @@ -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 (;;) { /*