Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3797225imm; Mon, 2 Jul 2018 05:53:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWPCASUYTwQ7KLfdTj5d+glGMDurTNfy8swg/2zRKqgbq1IFlisXp661sWHHz9T4BzUmBv X-Received: by 2002:a17:902:b949:: with SMTP id h9-v6mr25599773pls.321.1530535987845; Mon, 02 Jul 2018 05:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530535987; cv=none; d=google.com; s=arc-20160816; b=K1ty7Rk+Gau5qeaUtsL1kj2OGbqCmMAbOWlj30USb3ZKjAWf6j9yshGbXyY2dJbxvO HhTaX2YH+zS9c3Ucm8NcDecVEArzhNuILKnGO2BBPqzsSPUP1/NxDEc/1FQBqJU4ZJmI CxyMUA1v2PfoRsW4qfGtybhZpsbz5/L32uHv+fUppQw4jBo4hWhEeNa9uWb2p/f3cfJE 7D51LyI7MQguSDavHBmKVdz6OHyJN0DH1bke0sBu6Y4Dr4byx65sp5LcGzMM/WnWrE+m +BHcA3AiMOAZdEAmXb1YwX1+LHIlIelUDUtPBmjVmkMMFajDGKnGi3zs3d1oshuZKGYV NmSw== 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=BGq8aT8BlmdTdtvkLSydij6UmfiMSQjkCahEZ4njUTg=; b=Z9sUbHMcxR2i1Cuqa19pIqSepyU3BNoef4EMqkt7+8ZEkWJR96bk4qeQWzYfzNHDYi qkMAZAD3y9thVOFZcu6a2gTFg2ZyCL2pnssoNW9g5emrgaVeHL64XpDAeVy44ilC6eN2 I0cVcxUDgxXfQt/B25FMUrVfRJ2bH9H+308fKOV3fuotAnTbZyo5Q+PDhmupsuWwqFaz qZ/gUs0oKT5cBGrGNSv8SBP2ynp+LguBIdeDlD/nnX49cSTZRc5dAq7POEx42RILVLJV P1W7/yMleHNuf59JRqd/JbUJjO8Ht+stZvmLPhRLbL9GwGrGddJV2rOSUoMwWnUbHyIL zVxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="bYcv/gJN"; 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 r39-v6si15933815pld.83.2018.07.02.05.52.53; Mon, 02 Jul 2018 05:53:07 -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="bYcv/gJN"; 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 S1752229AbeGBMu2 (ORCPT + 99 others); Mon, 2 Jul 2018 08:50:28 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41392 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752049AbeGBMu0 (ORCPT ); Mon, 2 Jul 2018 08:50:26 -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=BGq8aT8BlmdTdtvkLSydij6UmfiMSQjkCahEZ4njUTg=; b=bYcv/gJNLhdLg8K31m6mEFnwq /IfhkIemQfTqBQ+QG20Pmye8TaGmBBPDA4t1Yb+hDL4yNRnte+7fsOM2JeA5dXG4JEVI279Ckkc5F HTqBPFVt9IrbvZAM9PmMdLqJ8LCUJ1J+d3uXtokkszlll2wxKbmAzOCgpf/e0uSfQepChR+KvPd4M aykQtV3HgmBSGD6mwFIQxRLt2mFvb17ffiZsz73dDU7kTS2Oxmio65ZskYDvRiICDZCFNkw3/RqAB tEzTfKRhJHKLML84TPfkLYbkw5tQeqNfQ3HraQlKA/KbCVJn4hvYp89qYLHR+ekj6MFJ+UmYPmnGd wUXJspSww==; 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.90_1 #2 (Red Hat Linux)) id 1fZyHN-00069F-Gs; Mon, 02 Jul 2018 12:50:05 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D38A62029F1D9; Mon, 2 Jul 2018 14:50:03 +0200 (CEST) Date: Mon, 2 Jul 2018 14:50:03 +0200 From: Peter Zijlstra To: Andrea Parri Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Ingo Molnar , Will Deacon , Alan Stern , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E . McKenney" , Akira Yokosawa , Daniel Lustig , Jonathan Corbet , Randy Dunlap Subject: Re: [PATCH 2/3] locking: Clarify requirements for smp_mb__after_spinlock() Message-ID: <20180702125003.GO2494@hirez.programming.kicks-ass.net> References: <1530182480-13205-1-git-send-email-andrea.parri@amarulasolutions.com> <1530182480-13205-3-git-send-email-andrea.parri@amarulasolutions.com> <20180628150550.GI2494@hirez.programming.kicks-ass.net> <20180628173045.GA4975@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180628173045.GA4975@andrea> User-Agent: Mutt/1.10.0 (2018-05-17) 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 07:30:45PM +0200, Andrea Parri wrote: > On Thu, Jun 28, 2018 at 05:05:50PM +0200, Peter Zijlstra wrote: > > On Thu, Jun 28, 2018 at 12:41:19PM +0200, Andrea Parri wrote: > > > - * This barrier must provide two things: > > > - * > > > - * - it must guarantee a STORE before the spin_lock() is ordered against a > > > - * LOAD after it, see the comments at its two usage sites. > > > - * > > > - * - it must ensure the critical section is RCsc. > > > - * > > > - * The latter is important for cases where we observe values written by other > > > - * CPUs in spin-loops, without barriers, while being subject to scheduling. > > > - * > > > - * CPU0 CPU1 CPU2 > > > - * > > > - * for (;;) { > > > - * if (READ_ONCE(X)) > > > - * break; > > > - * } > > > - * X=1 > > > - * > > > - * > > > - * r = X; > > > - * > > > - * without transitivity it could be that CPU1 observes X!=0 breaks the loop, > > > - * we get migrated and CPU2 sees X==0. > > > > Please don't remove that; that explains _why_ we need a full memory > > barrier here. > > Peter: > > Both you and Boqun stated that the above snippet is "bad": > > http://lkml.kernel.org/r/20180312085646.GE4064@hirez.programming.kicks-ass.net > > and I do agree with your assessment! ;-) Right.. > I've no objection to keep that comment (together with the > "clarification" suggested in this patch) _once_ replaced > that snippet with something else (say, with the snippet > Boqun suggested in: > > http://lkml.kernel.org/r/20180312085600.aczjkpn73axzs2sb@tardis ): > > is this what you mean? Yes. I much prefer to explain the why for rule than to just state them.