diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2023-03-03 14:37:51 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2023-06-06 09:42:14 +0200 |
commit | 06831001ac8949b0801e0d20c347d97339769a20 (patch) | |
tree | 01c418078a78ff8049bf5eb7bc36cf3e3bddcb14 /include | |
parent | 09a49afeae2542993d4cdc5d7af22abdfce7a3ba (diff) |
atomics: eliminate mb_read/mb_set
qatomic_mb_read and qatomic_mb_set were the very first atomic primitives
introduced for QEMU; their semantics are unclear and they provide a false
sense of safety.
The last use of qatomic_mb_read() has been removed, so delete it.
qatomic_mb_set() instead can survive as an optimized
qatomic_set()+smp_mb(), similar to Linux's smp_store_mb(), but
rename it to qatomic_set_mb() to match the order of the two
operations.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/atomic.h | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index f85834ee8b..d95612f7a0 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -259,24 +259,17 @@ # define smp_mb__after_rmw() smp_mb() #endif -/* qatomic_mb_read/set semantics map Java volatile variables. They are - * less expensive on some platforms (notably POWER) than fully - * sequentially consistent operations. - * - * As long as they are used as paired operations they are safe to - * use. See docs/devel/atomics.rst for more discussion. +/* + * On some architectures, qatomic_set_mb is more efficient than a store + * plus a fence. */ -#define qatomic_mb_read(ptr) \ - qatomic_load_acquire(ptr) - #if !defined(QEMU_SANITIZE_THREAD) && \ (defined(__i386__) || defined(__x86_64__) || defined(__s390x__)) -/* This is more efficient than a store plus a fence. */ -# define qatomic_mb_set(ptr, i) \ +# define qatomic_set_mb(ptr, i) \ ({ (void)qatomic_xchg(ptr, i); smp_mb__after_rmw(); }) #else -# define qatomic_mb_set(ptr, i) \ +# define qatomic_set_mb(ptr, i) \ ({ qatomic_store_release(ptr, i); smp_mb(); }) #endif |