Received: by 10.223.176.5 with SMTP id f5csp2679890wra; Thu, 1 Feb 2018 04:28:38 -0800 (PST) X-Google-Smtp-Source: AH8x227jaApjdA5k6kObSNJ/XYS78+VE2T08qMjh7HyBR68mAIguQ1XW/iQ/7IGF/25f+9EfrLHT X-Received: by 2002:a17:902:860a:: with SMTP id f10-v6mr31257336plo.292.1517488117998; Thu, 01 Feb 2018 04:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517488117; cv=none; d=google.com; s=arc-20160816; b=LhO9VNJcwm9c4MHveJIDv5IiFwNGXzxIZqGHzbR5+mjurdWeY9RLT32V0iXHEkhqCc JClJOs2diA5uldtZ7Eoo+lAdIsGWg7MoUxZRhXC1rnk0WtytAT7TyaDQ2ZoHSmWgo+Eg /CD3cxTHNgIfwGGoN2SjJyJdPlaxcxFd47oc/F+71zoXBnIs3wyIsbNEBrzPe5MZKXYR 8sXtENeGe/f/wNAr/AFmFYB7SEUF12+/vPC6AFxSrjqkFz04eDUh1FtOl6US7n8GUvum TfAqKfBhy1y7m+ccUaKEb2nD5LnZelL/p7L4FkwnvgaOr8c2O47A7BRFlXKaDRMEeInM 9Bwg== 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=G0zLuW7bZDnYWE7qeRWbOQnRDnXqHAKm+UFFwoVIuSw=; b=bGWeX0sg/++CnF4ZYp6HlI5h2RaB/5kGHWSl9e9xFvwk0yWQQV9CfrU19qSdmouHYG YJ7NYbPzkj+bMYC4O+sBaLq6EFl6fzteD1UpncCUlO/5Pn7ThmU0uJ6vKi07oOFxsvFc DqSt4I0yHUwznB76hx9aLdWgvS1HlHb/zrxsAj5rTNaBye4u0QOLIZ8lOjls++YaxJaq mO4evE05sXKjjHnNeBIwV221jx5wIG1+vhHKaAlFVkKoMC8oISp4GCO5DFm6LaiWnWDI 91IzslfpdmWrYiinHNHypfm49pNqzusASxPHU3QjZ2Ho2Ab/XXT7KKnOpWpk3DIisA0m peRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=srlGZbKk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2-v6si1024695plm.757.2018.02.01.04.28.23; Thu, 01 Feb 2018 04:28:37 -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=pass header.i=@gmail.com header.s=20161025 header.b=srlGZbKk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752453AbeBAM14 (ORCPT + 99 others); Thu, 1 Feb 2018 07:27:56 -0500 Received: from mail-pl0-f53.google.com ([209.85.160.53]:35170 "EHLO mail-pl0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752030AbeBAM1x (ORCPT ); Thu, 1 Feb 2018 07:27:53 -0500 Received: by mail-pl0-f53.google.com with SMTP id j19so3385176pll.2 for ; Thu, 01 Feb 2018 04:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=G0zLuW7bZDnYWE7qeRWbOQnRDnXqHAKm+UFFwoVIuSw=; b=srlGZbKkb66DJuG5hgDrWL3CVRvu97oAc2tvGnnLrW9uJb4ge/hYFyqpgR5qbvXKXX vSguB1rdqduR9k3EwbXtKDFzoAT15ccDyBRSlyhuGg+URvMI3bE/hmZoG4JAb8mH6/Sv 9ss8B8rcMXdabwdj7yfRoixdBdx+RAAl4BHfzsz+FPtnt3PBAVcYBUaZ8pI+4cDfIe+0 FjvSzTnnbeY2EEYmBbsStefmoT/1cNNOCgZiSnDQqFifRsmeMnd2gXwiBamulzTrwleC gVfKh0BwizCPjMFCA0RbgEHZK2FEvaycGfFdp9/efj5gW3h/Q4H3cjzxkP3qsnl/JJ2e AHRQ== 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:user-agent; bh=G0zLuW7bZDnYWE7qeRWbOQnRDnXqHAKm+UFFwoVIuSw=; b=ChWBbOhg/FIzH3VSUevuckaL62myYZFe4a4zidsp29+ALgvD4LJaNnqgHwc9wG4str fn/5bV1AcbFgPQHT5MtwuN5Q5kY2S/egzMJSzrQy8voshltxqHH5w6J1qBSKoeo48ERR OrKM9cOd2pNWNeTyfk8eQB8DE/4duZuRfoct52E+biYE28JgCDtf3yGClL+mzL2JADuk k+H1H86MYp93ftWUhGRPl5RhDTfbmXwihGPHOfMIx2CGG6NsEDMQ83iUzJtoxUznmfo6 b9YqA+zP4edB0J6AFCZrFnjgG0Qjg1S2kDV+BlPCkN1UXhMYrpJEs8AZtoeoA7R8d43z JY6g== X-Gm-Message-State: AKwxytd/u72Y0KH0fZB27dfnRkJypwc+sLg7kPQY+/xNUcwW16iERwMH +ydsHpGsNsOG1yNrPCyipyHtIZasbj8= X-Received: by 2002:a17:902:6c:: with SMTP id 99-v6mr29800980pla.409.1517488072789; Thu, 01 Feb 2018 04:27:52 -0800 (PST) Received: from localhost (g151.124-44-6.ppp.wakwak.ne.jp. [124.44.6.151]) by smtp.gmail.com with ESMTPSA id n6sm23160531pgd.13.2018.02.01.04.27.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Feb 2018 04:27:52 -0800 (PST) Date: Thu, 1 Feb 2018 21:27:50 +0900 From: Stafford Horne To: Peter Zijlstra Cc: Will Deacon , 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: <20180201122750.GE30895@lianli.shorne-pla.net> References: <20180131130034.GR2269@hirez.programming.kicks-ass.net> <20180131131737.GA5097@arm.com> <20180131132610.GT2269@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180131132610.GT2269@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.1 (2017-09-22) 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:26:10PM +0100, Peter Zijlstra wrote: > 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'. Hello, I tried to clarify some of this in the spec v1.2 [0] which help formalize some of the techniques we used for the SMP implementation. Its probably not perfect, but I added a section "10. Multicore support" and tried to clarify some things in section 7 on Atomicity. But it seems I dont cover exactly what are are mentioning here. In general: 1 Secondary cores have memory snooping enabled meaning that any write to a cached address will cause the cache line to be invalidated. 2 l.swa (store atomic word) implies a store buffer flush. 3 l.msync is used to flush the store buffer Also, during the IPI controller review [1] Marc Z asked many similar questions. I believe he was ok in the end. Anyway, Thanks for thanks for spotting the issue here. For some reason I remember we did have an l.msync for our mb(). Let me think about and test out this patch (and the fix to actually define mb) to see if anything comes up. Also, I haven't seen any implementations that use WOM. Stefan might know better. [0] https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.2-rev0.pdf [1] https://lkml.org/lkml/2017/9/14/487 -Stafford