Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752845AbdLESb3 (ORCPT ); Tue, 5 Dec 2017 13:31:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58296 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752668AbdLESbZ (ORCPT ); Tue, 5 Dec 2017 13:31:25 -0500 Date: Tue, 5 Dec 2017 20:31:20 +0200 From: "Michael S. Tsirkin" To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, Jason Wang , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: Re: [PATCH tip/core/rcu 21/21] drivers/vhost: Remove now-redundant read_barrier_depends() Message-ID: <20171205202928-mutt-send-email-mst@kernel.org> References: <20171201195053.GA23494@linux.vnet.ibm.com> <1512157876-24665-21-git-send-email-paulmck@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1512157876-24665-21-git-send-email-paulmck@linux.vnet.ibm.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Dec 2017 18:31:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1647 Lines: 45 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 > Cc: "Michael S. Tsirkin" > Cc: Jason Wang > Cc: > Cc: > Cc: 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