* Derived from AO_compare_and_swap() and AO_test_and_set_full().
*/
-static __attribute__((always_inline))
+static inline __attribute__((always_inline))
unsigned int atomic_exchange_32(volatile unsigned int *addr, unsigned int val)
{
unsigned int result;
#if (BITS_PER_LONG == 64)
-static __attribute__((always_inline))
+static inline __attribute__((always_inline))
unsigned long atomic_exchange_64(volatile unsigned long *addr,
unsigned long val)
{
#endif
-static __attribute__((always_inline))
+static inline __attribute__((always_inline))
unsigned long _atomic_exchange(volatile void *addr, unsigned long val, int len)
{
switch (len) {
/*
* Serialize core instruction execution. Also acts as a compiler barrier.
*/
+#ifdef __PIC__
+/*
+ * Cannot use cpuid because it clobbers the ebx register and clashes
+ * with -fPIC :
+ * error: PIC register 'ebx' clobbered in 'asm'
+ */
+static inline void sync_core(void)
+{
+ mb();
+}
+#else
static inline void sync_core(void)
{
asm volatile("cpuid" : : : "memory", "eax", "ebx", "ecx", "edx");
}
+#endif
#define rdtscll(val) \
do { \
*/
/*
- * Current RCU formal verification model assumes sequential execution of
- * the write-side. Add core synchronization instructions. Can be removed
- * if the formal model is extended to prove that reordering is still
- * correct.
+ * Adding a smp_mb() which is _not_ formally required, but makes the
+ * model easier to understand. It does not have a big performance impact
+ * anyway, given this is the write-side.
*/
- sync_core(); /* Formal model assumes serialized execution */
+ smp_mb();
/*
* Wait for previous parity to be empty of readers.
* Ensured by STORE_SHARED and LOAD_SHARED.
*/
- sync_core(); /* Formal model assumes serialized execution */
+ /*
+ * Adding a smp_mb() which is _not_ formally required, but makes the
+ * model easier to understand. It does not have a big performance impact
+ * anyway, given this is the write-side.
+ */
+ smp_mb();
switch_next_urcu_qparity(); /* 1 -> 0 */
* Ensured by STORE_SHARED and LOAD_SHARED.
*/
- sync_core(); /* Formal model assumes serialized execution */
+ /*
+ * Adding a smp_mb() which is _not_ formally required, but makes the
+ * model easier to understand. It does not have a big performance impact
+ * anyway, given this is the write-side.
+ */
+ smp_mb();
/*
* Wait for previous parity to be empty of readers.