[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 5/5] atomic: base mb_read/mb_set on load-acquire
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [PATCH 5/5] atomic: base mb_read/mb_set on load-acquire and store-release |
Date: |
Wed, 12 Oct 2016 10:28:13 +0100 |
User-agent: |
mu4e 0.9.17; emacs 25.1.50.7 |
Paolo Bonzini <address@hidden> writes:
> This introduces load-acquire and store-release operations in QEMU.
> For now, just use them as an implementation detail of atomic_mb_read
> and atomic_mb_set.
>
> Since docs/atomics.txt documents that atomic_mb_read only synchronizes
> with an atomic_mb_set of the same variable, we can use the new implementation
> everywhere instead of seq-cst loads and stores.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
<snip>
> +/* This is more efficient than a store plus a fence. */
> +#if defined(__i386__) || defined(__x86_64__) || defined(__s390x__)
> +#define atomic_mb_set(ptr, i) ((void)atomic_xchg(ptr, i))
> +#endif
Is this working around a compiler issue? Shouldn't it already be using
the best instructions for the constraint?
> +
> +#ifndef atomic_mb_read
> +#define atomic_mb_read(ptr) \
> + atomic_load_acquire(ptr)
> +#endif
> +
> +#ifndef atomic_mb_set
> +#define atomic_mb_set(ptr, i) do { \
> + atomic_store_release(ptr, i); \
> + smp_mb(); \
> +} while(0)
> +#endif
> +
> #endif /* QEMU_ATOMIC_H */
--
Alex Bennée
- Re: [Qemu-devel] [PATCH 2/5] cpus: use atomic_read to read seqlock-protected variables, (continued)
- [Qemu-devel] [PATCH 3/5] qemu-thread: use acquire/release to clarify semantics of QemuEvent, Paolo Bonzini, 2016/10/10
- [Qemu-devel] [PATCH 1/5] atomic: introduce smp_mb_acquire and smp_mb_release, Paolo Bonzini, 2016/10/10
- [Qemu-devel] [PATCH 4/5] rcu: simplify memory barriers, Paolo Bonzini, 2016/10/10
- [Qemu-devel] [PATCH 5/5] atomic: base mb_read/mb_set on load-acquire and store-release, Paolo Bonzini, 2016/10/10
- Re: [Qemu-devel] [PATCH 0/5] More thread sanitizer fixes and atomic.h improvements, no-reply, 2016/10/10
- Re: [Qemu-devel] [PATCH 0/5] More thread sanitizer fixes and atomic.h improvements, no-reply, 2016/10/11
- Re: [Qemu-devel] [PATCH 0/5] More thread sanitizer fixes and atomic.h improvements, Alex Bennée, 2016/10/12
- Re: [Qemu-devel] [PATCH 0/5] More thread sanitizer fixes and atomic.h improvements, Emilio G. Cota, 2016/10/12