X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=src%2Furcu-bp.c;h=ebe96c57da9630d3e43168ee32fa96da95277bfa;hp=4b4fe45b2c4bcaefe3dde281d0074f87caf0bc6b;hb=2f6618651c31c05ba1adbb5cdcf0d92980c38f38;hpb=6893800a4d1cc14dff0395ddcd660a5138db183d diff --git a/src/urcu-bp.c b/src/urcu-bp.c index 4b4fe45..ebe96c5 100644 --- a/src/urcu-bp.c +++ b/src/urcu-bp.c @@ -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, ®istry_arena.chunk_list, node) { - munmap(chunk, chunk->data_len + munmap((void *) chunk, chunk->data_len + sizeof(struct registry_chunk)); } CDS_INIT_LIST_HEAD(®istry_arena.chunk_list);