From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id F37657D062 for ; Mon, 2 Jul 2018 12:50:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751416AbeGBMu1 (ORCPT ); Mon, 2 Jul 2018 08:50:27 -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-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@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. -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html