From: "Michael S. Tsirkin" <mst@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: qemu-devel@nongnu.org, Jason Wang <jasowang@redhat.com>,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [Qemu-devel] [PATCH] virtio: use smp_load_acquire/smp_store_release
Date: Thu, 17 Dec 2015 16:47:32 +0200 [thread overview]
Message-ID: <20151217164428-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <20151217105827.GB6375@twins.programming.kicks-ass.net>
On Thu, Dec 17, 2015 at 11:58:27AM +0100, Peter Zijlstra wrote:
> On Thu, Dec 17, 2015 at 12:29:03PM +0200, Michael S. Tsirkin wrote:
> > +static inline __virtio16 virtio_load_acquire(bool weak_barriers, __virtio16 *p)
> > +{
> > + if (!weak_barriers) {
> > + rmb();
> > + return READ_ONCE(*p);
> > + }
> > +#ifdef CONFIG_SMP
> > + return smp_load_acquire(p);
> > +#else
> > + dma_rmb();
> > + return READ_ONCE(*p);
> > +#endif
> > +}
>
> This too is wrong. Look for example at arm.
>
> dma_rmb() is dmb(osh), while the smp_mb() used by smp_load_acquire() is
> dmb(ish). They order completely different types of memory accesses.
>
> Also, load_acquire() is first load, then barrier, and an ACQUIRE barrier
> at that, not a READ barrier.
Yes - it just so happens that READ barrier is enough for where I use it
for virtio.
I really just need virtio_load_acquire that fences reads,
I don't care what happens to writes.
Given the confusion, maybe virtio_load_acquire is a bad name though.
Donnu what a good name would be.
virtio_load_acquire_rmb and virtio_store_release_wmb?
> So your #else branch should look something like:
>
> var = READ_ONCE(*p);
> dma_mb();
> return var;
>
prev parent reply other threads:[~2015-12-17 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-17 10:29 [Qemu-devel] [PATCH] virtio: use smp_load_acquire/smp_store_release Michael S. Tsirkin
2015-12-17 10:58 ` Peter Zijlstra
2015-12-17 14:47 ` Michael S. Tsirkin [this message]
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=20151217164428-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=qemu-devel@nongnu.org \
--cc=virtualization@lists.linux-foundation.org \
/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).