From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6840EC433E0 for ; Mon, 13 Jul 2020 11:28:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3855E2072D for ; Mon, 13 Jul 2020 11:28:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C3L1jObu"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BXd6olNI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3855E2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ys3vOXga6GpfrSeZYul73Wdho1Eq9K64CbwZDNYEZlk=; b=C3L1jObuyMVs8uM67G+Mcu+o6 XXk01XyMGNi8cBb6hc0dzrJLDwR9bjHLYck3Bvpo25119kVj0NxRsFFFkuUatavJQc5mJ9VvLPttK aAlbHi8RNW06FyYE8+FoboRu6sjvKga8ni8bUSZHjEZG1hEB6ysWRJgICnVI326PpPWMCfVDDRFVA Y1z8ZqFkgBB3LEbdht9MSdvLWpowrUNqu4b3Z8mmnT3ZdH0rlAV3iV49jrQArNdzan/OXLa8aXzoG wrzwVfYHVqmpF4mIZgScBtRhr51Xi4oQ/u2628k/f7mYG05Lr9I5lSCwqt6xyCXAffaJNdco26jBu f7b+J/lcw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1juwc7-0001ld-ML; Mon, 13 Jul 2020 11:27:15 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1juwc4-0001kK-1k for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2020 11:27:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594639631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NndF9MqDcvO4KNH3w4Ig8XfoceRFDUTb0+wABisiArU=; b=BXd6olNI6zoX1ALP1vULJuCE08hgRJRk3QR20dMdraOiUMganKLIfK8ALtSIyEvfDmMLSf mjnihropRLo48yohHhl+QjrTsPzhluTX9QnDpUXW8MuT+5lYSSkT6R5welZ66kksAW2yhD 4PHEjSlYo0LOCRWBTc66DzMG8MbLezU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-cOZPd6yhPm-hhkr9pLUSCg-1; Mon, 13 Jul 2020 07:27:07 -0400 X-MC-Unique: cOZPd6yhPm-hhkr9pLUSCg-1 Received: by mail-wr1-f72.google.com with SMTP id w4so17399776wrm.5 for ; Mon, 13 Jul 2020 04:27:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NndF9MqDcvO4KNH3w4Ig8XfoceRFDUTb0+wABisiArU=; b=geKzQ3xU7gf6JWIcKIcw8ZL1OUO5QvnDq1W6jPVeiLM2k/N2gcI9Xv++tZEYtgsQ4y w+XWxkQ6gsVBpaRZ8OYFukkqFHGcS7ULyByEQPbuFBHPqK9WHbcSfMMbinBX+vcQzIPn 7Su7Ebijt01KHz+QWiDurMUywz3eaXyMoMIei6F7nhN8QnI1jM6SmtTLofdaUO47jnIY NyJaFgLibV43n+/O+JuR42YOtHUvxiLSmwouae1Ds8R+kPePJz3+n0jt0BHApa/I6snl TtPrtUSSw48UH8b1YNTf7oJe9Dtru312aBlfb82fbrPR6OJ8VoDLqsKy/NGInrGqhCAe Lh7g== X-Gm-Message-State: AOAM532xIvjWAd7qLBpa1D3LnUYMJZ15z16VWeo2mW7a/D3O7S5wPrkf p8cnC7SXoVHTz1BgeeRO0I6WxjywZbGJsULJYF5eJYGsl/tlt/LwmpQ8fF1EJa5gXItH9tG/JTD AF4XXs8BC90SoWCSYRlicOD9mkZvseWNJzwM= X-Received: by 2002:adf:e40e:: with SMTP id g14mr85945105wrm.271.1594639626487; Mon, 13 Jul 2020 04:27:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoQoJFGLmA7IKeh1vfhF4LpR1itbcrQH3486CQtGPbzU10VTecZ0k8Yt5A6ZRHstGlY191xQ== X-Received: by 2002:adf:e40e:: with SMTP id g14mr85945083wrm.271.1594639626252; Mon, 13 Jul 2020 04:27:06 -0700 (PDT) Received: from redhat.com (bzq-79-180-10-140.red.bezeqint.net. [79.180.10.140]) by smtp.gmail.com with ESMTPSA id z132sm23730810wmb.21.2020.07.13.04.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 04:27:05 -0700 (PDT) Date: Mon, 13 Jul 2020 07:27:01 -0400 From: "Michael S. Tsirkin" To: Will Deacon Subject: Re: [PATCH v3 07/19] vhost: Remove redundant use of read_barrier_depends() barrier Message-ID: <20200713072618-mutt-send-email-mst@kernel.org> References: <20200710165203.31284-1-will@kernel.org> <20200710165203.31284-8-will@kernel.org> MIME-Version: 1.0 In-Reply-To: <20200710165203.31284-8-will@kernel.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200713_072712_239254_23EEF78F X-CRM114-Status: GOOD ( 24.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joel Fernandes , Mark Rutland , Marco Elver , Kees Cook , "Paul E. McKenney" , Peter Zijlstra , Catalin Marinas , Jason Wang , Nick Desaulniers , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Ivan Kokshaysky , linux-arm-kernel@lists.infradead.org, Sami Tolvanen , linux-alpha@vger.kernel.org, Alan Stern , Matt Turner , kernel-team@android.com, Boqun Feng , Arnd Bergmann , Richard Henderson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 10, 2020 at 05:51:51PM +0100, Will Deacon wrote: > Since commit 76ebbe78f739 ("locking/barriers: Add implicit > smp_read_barrier_depends() to READ_ONCE()"), there is no need to use > smp_read_barrier_depends() outside of the Alpha architecture code. > > Unfortunately, there is precisely _one_ user in the vhost code, and > there isn't an obvious READ_ONCE() access making the barrier > redundant. However, on closer inspection (thanks, Jason), it appears > that vring synchronisation between the producer and consumer occurs via > the 'avail_idx' field, which is followed up by an rmb() in > vhost_get_vq_desc(), making the read_barrier_depends() redundant on > Alpha. > > Jason says: > > | I'm also confused about the barrier here, basically in driver side > | we did: > | > | 1) allocate pages > | 2) store pages in indirect->addr > | 3) smp_wmb() > | 4) increase the avail idx (somehow a tail pointer of vring) > | > | in vhost we did: > | > | 1) read avail idx > | 2) smp_rmb() > | 3) read indirect->addr > | 4) read from indirect->addr > | > | It looks to me even the data dependency barrier is not necessary > | since we have rmb() which is sufficient for us to the correct > | indirect->addr and driver are not expected to do any writing to > | indirect->addr after avail idx is increased > > Remove the redundant barrier invocation. > > Suggested-by: Jason Wang > Acked-by: Paul E. McKenney > Signed-off-by: Will Deacon I agree Acked-by: Michael S. Tsirkin Pls merge with the rest of the patchset. > --- > drivers/vhost/vhost.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index d7b8df3edffc..74d135ee7e26 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -2092,11 +2092,6 @@ static int get_indirect(struct vhost_virtqueue *vq, > return ret; > } > iov_iter_init(&from, READ, vq->indirect, ret, len); > - > - /* We will use the result as an address to read from, so most > - * architectures only need a compiler barrier here. */ > - read_barrier_depends(); > - > count = len / sizeof desc; > /* Buffers are chained via a 16 bit next field, so > * we can have at most 2^16 of these. */ > -- > 2.27.0.383.g050319c2ae-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel