Received: by 10.223.176.5 with SMTP id f5csp1366284wra; Wed, 31 Jan 2018 05:29:12 -0800 (PST) X-Google-Smtp-Source: AH8x226/FMBiIBE/vgKu+twzCuSQnAGUcsCXKbuaxe9OXLNakB8bbdOz+gFBh3IGsxvt3HpslzWN X-Received: by 10.98.41.68 with SMTP id p65mr11677512pfp.86.1517405352782; Wed, 31 Jan 2018 05:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517405352; cv=none; d=google.com; s=arc-20160816; b=fM6I23ZK4sjvyeyan1scazEEfvSku17WOT9Ups5psQvaR9ltVmtpwVgL9YVJSYvPkY 8sdsp9E9V+Ng+PorXyHHAw0EVUYbuG+7PZN0I/o64YMbP+p7ApQVAXYmQGnEVWKFX+9A XRTFvI6VQ7XsS78m3z4VkD2RZ5yQeZ7kMHNNV16O+fYy2WSdQMS79ukOFHkTYWMvl1Sj +jr8Cg78XQ5l6w2BZC0O8VgT1S+nsmE0urnGgXXKjKjnS64iDUrstE7KB3EU4BiOWXAh 6dI7jwDVFBRs+GzxyGJ9JlzgnUHh+fNYOpyAAqOXcAnK5rqPgs/iNkYpkr6KBq01+/Pu fnLA== 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=2pD3jlslqTXER+e7sD3goyyVAP2jzXAWhW0+hvILXzI=; b=egSsP4W8c/D4bgMMt+JaopfTGjSnqMRK5LSZi2pvONpvCD9UXtZPMV1MWsBV/72WUm ShvFSyJjEMbqauMiMv7al+/AbJtobr4y06ZzYj9IYrrhpzm0nQN3jJRzfY2OwIv/sYeJ KJ9U1ZBM1OFCvFIgzkiMZUdaaMgM7OpJf3TFsKwBQaUtTYhzx67WoZ8BRBX6Ju0hxIKt QwHi1oDFhnYqjLwbb9JomWRHuLRdTj3Jgz0TvSigiGZmftOs30viBf6MS0KNYLMb32kq pt4mEPVGoDcnPpon7rFonG3azenrFt3WnzFl5UFE0quLJmWj1LFowrK3O5Jc0WziZPZV sp3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fn6U5uR+; 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 t2si11133989pgc.747.2018.01.31.05.28.58; Wed, 31 Jan 2018 05:29:12 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fn6U5uR+; 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 S1753496AbeAaN0Z (ORCPT + 99 others); Wed, 31 Jan 2018 08:26:25 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:57453 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751587AbeAaN0X (ORCPT ); Wed, 31 Jan 2018 08:26:23 -0500 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=2pD3jlslqTXER+e7sD3goyyVAP2jzXAWhW0+hvILXzI=; b=fn6U5uR+NOS9j0J+LbZO+9dXV LYLPPNOFtt+mG6V49tMe6Iz9TcL/I+DDBirRX2UJ6GiSVZrNwDrED5ZOxPU+R70m8Dpshwdh2T8ar YV1nJUJiLLR5cSMo2vxfXGsfZHBVQ9yBevMVYExwr3wI6UkAUfc8/SFiKTiIJB/Q/PHPcOy6eHW0t MVhP5megKgeKdFSYmKX4Bn7QOGNhEq/yuLexTh9aIDIcb/akIJCT4JYkaW1oD5pQ+UaHDqi7nx7t2 Om8lpUeAkk3mcczRqaNODAerTV0/O9ZOevg30Fb+/MrLrZYKMYEUt4yyPT0bicwJnHU4Qdm23Snla N5o5WTRtQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1egsP0-0000fl-2u; Wed, 31 Jan 2018 13:26:14 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EA9502029F9F9; Wed, 31 Jan 2018 14:26:10 +0100 (CET) Date: Wed, 31 Jan 2018 14:26:10 +0100 From: Peter Zijlstra To: Will Deacon 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: <20180131132610.GT2269@hirez.programming.kicks-ass.net> References: <20180131130034.GR2269@hirez.programming.kicks-ass.net> <20180131131737.GA5097@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180131131737.GA5097@arm.com> 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 Wed, Jan 31, 2018 at 01:17:37PM +0000, Will Deacon wrote: > 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?) Right, so by that document they need: #define mb() asm volatile ("l.msync":::"memory) but yes, that document raises more questions than it answers. It would be very good to get clarification on how strong their strong model really is. SMP without store buffers is, as I wrote above, 'unusual'.