mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-24 04:45:14 +00:00
atomics: do not emit consume barrier for atomic_rcu_read
Currently we emit a consume-load in atomic_rcu_read. Because of limitations in current compilers, this is overkill for non-Alpha hosts and it is only useful to make Thread Sanitizer work. This patch leaves the consume-load in atomic_rcu_read when compiling with Thread Sanitizer enabled, and resorts to a relaxed load + smp_read_barrier_depends otherwise. On an RMO host architecture, such as aarch64, the performance improvement of this change is easily measurable. For instance, qht-bench performs an atomic_rcu_read on every lookup. Performance before and after applying this patch: $ tests/qht-bench -d 5 -n 1 Before: 9.78 MT/s After: 10.96 MT/s Backports commit 15487aa132109891482f79d78a30d6cfd465a391 from qemu
This commit is contained in:
parent
87ef2a2c5f
commit
ab569f5cde
|
@ -70,12 +70,22 @@ void _ReadWriteBarrier(void);
|
||||||
__atomic_store(ptr, &_val, __ATOMIC_RELAXED); \
|
__atomic_store(ptr, &_val, __ATOMIC_RELAXED); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/* Atomic RCU operations imply weak memory barriers */
|
/* See above: most compilers currently treat consume and acquire the
|
||||||
|
* same, but this slows down atomic_rcu_read unnecessarily.
|
||||||
|
*/
|
||||||
|
#ifdef __SANITIZE_THREAD__
|
||||||
|
#define atomic_rcu_read__nocheck(ptr, valptr) \
|
||||||
|
__atomic_load(ptr, valptr, __ATOMIC_CONSUME);
|
||||||
|
#else
|
||||||
|
#define atomic_rcu_read__nocheck(ptr, valptr) \
|
||||||
|
__atomic_load(ptr, valptr, __ATOMIC_RELAXED); \
|
||||||
|
smp_read_barrier_depends();
|
||||||
|
#endif
|
||||||
|
|
||||||
#define atomic_rcu_read(ptr) \
|
#define atomic_rcu_read(ptr) \
|
||||||
({ \
|
({ \
|
||||||
typeof(*ptr) _val; \
|
typeof(*ptr) _val; \
|
||||||
__atomic_load(ptr, &_val, __ATOMIC_CONSUME); \
|
atomic_rcu_read__nocheck(ptr, &_val); \
|
||||||
_val; \
|
_val; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue