Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp673029imm; Fri, 31 Aug 2018 10:06:27 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbps4WgFUhrLhDXRLD2bF2i9+PJjNYFkqeJihDFEBAgrb/nFen9W0zlCLoNsOjWNw0L4Zhp X-Received: by 2002:a62:6bc5:: with SMTP id g188-v6mr12899222pfc.91.1535735187348; Fri, 31 Aug 2018 10:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535735187; cv=none; d=google.com; s=arc-20160816; b=t9BXnhM/q/sNGeTVN54et1LtZyK6VO/6PaGuwcDqGbAhlgEEkT3p10E6sOxl9Od0ts Y4NodQTtEjMX/Mi0hYlfjCTQA3KS30/myewBBypS/DCeWY9jb9Jvb6bbek1fZpmQe6Xe 75qoyUL8dHQiw3FJH3fSS9PmpAEIm4F92CAilrRbHjcuPbclvfpL2yI28v6uv7W7Eoek 68tWUUNTPgur8yMJKvzVmg+5DA5OFECWJKFmkJ+bHN3IeeVKcbDkxMtGCAzY4bP8R1ws kqGo3kEDnMyWFp7FuCEgqvpZL3GDyHcODob6amGL54KdAw/2ojti1+cMwWeeLHK/MYM0 L40A== 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:arc-authentication-results; bh=MiIMoNCm5V5ahfHnClxAPyOH9ZHQYVDQo0p4tdFd+t4=; b=dbRBtsMWe6V0nFMG3tJ4scoI9BWaTeVGpnOAYHFrhIJbiwwtD8jjvI2S44Vm3JU66t cGWBh2iYz9qZNnUfumC1FEXI374a7Hko2uYHuWZpBxUeEERzE/CyktUK37/O2Cji4v/u Fi+znPa6HW59M8C3Ygq064XGVIUN6opn2Su0u6brZoUXrT2wBnXQ4KGPsmOab+K+yZ6L 50rrhtpIKaBhtf98WOqS4OF8oFi7ofx4DbXiEcrBL5okkoJRBMmqtkJNRgUCRQv4LRg7 eUjS1pbJfif3DNVnO1AZC4x/Mv6bpDAl4OPU7XFUzVsOjuf+jbwHFcoynUBOxMn3gg43 DzFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 b69-v6si10117252pga.90.2018.08.31.10.06.09; Fri, 31 Aug 2018 10:06:27 -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; 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 S1729187AbeHaUOj (ORCPT + 99 others); Fri, 31 Aug 2018 16:14:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:32872 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727286AbeHaUOj (ORCPT ); Fri, 31 Aug 2018 16:14:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D3D1ED1; Fri, 31 Aug 2018 09:06:28 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D2E253F5BD; Fri, 31 Aug 2018 09:06:27 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 83C791AE30C7; Fri, 31 Aug 2018 17:06:40 +0100 (BST) Date: Fri, 31 Aug 2018 17:06:40 +0100 From: Will Deacon To: Alan Stern Cc: Andrea Parri , "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com Subject: Re: [PATCH RFC LKMM 1/7] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Message-ID: <20180831160640.GG30626@arm.com> References: <20180831091641.GA3634@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 31, 2018 at 10:52:54AM -0400, Alan Stern wrote: > On Fri, 31 Aug 2018, Andrea Parri wrote: > > On Thu, Aug 30, 2018 at 05:31:32PM -0400, Alan Stern wrote: > > > On Thu, 30 Aug 2018, Andrea Parri wrote: > > > > (Remark: ordinary release/acquire are building blocks for code such as > > > > qspinlock, (q)rwlock, mutex, rwsem, ... and what else??). > > > > > > But are these building blocks used the same way for all architectures? > > > > The more, the better! (because then we have the LKMM tools) > > > > We already discussed the "fast path" example: the fast paths of the > > above all resemble: > > > > *_lock(s): atomic_cmpxchg_acquire(&s->val, UNLOCKED_VAL, LOCKED_VAL) ... > > *_unlock(s): ... atomic_set_release(&s->val, UNLOCKED_VAL) > > > > When I read this code, I think "Of course." (unless some arch. has > > messed the implementation of cmpxchg_* up, which can happen...); but > > then I read the subject line of this patch and I think "Wait, what?". > > > > You can argue that this is not generic code, sure; but why on Earth > > would you like to do so?! > > Because the code might not work! On RISC-V, for example, the > implementation of ordinary release/acquire is currently not as strong > as atomic release/acquire. > > Yes, it's true that implementing locks with atomic_cmpxchg_acquire > should be correct on all existing architectures. And Paul has invited > a patch to modify the LKMM accordingly. If you feel that such a change > would be a useful enhancement to the LKMM's applicability, please write > it. Yes, please! That would be the "RmW" discussion which Andrea partially quoted earlier on, so getting that going independently from this patch sounds like a great idea to me. Cheers, Will