Revert "Use initial-exec tls model"
[urcu.git] / src / urcu-bp.c
index 4b4fe45b2c4bcaefe3dde281d0074f87caf0bc6b..ebe96c57da9630d3e43168ee32fa96da95277bfa 100644 (file)
@@ -111,7 +111,9 @@ void __attribute__((constructor)) rcu_bp_init(void);
 static
 void __attribute__((destructor)) rcu_bp_exit(void);
 
+#ifndef CONFIG_RCU_FORCE_SYS_MEMBARRIER
 int urcu_bp_has_sys_membarrier;
+#endif
 
 /*
  * rcu_gp_lock ensures mutual exclusion between threads calling
@@ -372,7 +374,8 @@ void expand_arena(struct registry_arena *arena)
                        sizeof(struct registry_chunk)
                        + sizeof(struct rcu_reader));
                new_chunk_len = ARENA_INIT_ALLOC;
-               new_chunk = mmap(NULL, new_chunk_len,
+               new_chunk = (struct registry_chunk *) mmap(NULL,
+                       new_chunk_len,
                        PROT_READ | PROT_WRITE,
                        MAP_ANONYMOUS | MAP_PRIVATE,
                        -1, 0);
@@ -406,7 +409,8 @@ void expand_arena(struct registry_arena *arena)
        }
 
        /* Remap did not succeed, we need to add a new chunk. */
-       new_chunk = mmap(NULL, new_chunk_len,
+       new_chunk = (struct registry_chunk *) mmap(NULL,
+               new_chunk_len,
                PROT_READ | PROT_WRITE,
                MAP_ANONYMOUS | MAP_PRIVATE,
                -1, 0);
@@ -578,6 +582,27 @@ void urcu_bp_thread_exit_notifier(void *rcu_key)
        rcu_bp_unregister(rcu_key);
 }
 
+#ifdef CONFIG_RCU_FORCE_SYS_MEMBARRIER
+static
+void rcu_sys_membarrier_status(int available)
+{
+       if (!available)
+               abort();
+}
+#else
+static
+void rcu_sys_membarrier_status(int available)
+{
+       /*
+        * membarrier has blocking behavior, which changes the
+        * application behavior too much compared to using barriers when
+        * synchronize_rcu is used repeatedly (without using call_rcu).
+        * Don't use membarrier for now, unless its use has been
+        * explicitly forced when building liburcu.
+        */
+}
+#endif
+
 static
 void rcu_bp_init(void)
 {
@@ -590,9 +615,8 @@ void rcu_bp_init(void)
                if (ret)
                        abort();
                ret = membarrier(MEMBARRIER_CMD_QUERY, 0);
-               if (ret >= 0 && (ret & MEMBARRIER_CMD_SHARED)) {
-                       urcu_bp_has_sys_membarrier = 1;
-               }
+               rcu_sys_membarrier_status(ret >= 0
+                               && (ret & MEMBARRIER_CMD_SHARED));
                initialized = 1;
        }
        mutex_unlock(&init_lock);
@@ -608,7 +632,7 @@ void rcu_bp_exit(void)
 
                cds_list_for_each_entry_safe(chunk, tmp,
                                &registry_arena.chunk_list, node) {
-                       munmap(chunk, chunk->data_len
+                       munmap((void *) chunk, chunk->data_len
                                        + sizeof(struct registry_chunk));
                }
                CDS_INIT_LIST_HEAD(&registry_arena.chunk_list);
This page took 0.032505 seconds and 4 git commands to generate.