From: Peter Zijlstra <peterz@infradead.org>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: tglx@linutronix.de, kvm@vger.kernel.org, fweisbec@gmail.com,
jiangshanlai@gmail.com, linux-kernel@vger.kernel.org,
rostedt@goodmis.org, josh@joshtriplett.org, dhowells@redhat.com,
edumazet@google.com, netdev@vger.kernel.org,
mathieu.desnoyers@efficios.com, oleg@redhat.com,
dipankar@in.ibm.com, akpm@linux-foundation.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
virtualization@lists.linux-foundation.org, mingo@kernel.org
Subject: Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
Date: Tue, 5 Dec 2017 20:55:58 +0100 [thread overview]
Message-ID: <20171205195558.GR3165@worktop.lehotels.local> (raw)
In-Reply-To: <20171205212053-mutt-send-email-mst@kernel.org>
On Tue, Dec 05, 2017 at 09:24:21PM +0200, Michael S. Tsirkin wrote:
> On Tue, Dec 05, 2017 at 08:17:33PM +0100, Peter Zijlstra wrote:
> > On Tue, Dec 05, 2017 at 08:57:46PM +0200, Michael S. Tsirkin wrote:
> >
> > > I don't see WRITE_ONCE inserting any barriers, release or
> > > write.
> >
> > Correct, never claimed there was.
> >
> > Just saying that:
> >
> > obj = READ_ONCE(*foo);
> > val = READ_ONCE(obj->val);
> >
> > Never needs a barrier (except on Alpha and we want to make that go
> > away). Simply because a CPU needs to complete the load of @obj before it
> > can compute the address &obj->val. Thus the second load _must_ come
> > after the first load and we get LOAD-LOAD ordering.
> >
> > Alpha messing that up is a royal pain, and Alpha not being an
> > active/living architecture is just not worth the pain of keeping this in
> > the generic model.
> >
>
> Right. What I am saying is that for writes you need
>
> WRITE_ONCE(obj->val, 1);
> smp_wmb();
> WRITE_ONCE(*foo, obj);
You really should use smp_store_release() here instead of the smp_wmb().
But yes.
> and this barrier is no longer paired with anything until
> you realize there's a dependency barrier within READ_ONCE.
No, there isn't. read_dependecy barriers are no more. They don't exist.
They never did, except on Alpha anyway.
There were a ton of sites that relied on this but never had the
smp_read_barrier_depends() annotation, similarly there were quite a few
sites that had the barrier but nobody could explain wtf for.
What these patches do is return the sane rule that dependent loads are
ordered.
And like all memory ordering; it should come with comments. Any piece of
code that relies on memory ordering and doesn't have big fat comments
that explain the required ordering are broken per definition. Maybe not
now, but they will be after a few years because someone changed it and
didn't know.
> Barrier pairing was a useful tool to check code validity,
> maybe there are other, better tools now.
Same is true for the closely related control dependency, you can pair
against those just fine but they don't have an explicit barrier
annotation.
There are no tools, use brain.
prev parent reply other threads:[~2017-12-05 19:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20171201195053.GA23494@linux.vnet.ibm.com>
2017-12-01 19:50 ` [PATCH tip/core/rcu 03/21] drivers/net/ethernet/qlogic/qed: Fix __qed_spq_block() ordering Paul E. McKenney
2017-12-01 19:51 ` [PATCH tip/core/rcu 14/21] netfilter: Remove now-redundant smp_read_barrier_depends() Paul E. McKenney
2017-12-01 19:51 ` [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends() Paul E. McKenney
2017-12-05 18:31 ` Michael S. Tsirkin
2017-12-05 18:39 ` Peter Zijlstra
2017-12-05 18:57 ` Michael S. Tsirkin
2017-12-05 19:17 ` Peter Zijlstra
2017-12-05 19:24 ` Michael S. Tsirkin
2017-12-05 19:33 ` Paul E. McKenney
2017-12-05 19:51 ` Michael S. Tsirkin
2017-12-05 19:57 ` Peter Zijlstra
2017-12-05 20:28 ` Michael S. Tsirkin
2017-12-05 21:17 ` Peter Zijlstra
2017-12-05 21:42 ` Michael S. Tsirkin
2017-12-05 20:08 ` Paul E. McKenney
2017-12-05 21:24 ` Michael S. Tsirkin
2017-12-05 21:36 ` Paul E. McKenney
2017-12-05 21:43 ` Michael S. Tsirkin
2017-12-05 22:02 ` Paul E. McKenney
2017-12-05 22:09 ` Peter Zijlstra
2017-12-05 21:57 ` Peter Zijlstra
2017-12-05 22:09 ` Michael S. Tsirkin
2017-12-05 23:39 ` Paul E. McKenney
2017-12-05 19:55 ` Peter Zijlstra [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=20171205195558.GR3165@worktop.lehotels.local \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--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).