Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2723803imj; Mon, 11 Feb 2019 07:32:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYJbzhV5dflAhqtMHYBfSPLx740tvgrxt3eyIiqLfhvRVPP3eP/zpd0hgcc7WuiDZgM/xCj X-Received: by 2002:a63:7044:: with SMTP id a4mr33538212pgn.359.1549899135414; Mon, 11 Feb 2019 07:32:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899135; cv=none; d=google.com; s=arc-20160816; b=kkF0GISNcd+NDljylRNVMYIRx4ZmRjeUJLxkbXkoEVwdJhrVhzrxZoWBQ+qjhL0dz/ K7DxF+pJkhulOC4sIQeD0UfeypX25JFRwueIk7+QF6KM3hZbWUxofcMu6gcS4Ych7I3i KiVDP5z5YV86++rk72/nwUe6HU+DASIzgAG7jxSE5bODa5wqSal+jX0cDhPTcXGOWIx8 II8fq4JzagO0rFSpmmSCNJ1FPgO0w6XNwbHxzRlX+k2HMzK0HTeeVk5AoRSW3+0NqQy3 R7/QqdgwWAKnZubIswiuOVmNMWinKwl93jNgZ8T/I3hHpgPWRLFbmj4Au2SiKMvbmk/K 55IA== 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; bh=KBoQsR8ywJixmygxBnlZySTs2AKtymyq6PfRggfcb+Y=; b=wdN/G/XkzGsBkFxHa29TMw1U7BxKnzniW+0EaX66NJLXqnhZVrmUhA1NsIEQpMCadb I0fl5Pfck2YmlNnFYW7uM2JzhzNOglmG5M+BSZyWg5I5uAOKr3NNbWXebnmS311U0Nb8 q21M1+CJRG9dcuoqsC0j1p5tDcQr5kPv0TSbSmfj7EvseuNTK0S8nLtshRxf/eQqI5Qm ff9BQLL3zEIO/pWUMJiURW8fbJ4pUd49abl9DptVsOx7s8GGP/UQN45KO7xkvn/UV3IQ rPblBPnIloGDYcHSTB8R83ll3u+m088xBiB3novpQZ43wCKXr8IGsx1Fvsy0b2booIdI auxQ== ARC-Authentication-Results: i=1; mx.google.com; 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 59si10761015ple.291.2019.02.11.07.31.45; Mon, 11 Feb 2019 07:32:15 -0800 (PST) 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; 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 S2390183AbfBKPay (ORCPT + 99 others); Mon, 11 Feb 2019 10:30:54 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51776 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389928AbfBKPat (ORCPT ); Mon, 11 Feb 2019 10:30:49 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B9FEB15AD; Mon, 11 Feb 2019 07:30:48 -0800 (PST) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E99E63F738; Mon, 11 Feb 2019 07:30:45 -0800 (PST) Date: Mon, 11 Feb 2019 15:30:43 +0000 From: Will Deacon To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mingo@kernel.org, stern@rowland.harvard.edu, parri.andrea@gmail.com, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, willy@infradead.org, Benjamin Herrenschmidt , Arnd Bergmann , David Laight , linux-doc@vger.kernel.org Subject: Re: [PATCH RFC LKMM 5/7] docs/memory-barriers.txt: Enforce heavy ordering for port I/O accesses Message-ID: <20190211153043.GC32385@fuggles.cambridge.arm.com> References: <20190109210706.GA27268@linux.ibm.com> <20190109210748.29074-5-paulmck@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190109210748.29074-5-paulmck@linux.ibm.com> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On Wed, Jan 09, 2019 at 01:07:46PM -0800, Paul E. McKenney wrote: > From: Will Deacon > > David Laight explains: > > | A long time ago there was a document from Intel that said that > | inb/outb weren't necessarily synchronised wrt memory accesses. > | (Might be P-pro era). However no processors actually behaved that > | way and more recent docs say that inb/outb are fully ordered. > > This also reflects the situation on other architectures, the the port > accessor macros tend to be implemented in terms of readX/writeX. > > Update Documentation/memory-barriers.txt to reflect reality. > > Cc: Benjamin Herrenschmidt > Cc: Arnd Bergmann > Cc: David Laight > Cc: Alan Stern > Cc: Peter Zijlstra > Cc: > Cc: > Cc: > Signed-off-by: Will Deacon > Signed-off-by: Paul E. McKenney > --- > Documentation/memory-barriers.txt | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt > index 1c22b21ae922..a70104e2a087 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -2619,10 +2619,8 @@ functions: > intermediary bridges (such as the PCI host bridge) may not fully honour > that. > > - They are guaranteed to be fully ordered with respect to each other. > - > - They are not guaranteed to be fully ordered with respect to other types of > - memory and I/O operation. > + They are guaranteed to be fully ordered with respect to each other and > + also with respect to other types of memory and I/O operation. Given the lack of Intel response here, I went away to do some digging. As evidenced by the commit message, there is certainly an understanding amongst some developers that inX/outX() are strongly ordered on x86 and this was re-enforced by Linus in March last year: https://www.mail-archive.com/linuxppc-dev@lists.ozlabs.org/msg131212.html It was this information on which I based my patch. The Intel SDM is not quite as assertive in its claims. However, it has also occurred to me that this patch is actually missing the point. memory-barriers.txt should be documenting the *Linux* memory model, not the x86 one, and so the port accessors should be defined to have the same ordering semantics as the MMIO accessors. If this wasn't the case, then macros such as ioreadX() and iowriteX() would be unusable in portable driver code. The inX/outX implementation in asm-generic would also be bogus, despite being widely used. Unfortunately, the whole "KERNEL I/O BARRIER EFFECTS" section in memory-barriers.txt is vague, x86-centric and out of date. I think the best way forward is for me to propose a rewrite of that section, based on the work I did putting together my I/O ordering talk at ELCE last year. That, at least, will allow us to start off with a portable semantics rather than trying to infer the details from CPU manuals. So please drop this for now, and I'll send out a more involved RFC patch shortly with the usual suspects on cc. Cheers, Will