From: Sergey Fedorov <serge.fdrv@gmail.com>
To: "Emilio G. Cota" <cota@braap.org>,
QEMU Developers <qemu-devel@nongnu.org>,
MTTCG Devel <mttcg@listserver.greensocs.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] atomics: emit an smp_read_barrier_depends() barrier only for Sparc and Thread Sanitizer
Date: Tue, 24 May 2016 23:09:47 +0300 [thread overview]
Message-ID: <5744B50B.5040001@gmail.com> (raw)
In-Reply-To: <1464120374-8950-3-git-send-email-cota@braap.org>
On 24/05/16 23:06, Emilio G. Cota wrote:
> For correctness, smp_read_barrier_depends() is only required to
> emit a barrier on Sparc hosts. However, we are currently emitting
> a consume fence unconditionally.
>
> Fix it by keeping the consume fence if we're compiling with Thread
> Sanitizer, since this might help prevent false warnings. Otherwise,
> only emit the barrier for Sparc hosts. Note that we still guarantee
> that smp_read_barrier_depends() is a compiler barrier.
s/Sparc/Alpha/?
Regards,
Sergey
>
> Signed-off-by: Emilio G. Cota <cota@braap.org>
> ---
> include/qemu/atomic.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index 5bc4d6c..4a4f2fb 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -36,7 +36,14 @@
> #define smp_wmb() ({ barrier(); __atomic_thread_fence(__ATOMIC_RELEASE); barrier(); })
> #define smp_rmb() ({ barrier(); __atomic_thread_fence(__ATOMIC_ACQUIRE); barrier(); })
>
> +#if defined(__SANITIZE_THREAD__)
> #define smp_read_barrier_depends() ({ barrier(); __atomic_thread_fence(__ATOMIC_CONSUME); barrier(); })
> +#elsif defined(__alpha__)
> +#define smp_read_barrier_depends() asm volatile("mb":::"memory")
> +#else
> +#define smp_read_barrier_depends() barrier()
> +#endif
> +
>
> /* Weak atomic operations prevent the compiler moving other
> * loads/stores past the atomic operation load/store. However there is
next prev parent reply other threads:[~2016-05-24 20:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 20:06 [Qemu-devel] [PATCH v2 0/3] atomics: fix RCU perf. regression + update documentation Emilio G. Cota
2016-05-24 20:06 ` [Qemu-devel] [PATCH v2 1/3] docs/atomics: update atomic_read/set comparison with Linux Emilio G. Cota
2016-05-25 12:13 ` Paolo Bonzini
2016-05-24 20:06 ` [Qemu-devel] [PATCH v2 2/3] atomics: emit an smp_read_barrier_depends() barrier only for Sparc and Thread Sanitizer Emilio G. Cota
2016-05-24 20:09 ` Sergey Fedorov [this message]
2016-05-24 20:44 ` Emilio G. Cota
2016-05-25 12:16 ` Paolo Bonzini
2016-05-25 15:06 ` Emilio G. Cota
2016-05-24 20:06 ` [Qemu-devel] [PATCH v2 3/3] atomics: do not emit consume barrier for atomic_rcu_read Emilio G. Cota
2016-05-25 12:20 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5744B50B.5040001@gmail.com \
--to=serge.fdrv@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=cota@braap.org \
--cc=mttcg@listserver.greensocs.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).