X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=urcu-static.h;h=44bcd073710e3e98d760c667eb7aa787238bb3ff;hb=f0708810fe66d7fdcf52903c607ed65c9fa664c7;hp=bd11be8d212fbd942d42ba00fd33711347b04c39;hpb=02be55611d3b1c7bf4fdfcb3a9c98f621882d417;p=userspace-rcu.git diff --git a/urcu-static.h b/urcu-static.h index bd11be8..44bcd07 100644 --- a/urcu-static.h +++ b/urcu-static.h @@ -45,6 +45,26 @@ extern "C" { #endif +/* Default is RCU_MEMBARRIER */ +#if !defined(RCU_MEMBARRIER) && !defined(RCU_MB) && !defined(RCU_SIGNAL) +#define RCU_MEMBARRIER +#endif + +#ifdef RCU_MEMBARRIER +#include +#include + +/* If the headers do not support SYS_membarrier, statically use RCU_MB */ +#ifdef SYS_membarrier +# define MEMBARRIER_EXPEDITED (1 << 0) +# define MEMBARRIER_DELAYED (1 << 1) +# define membarrier(...) syscall(__NR_membarrier, __VA_ARGS__) +#else +# undef RCU_MEMBARRIER +# define RCU_MB +#endif +#endif + /* * This code section can only be included in LGPL 2.1 compatible source code. * See below for the function call wrappers which can be used in code meant to @@ -89,14 +109,13 @@ extern "C" { #define YIELD_WRITE (1 << 1) /* - * Updates without RCU_MB are much slower. Account this in - * the delay. + * Updates with RCU_SIGNAL are much slower. Account this in the delay. */ -#ifdef RCU_MB +#ifdef RCU_SIGNAL /* maximum sleep delay, in us */ -#define MAX_SLEEP 50 -#else #define MAX_SLEEP 30000 +#else +#define MAX_SLEEP 50 #endif extern unsigned int yield_active; @@ -135,13 +154,27 @@ static inline void debug_yield_init(void) } #endif +#ifdef RCU_MEMBARRIER +extern int has_sys_membarrier; + +static inline void smp_mb_light() +{ + if (likely(has_sys_membarrier)) + barrier(); + else + smp_mb(); +} +#endif + #ifdef RCU_MB -static inline void reader_barrier() +static inline void smp_mb_light() { smp_mb(); } -#else -static inline void reader_barrier() +#endif + +#ifdef RCU_SIGNAL +static inline void smp_mb_light() { barrier(); } @@ -216,9 +249,9 @@ static inline void _rcu_read_lock(void) _STORE_SHARED(rcu_reader.ctr, _LOAD_SHARED(rcu_gp_ctr)); /* * Set active readers count for outermost nesting level before - * accessing the pointer. See force_mb_all_threads(). + * accessing the pointer. See smp_mb_heavy(). */ - reader_barrier(); + smp_mb_light(); } else { _STORE_SHARED(rcu_reader.ctr, tmp + RCU_GP_COUNT); } @@ -231,13 +264,13 @@ static inline void _rcu_read_unlock(void) tmp = rcu_reader.ctr; /* * Finish using rcu before decrementing the pointer. - * See force_mb_all_threads(). + * See smp_mb_heavy(). */ if (likely((tmp & RCU_GP_CTR_NEST_MASK) == RCU_GP_COUNT)) { - reader_barrier(); + smp_mb_light(); _STORE_SHARED(rcu_reader.ctr, rcu_reader.ctr - RCU_GP_COUNT); /* write rcu_reader.ctr before read futex */ - reader_barrier(); + smp_mb_light(); wake_up_gp(); } else { _STORE_SHARED(rcu_reader.ctr, rcu_reader.ctr - RCU_GP_COUNT);