qemu-devel
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]