X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=urcu-qsbr.h;h=448074d019b28ea1219660c43f990b39e09b7479;hb=fb6e510b9ae45b9b984b4646b4be6b9d7a2bbf7c;hp=101b94d49d83c71230bf208bf5cd9771656bab5b;hpb=420e5b9208a77041b662c9d9cdc021287f95eec1;p=urcu.git diff --git a/urcu-qsbr.h b/urcu-qsbr.h index 101b94d..448074d 100644 --- a/urcu-qsbr.h +++ b/urcu-qsbr.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -103,11 +104,17 @@ /* * If a reader is really non-cooperative and refuses to commit its - * urcu_active_readers count to memory (there is no barrier in the reader + * rcu_reader_qs_gp 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 +#ifdef DEBUG_RCU +#define rcu_assert(args...) assert(args) +#else +#define rcu_assert(args...) +#endif + #ifdef DEBUG_YIELD #include #include @@ -117,13 +124,8 @@ #define YIELD_READ (1 << 0) #define YIELD_WRITE (1 << 1) -/* Updates without DEBUG_FULL_MB are much slower. Account this in the delay */ -#ifdef DEBUG_FULL_MB /* maximum sleep delay, in us */ #define MAX_SLEEP 50 -#else -#define MAX_SLEEP 30000 -#endif extern unsigned int yield_active; extern unsigned int __thread rand_yield; @@ -161,26 +163,10 @@ static inline void debug_yield_init(void) } #endif -#ifdef DEBUG_FULL_MB static inline void reader_barrier() { smp_mb(); } -#else -static inline void reader_barrier() -{ - barrier(); -} -#endif - -/* - * The trick here is that RCU_GP_CTR_BIT must be a multiple of 8 so we can use a - * full 8-bits, 16-bits or 32-bits bitmask for the lower order bits. - */ -#define RCU_GP_COUNT (1UL << 0) -/* Use the amount of bits equal to half of the architecture long size */ -#define RCU_GP_CTR_BIT (1UL << (sizeof(long) << 2)) -#define RCU_GP_CTR_NEST_MASK (RCU_GP_CTR_BIT - 1) /* * Global quiescent period counter with low-order bits unused. @@ -189,9 +175,9 @@ static inline void reader_barrier() */ extern long urcu_gp_ctr; -extern long __thread urcu_active_readers; +extern long __thread rcu_reader_qs_gp; -static inline int rcu_old_gp_ongoing(long *value) +static inline int rcu_gp_ongoing(long *value) { if (value == NULL) return 0; @@ -201,6 +187,7 @@ static inline int rcu_old_gp_ongoing(long *value) static inline void _rcu_read_lock(void) { + rcu_assert(rcu_reader_qs_gp & 1); } static inline void _rcu_read_unlock(void) @@ -210,19 +197,19 @@ static inline void _rcu_read_unlock(void) static inline void _rcu_quiescent_state(void) { smp_mb(); - urcu_active_readers = ACCESS_ONCE(urcu_gp_ctr) + 1; + rcu_reader_qs_gp = ACCESS_ONCE(urcu_gp_ctr) + 1; smp_mb(); } static inline void _rcu_thread_offline(void) { smp_mb(); - urcu_active_readers = ACCESS_ONCE(urcu_gp_ctr); + rcu_reader_qs_gp = ACCESS_ONCE(urcu_gp_ctr); } static inline void _rcu_thread_online(void) { - urcu_active_readers = ACCESS_ONCE(urcu_gp_ctr) + 1; + rcu_reader_qs_gp = ACCESS_ONCE(urcu_gp_ctr) + 1; smp_mb(); }