Received: by 10.223.176.5 with SMTP id f5csp1354335wra; Wed, 31 Jan 2018 05:18:24 -0800 (PST) X-Google-Smtp-Source: AH8x224QT0IsToYWVryXbFkmCBd9g8nOFF9WaZgNvCcxSmGoNLckcrnoEMz7Me9y0YCU7XY0ZMVo X-Received: by 10.98.152.90 with SMTP id q87mr33892573pfd.131.1517404704197; Wed, 31 Jan 2018 05:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517404704; cv=none; d=google.com; s=arc-20160816; b=HDea9LqUCJCyKASvBeKdSPZFKZ6/jtUFOi/av4T7dXzTkmIHmisxTlpKfHILrWkHr6 bcSMeg3qR4t8lDPcWTPEJqN0M2vXgTPs5yIpOeXOyfYB0INvQg0BNRPzBtSAQBE51uCU kmbODtoW9NYwbApKxyQ0NuquHGsVjFQfmnn7hAgbE6Fc3WPKB8kh9oB91SMv+2mz06Ah jpSUS5jaSm7k0YLCDtyx+nQNQt3bvEXEc1f2gbnuMWSuds3Mpy9m+LdQYk9IlMEq21sI Xo/yfJ1U4AtvwKScm5QXI73W0s5ahtlKISYTlLxazbyem4Ze+yfmy/bKJeH/qoKnq4bN NUEQ== 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:arc-authentication-results; bh=wBljsQgieKJubIVDtvNDaJQ1mrXvkor+kPh2mToc+S0=; b=QdEogSm8PuMdM3VOef3wBuqeshgLXuhSnPA3HDy1hvYKir0qBjFBcx30Ca2Ti4yM0g P8s8vShzSeJJN+ceV6eAXkCOKPGNfnbPmdhInOnMAMyk2Ly1YiHEGQjU0Tj0iJqlaaFP vBEk8aAib2im1NfKE09gGsUIc2rMlWY+L1Wh/1a1qriGnszWVR/htkqIE0NfMxo1ablX TCP9sVrw+d1GMkHceJKFBiXqxZHPA1QK0tNtaHj1Qj4vpeEiS9jPw1+b/Ljo9+S4UBFl LPa0qCiFW6sWgLFqwayPBSog4+nfKcZ4y+lMM0MmbPLK8O+Wb4un1V/F0u9ZwCPxTV8a KpnA== 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 h7si3514226pgv.172.2018.01.31.05.18.09; Wed, 31 Jan 2018 05:18:24 -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 S1753384AbeAaNRi (ORCPT + 99 others); Wed, 31 Jan 2018 08:17:38 -0500 Received: from foss.arm.com ([217.140.101.70]:38010 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752436AbeAaNRh (ORCPT ); Wed, 31 Jan 2018 08:17:37 -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 A2C9180D; Wed, 31 Jan 2018 05:17:36 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 737CE3F24D; Wed, 31 Jan 2018 05:17:36 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 0FFAE1AE10C2; Wed, 31 Jan 2018 13:17:37 +0000 (GMT) Date: Wed, 31 Jan 2018 13:17:37 +0000 From: Will Deacon To: Peter Zijlstra Cc: Stafford Horne , Paul McKenney , Jonas Bonn , Stefan Kristiansson , David Howells , Arnd Bergmann , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: asm-generic: Disallow no-op mb() for SMP systems Message-ID: <20180131131737.GA5097@arm.com> References: <20180131130034.GR2269@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180131130034.GR2269@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 31, 2018 at 02:00:34PM +0100, Peter Zijlstra wrote: > > While looking through the qspinlock users, I stumbled upon openrisc and > being curious, I wanted to have a look at its memory model. > > To my surprise it doesn't have asm/barrier.h. It does however support > SMP. This lead me to wonder why it would compile, turns out we provide a > no-op mb() if the architecture does not provide one. > > With the obvious exception of Sequentially Consistent SMP systems, this > is terribly broken. And seeing how SC SMP is really rather unusual (and > unlikely), change the asm-generic/barrier.h to not provide this. > > This _will_ break openrisc builds, they had better clarify their > position by writing their own barrier.h with a comment in. > > Signed-off-by: Peter Zijlstra (Intel) > --- > include/asm-generic/barrier.h | 6 ++++++ > 1 file changed, 6 insertions(+) Acked-by: Will Deacon One comment below... > diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h > index fe297b599b0a..7a10748615ff 100644 > --- a/include/asm-generic/barrier.h > +++ b/include/asm-generic/barrier.h > @@ -30,9 +30,15 @@ > * Fall back to compiler barriers if nothing better is provided. > */ > > +#ifndef CONFIG_SMP > +/* > + * If your SMP architecture really is Sequentially Consistent, you get > + * barrier.h to write a nice big comment about it. > + */ I couldn't find any documentation about the openrisc memory model other than: https://openrisc.io/or1k.html#__RefHeading__504775_595890882 which talks about the WOM bit in the page table being used to select a weak memory model for the page being mapped as opposed to the strong memory model. Furthermore, the only fence instruction (l.msync) is permitted to be a NOP for the strong model, which implies that the strong model is SC and things like write buffers are forbidden. However, Google suggests that there are implementations of openrisc with write buffers so I'm not sure I understand what's going on here (maybe they force WOM and/or l.msync isn't actually a NOP?) Will