Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7919020imm; Thu, 28 Jun 2018 11:23:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKN387eE2EkB1M/LfhRYwZYD1zBn3BbcXez2wrN95Iv4RyTyD0WbYi9pKapwyvx/bE5q4fe X-Received: by 2002:a17:902:8a8c:: with SMTP id p12-v6mr11632452plo.212.1530210222473; Thu, 28 Jun 2018 11:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530210222; cv=none; d=google.com; s=arc-20160816; b=bpJvO+/juonohZhi0ZaAnfaboTqsYqzNBLsgDmP/We1sWteGwUt209u+KpuXuIPtws mNdDMXjO/ZwgEjRa1fKnB7W7LoppSEpN8hMEvhigkjACfn8kBRS726Ra12kzJnYZmgVX allNOxOKLzwg5wLJFgtxm79AZ2/wgT0+LFajxrts5DwV+xxMThppeqeYAzsPx6a+4n40 4RsZRDas/lsSmDE/yJqkcqZclG31aAxOH4T0icHqlG55k0aGyh94JZLADHVDi2RlHRom d2rL/sDLbM1TuDElTloTu1Qu5tMdiAOt71tf7ryd+Mww/9X5fpbN91Tw5NtxPJdXeGRJ +23g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=J1sqDgdl8sPhDG8Rf6xrrfwapSUI9sWidWr+/ZgRQgU=; b=XAOw7Mv8x5yM9djRc3SENMcrrEY7nM/DpiVq141BAebRJgSZFQlWivwB3ooCHs9LGY PTm9PRzRSHI/v2WwrRnXbnlgcAS5ii0ZO/omkgomrq+6rpI5GYhIGn2bNnDXP2EpV5EP YQ06cO/bkZ9cThUEd+BUK46zsoxJJx4IlOyvi7VYFlN3f8MwatqTKol+kIc69sxv/39c +eJpWEr+RLaz3ulKP5VMC0hGKs9aNlBJ3NQa0/HYdImiltD/PulhPAyLzNu3r4KUBMFh 898t1gJ1geOYkeFDuISHt7AgCYlPtZNRP9YjchBAu52eqXXKAroRWP8fV0WUX+9QoiXN 6nWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="m4lXN/tf"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2-v6si7066864plr.494.2018.06.28.11.23.28; Thu, 28 Jun 2018 11:23:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="m4lXN/tf"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934950AbeF1OEG (ORCPT + 99 others); Thu, 28 Jun 2018 10:04:06 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44642 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934483AbeF1OEF (ORCPT ); Thu, 28 Jun 2018 10:04:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J1sqDgdl8sPhDG8Rf6xrrfwapSUI9sWidWr+/ZgRQgU=; b=m4lXN/tfz1j+nY00ZkDuEz1qz gey4Pst0B3RfXuPABEg/U14STuHLtoBhn+8J79By4ZxkgvTdowmZY2z6C8cD1YJYytbrBaeXTOa0Y tnIauhGyulpLrCUg+zOZHzkeVaKYwlgmPDm3Am6KVhUsjYLQDPqTARTfPHM+53ZeU9m4frz5qaaE6 p+zv0XlvjcNZ5hpJliPwUww4qXPgutF7tTuMOPD3Jc+2JEFs4Jwc3QP0nnvyGKMByE4KrOnMfV1Lt 4Zn/VjrDVe9AeyfXdYHqZxIZraOEB1ZQGmFcgZNL90lWdC/4Qi61UYXK5oH9O/WmuA4ZHpefgIeRI tbGRGQHyg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYXWg-0002hP-T0; Thu, 28 Jun 2018 14:03:58 +0000 Date: Thu, 28 Jun 2018 07:03:58 -0700 From: Matthew Wilcox To: Dominique Martinet Cc: v9fs-developer@lists.sourceforge.net, Latchesar Ionkov , Eric Van Hensbergen , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Ron Minnich Subject: Re: [V9fs-developer] [PATCH 4/6] 9p: Remove an unnecessary memory barrier Message-ID: <20180628140358.GG7646@bombadil.infradead.org> References: <20180628132629.3148-1-willy@infradead.org> <20180628132629.3148-5-willy@infradead.org> <20180628134029.GA24673@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180628134029.GA24673@nautica> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 03:40:29PM +0200, Dominique Martinet wrote: > Matthew Wilcox wrote on Thu, Jun 28, 2018: > > --- a/net/9p/client.c > > +++ b/net/9p/client.c > > @@ -436,13 +436,9 @@ void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status) > > { > > p9_debug(P9_DEBUG_MUX, " tag %d\n", req->tc->tag); > > > > - /* > > - * This barrier is needed to make sure any change made to req before > > - * the other thread wakes up will indeed be seen by the waiting side. > > - */ > > - smp_wmb(); > > req->status = status; > > > > + /* wake_up is an implicit write memory barrier */ > > Nope. > Please note the wmb is _before_ setting status, basically it protects > from cpu optimizations where status could be set before other fields, > then other core opportunistically checking and finding status is good so > other thread continuing. > > I could only reproduce this bug with infiniband network, but it is very > definitely needed. Here is the commit message of when I added that barrier: > ----- > 9P: Add memory barriers to protect request fields over cb/rpc threads handoff > > We need barriers to guarantee this pattern works as intended: > [w] req->rc, 1 [r] req->status, 1 > wmb rmb > [w] req->status, 1 [r] req->rc > > Where the wmb ensures that rc gets written before status, > and the rmb ensures that if you observe status == 1, rc is the new value. > ----- > > It might need an update to the comment though, if you thought about > removing it... Ah! Yes, that situation is different from what the comment documents. How about this? /* * This barrier is needed to make sure any change made to req before - * the other thread wakes up will indeed be seen by the waiting side. + * the status change is visible to another thread */