X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=urcu-qsbr-static.h;h=108ef6e7181d58409b2314d0ea0551b211f8e76a;hp=7cef820d59fd7ff4223b0a9cc01f6834073d7b13;hb=5481ddb381061bda64aebc039900d21cac6a6caf;hpb=f02bbafc4513879a545b6b5ad932ea5ff220230d diff --git a/urcu-qsbr-static.h b/urcu-qsbr-static.h index 7cef820..108ef6e 100644 --- a/urcu-qsbr-static.h +++ b/urcu-qsbr-static.h @@ -9,7 +9,7 @@ * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu-qsbr.h for linking * dynamically with the userspace rcu QSBR library. * - * Copyright (c) 2009 Mathieu Desnoyers + * Copyright (c) 2009 Mathieu Desnoyers * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. * * This library is free software; you can redistribute it and/or @@ -135,7 +135,7 @@ struct rcu_reader { /* Data used by both reader and synchronize_rcu() */ unsigned long ctr; /* Data used for registry */ - struct list_head head __attribute__((aligned(CACHE_LINE_SIZE))); + struct list_head node __attribute__((aligned(CACHE_LINE_SIZE))); pthread_t tid; }; @@ -155,27 +155,13 @@ static inline void wake_up_gp(void) } } -#if (BITS_PER_LONG < 64) -static inline int rcu_gp_ongoing(unsigned long *value) +static inline int rcu_gp_ongoing(unsigned long *ctr) { - unsigned long reader_gp; + unsigned long v; - if (value == NULL) - return 0; - reader_gp = LOAD_SHARED(*value); - return reader_gp && ((reader_gp ^ rcu_gp_ctr) & RCU_GP_CTR); + v = LOAD_SHARED(*ctr); + return v && (v != rcu_gp_ctr); } -#else /* !(BITS_PER_LONG < 64) */ -static inline int rcu_gp_ongoing(unsigned long *value) -{ - unsigned long reader_gp; - - if (value == NULL) - return 0; - reader_gp = LOAD_SHARED(*value); - return reader_gp && (reader_gp - rcu_gp_ctr > ULONG_MAX / 2); -} -#endif /* !(BITS_PER_LONG < 64) */ static inline void _rcu_read_lock(void) { @@ -188,25 +174,27 @@ static inline void _rcu_read_unlock(void) static inline void _rcu_quiescent_state(void) { - smp_mb(); + cmm_smp_mb(); _STORE_SHARED(rcu_reader.ctr, _LOAD_SHARED(rcu_gp_ctr)); - smp_mb(); /* write rcu_reader.ctr before read futex */ + cmm_smp_mb(); /* write rcu_reader.ctr before read futex */ wake_up_gp(); - smp_mb(); + cmm_smp_mb(); } static inline void _rcu_thread_offline(void) { - smp_mb(); + cmm_smp_mb(); STORE_SHARED(rcu_reader.ctr, 0); - smp_mb(); /* write rcu_reader.ctr before read futex */ + cmm_smp_mb(); /* write rcu_reader.ctr before read futex */ wake_up_gp(); + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ } static inline void _rcu_thread_online(void) { + cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ _STORE_SHARED(rcu_reader.ctr, LOAD_SHARED(rcu_gp_ctr)); - smp_mb(); + cmm_smp_mb(); } #ifdef __cplusplus