Paul E. McKenney
2017-Dec-01 19:51 UTC
[PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
Because READ_ONCE() now implies read_barrier_depends(), the read_barrier_depends() in next_desc() is now redundant. This commit therefore removes it and the related comments. Signed-off-by: Paul E. McKenney <paulmck at linux.vnet.ibm.com> Cc: "Michael S. Tsirkin" <mst at redhat.com> Cc: Jason Wang <jasowang at redhat.com> Cc: <kvm at vger.kernel.org> Cc: <virtualization at lists.linux-foundation.org> Cc: <netdev at vger.kernel.org> --- drivers/vhost/vhost.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 33ac2b186b85..78b5940a415a 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1877,12 +1877,7 @@ static unsigned next_desc(struct vhost_virtqueue *vq, struct vring_desc *desc) return -1U; /* Check they're not leading us off end of descriptors. */ - next = vhost16_to_cpu(vq, desc->next); - /* Make sure compiler knows to grab that: we don't want it changing! */ - /* We will use the result as an index in an array, so most - * architectures only need a compiler barrier here. */ - read_barrier_depends(); - + next = vhost16_to_cpu(vq, READ_ONCE(desc->next)); return next; } -- 2.5.2
Michael S. Tsirkin
2017-Dec-05 18:31 UTC
[PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
On Fri, Dec 01, 2017 at 11:51:16AM -0800, Paul E. McKenney wrote:> Because READ_ONCE() now implies read_barrier_depends(), the > read_barrier_depends() in next_desc() is now redundant. This commit > therefore removes it and the related comments. > > Signed-off-by: Paul E. McKenney <paulmck at linux.vnet.ibm.com> > Cc: "Michael S. Tsirkin" <mst at redhat.com> > Cc: Jason Wang <jasowang at redhat.com> > Cc: <kvm at vger.kernel.org> > Cc: <virtualization at lists.linux-foundation.org> > Cc: <netdev at vger.kernel.org>Apropos, READ_ONCE is now asymmetrical with WRITE_ONCE. I can read a pointer with READ_ONCE and be sure the value is sane, but only if I also remember to put in smp_wmb before WRITE_ONCE. Otherwise the pointer is ok but no guarantees about the data pointed to. It would be better if the API reflected he assymetry somehow.> --- > drivers/vhost/vhost.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index 33ac2b186b85..78b5940a415a 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -1877,12 +1877,7 @@ static unsigned next_desc(struct vhost_virtqueue *vq, struct vring_desc *desc) > return -1U; > > /* Check they're not leading us off end of descriptors. */ > - next = vhost16_to_cpu(vq, desc->next); > - /* Make sure compiler knows to grab that: we don't want it changing! */ > - /* We will use the result as an index in an array, so most > - * architectures only need a compiler barrier here. */ > - read_barrier_depends(); > - > + next = vhost16_to_cpu(vq, READ_ONCE(desc->next)); > return next; > } > > -- > 2.5.2
Peter Zijlstra
2017-Dec-05 18:39 UTC
[PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
On Tue, Dec 05, 2017 at 08:31:20PM +0200, Michael S. Tsirkin wrote:> Apropos, READ_ONCE is now asymmetrical with WRITE_ONCE. > > I can read a pointer with READ_ONCE and be sure the value > is sane, but only if I also remember to put in smp_wmb before > WRITE_ONCE. Otherwise the pointer is ok but no guarantees > about the data pointed to.That was already the case on everything except Alpha. And the canonical match do the data dependency is store_release, not wmb.
Maybe Matching Threads
- [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
- [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
- [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
- [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends()
- [PATCH 00/13] Finish off [smp_]read_barrier_depends()