Rename likely/unlikely to caa_likely/caa_unlikely
[urcu.git] / urcu / static / urcu-qsbr.h
index e0b12be15c2ebdf540446dbbaa16cdce8ff5f4fe..68bfc31f540ee07adbb0701251adac9ccb0434b5 100644 (file)
 #include <pthread.h>
 #include <assert.h>
 #include <limits.h>
-#include <syscall.h>
 #include <unistd.h>
+#include <stdint.h>
 
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
 #include <urcu/system.h>
-#include <urcu/uatomic_arch.h>
+#include <urcu/uatomic.h>
 #include <urcu/list.h>
-#include <urcu/urcu-futex.h>
+#include <urcu/futex.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -55,18 +55,6 @@ extern "C" {
  * This is required to permit relinking with newer versions of the library.
  */
 
-/*
- * If a reader is really non-cooperative and refuses to commit its
- * rcu_reader.ctr count to memory (there is no barrier in the reader
- * per-se), kick it after a few loops waiting for it.
- */
-#define KICK_READER_LOOPS 10000
-
-/*
- * Active attempts to check for reader Q.S. before calling futex().
- */
-#define RCU_QS_ACTIVE_ATTEMPTS 100
-
 #ifdef DEBUG_RCU
 #define rcu_assert(args...)    assert(args)
 #else
@@ -136,19 +124,24 @@ struct rcu_reader {
        unsigned long ctr;
        /* Data used for registry */
        struct cds_list_head node __attribute__((aligned(CAA_CACHE_LINE_SIZE)));
+       int waiting;
        pthread_t tid;
 };
 
 extern struct rcu_reader __thread rcu_reader;
 
-extern int gp_futex;
+extern int32_t gp_futex;
 
 /*
  * Wake-up waiting synchronize_rcu(). Called from many concurrent threads.
  */
 static inline void wake_up_gp(void)
 {
-       if (unlikely(uatomic_read(&gp_futex) == -1)) {
+       if (caa_unlikely(_CMM_LOAD_SHARED(rcu_reader.waiting))) {
+               _CMM_STORE_SHARED(rcu_reader.waiting, 0);
+               cmm_smp_mb();
+               if (uatomic_read(&gp_futex) != -1)
+                       return;
                uatomic_set(&gp_futex, 0);
                futex_noasync(&gp_futex, FUTEX_WAKE, 1,
                      NULL, NULL, 0);
This page took 0.024237 seconds and 4 git commands to generate.