Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7986627imm; Thu, 28 Jun 2018 12:34:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJs7GzFChYREjooXFTn8EmuA2YcFoOrSUkFLQ+wa5oWTF0vHgaHwgqv0vmefyAd+RUPbBfM X-Received: by 2002:a17:902:2864:: with SMTP id e91-v6mr11498937plb.240.1530214483299; Thu, 28 Jun 2018 12:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530214483; cv=none; d=google.com; s=arc-20160816; b=LtP0r5ar9O6rSB3FbnHUsP2FKaN+N3aMCbShnWnnwkn1dliyN3ky33g7Tf4RaOkMLR kagI98kB73R6LdbWzqRsl0YlvIaMd2Rj2l2ukSQePEQILp55Way2/8RBfDe3IzhaQTA6 a+bGLiGad/zvFex9+ppJIVJRy+GbMz7dstdQj1nj3BtKZ3iFxdh1iFS1aZARaQ+lLqZB 2QudA5jNOtJmuU2usJOZUU8xFYoPRX7PYtOhg24gwcoBhqZ30fim7dK3Z7azYKT7Z03j 6nw3Zn0V9baQ8OUrfky9ftCJBPJFHvEmP5VfvZc3i3c07pXFKD6+Gejp27YXKQe9l0cQ xo8Q== 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=A0QHU8mL+6CDYRZhCz74GYSF4Kf0iPJGJzoqxFNfZlw=; b=TaNM9ocrJivN2uV2DDWJCOOBnqb2nG2aYBTLhDzK4/Kho2o6PR0aeQQkxGdGImpfrt 6I1RvjbhMgFxr/3prkodtNrQzn5STkvak0duzrK05G9MLkc8B2nsHkJGCMXsCO+u70CC SBmB5NZ/qalNHZDqAd6sg4o7Gxvm8SLUEU1mbMxpLtuyRXBsQ/qnDqQxfl9yC5blNn2s dsXE/ZQTjwoqegzawIKBt7ItbPi+lfqVrfyXPjcTfEi0zpiZxR6fWK4R4LFd+yrsQBcc gRt/PejN/LCUO7GsS1NCSG+I1IWGPGa1GHfF9H1keesw/AjE4A02i656SzUZamSrc4d4 ex+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BDjiTO1b; 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 bc4-v6si6871257plb.254.2018.06.28.12.34.28; Thu, 28 Jun 2018 12:34:43 -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=pass header.i=@amarulasolutions.com header.s=google header.b=BDjiTO1b; 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 S935159AbeF1Ra4 (ORCPT + 99 others); Thu, 28 Jun 2018 13:30:56 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51367 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934931AbeF1Ray (ORCPT ); Thu, 28 Jun 2018 13:30:54 -0400 Received: by mail-wm0-f67.google.com with SMTP id w137-v6so10625447wmw.1 for ; Thu, 28 Jun 2018 10:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=A0QHU8mL+6CDYRZhCz74GYSF4Kf0iPJGJzoqxFNfZlw=; b=BDjiTO1b2tBcu4jRtIm4VSmC817Y24sAlw1sNJYeV6hmm1wMHuS3QAKD2prIayS9VF xfcQn30TnJR8xvCc9eHLZzZ2QaYw/fDH0uXq5S8CPevH1UP1Jlk2d/reV6qt0VwHZGGF Ck3aUnliC6nytjxNDL9MCZJf6/VUHxpPy6EMU= 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=A0QHU8mL+6CDYRZhCz74GYSF4Kf0iPJGJzoqxFNfZlw=; b=gHTz+mm8WTY/Ey0KmOPbiQOqsjOPZuZXN7aqBkv/f+yD9R2i2+IPnKuqTYWvON7MQO l01Ip7oXumna7iN2PsBhAI/6CsAXC+b4zYqy51bpo/6ZQdXh1WxStX6dSvaK9vUhTlCO XYPNB4c4zc1sZZ6tcHhppkrM7JXulMV3+QuHKS8kD207FuM5pQrudt2hMODnyVl6HR9M H2uceSRO6h3wHDGWVH9PbuK9oKHHQHgEHSpI6pT8gXSnSTdFzspxOqa91L5kuJg63ZYy LmZnyLAcOplmkJToljfynff1jhKbR3Imvb7A0DIUzfAhxgCBzngS6KcQ1yQgp4ZMluBH B8Ug== X-Gm-Message-State: APt69E3xG5PvlAY2T9qvsG5hgruBGdXfDm5lkCRXieZUdZ0oJF+6bvY/ SvRcuXbj5rGc+kdFyNIt9ZDy9Q== X-Received: by 2002:a7b:c058:: with SMTP id u24-v6mr9036613wmc.136.1530207052957; Thu, 28 Jun 2018 10:30:52 -0700 (PDT) Received: from andrea ([94.230.152.15]) by smtp.gmail.com with ESMTPSA id h3-v6sm5335306wro.87.2018.06.28.10.30.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 10:30:52 -0700 (PDT) Date: Thu, 28 Jun 2018 19:30:45 +0200 From: Andrea Parri To: Peter Zijlstra 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: <20180628173045.GA4975@andrea> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180628150550.GI2494@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) 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 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! ;-) 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? Andrea