#include <urcu/system.h>
#include <urcu/tls-compat.h>
#include "urcu-die.h"
+#include "urcu-utils.h"
/*
* Number of entries in the per-thread defer queue. Must be power of 2.
};
/* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */
-#include "urcu-defer.h"
+#include <urcu/defer.h>
void __attribute__((destructor)) rcu_defer_exit(void);
* Written to only by each individual deferer. Read by both the deferer and
* the reclamation tread.
*/
-static DEFINE_URCU_TLS_IE(struct defer_queue, defer_queue);
+static DEFINE_URCU_TLS(struct defer_queue, defer_queue);
static CDS_LIST_HEAD(registry_defer);
static pthread_t tid_defer;
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);
_rcu_defer_barrier_thread();
mutex_unlock(&rcu_defer_mutex);
}
+URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_barrier_thread))
+void alias_rcu_defer_barrier_thread();
/*
* rcu_defer_barrier - Execute all queued rcu callbacks.
end:
mutex_unlock(&rcu_defer_mutex);
}
+URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_barrier))
+void alias_rcu_defer_barrier();
/*
* _defer_rcu - Queue a RCU callback.
wake_up_defer();
}
-static void *thr_defer(void *args)
+static void *thr_defer(void *args __attribute__((unused)))
{
for (;;) {
/*
{
_defer_rcu(fct, p);
}
+URCU_ATTR_ALIAS(urcu_stringify(defer_rcu)) void alias_defer_rcu();
static void start_defer_thread(void)
{
int ret;
ret = pthread_create(&tid_defer, NULL, thr_defer, NULL);
- assert(!ret);
+ if (ret)
+ urcu_die(ret);
}
static void stop_defer_thread(void)
mutex_unlock(&defer_thread_mutex);
return 0;
}
+URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_register_thread))
+int alias_rcu_defer_register_thread();
void rcu_defer_unregister_thread(void)
{
stop_defer_thread();
mutex_unlock(&defer_thread_mutex);
}
+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));
}
+URCU_ATTR_ALIAS(urcu_stringify(rcu_defer_exit))
+void alias_rcu_defer_exit();
#endif /* _URCU_DEFER_IMPL_H */