Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp303215imm; Wed, 11 Jul 2018 02:45:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpckktgF6WJNoydLewrfIXtiyF3Ywzafj7XZT1lXSNUWOCrzyDAFVVeP9pySJuzahydFCywY X-Received: by 2002:a63:1063:: with SMTP id 35-v6mr24974892pgq.249.1531302319031; Wed, 11 Jul 2018 02:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531302319; cv=none; d=google.com; s=arc-20160816; b=ay1NLOw0QyVOz+46z2s4n606wc6GfSL7/xMXWHL7moxYcq6KqjOUxrJ/OUquPNoqkr KwnQHkCicUAU0Msiyum+/L3TqrKCS0n5YAhaxDsc4E0wOyZ09ZbC26Jes6FQupzqxan7 hhTaGIveOGw/59Y4RWvtCDOlh2JRgcq6y9NU0GdC7ncie+iSfKrbdG9SABrX3hZeDaPS vM1wiu1wp/YPeLXoXzd12+llTsq7b7LrminjxUtUgRLwupVLOTKZk4ZlyzBQSWg4mUh/ 5H0iv5TbovGQCoGNgZaZy62KKwIry9sg0BXk8ZecXsPbsbAB/1K7Rede9Pj7gtMVOEKW /xxA== 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=ZVezKhwBJjbitMtmiNQIP4jCAguT4mgHWW/FMqfS1IY=; b=tuJnK8wnkfljxfttVdnJLt50+6bsqiH5VXl7yiRmfvbmttJpbCYz+NjjQ55HrMPjfL DPzpFsoZoq1ITqvWERIDVuQMT7TY0jPcKc2eYonDo3vZzZgixFJNRUJl4rVcTCpTmKde eEEuSKaxWlQGJDmjU+0Hm/tAqQpD6PCLZJ9xS43T8atkZVkFIrBF9t6lYH5FelVEf5sR wnfyQ4MyWLzE9viCph7m8oyHDCpjvarCBHmojp+ezcr8SKn5Rvfg0JdRu0wzefagVH8e hRFU9TwrWgTdOWjLrB9H8GMrDlCwm3oCRf2cYx+/HXvt+WWaQbwChmEcjOz7MrUfG2vD kGMw== 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 o8-v6si2344187pgr.461.2018.07.11.02.45.03; Wed, 11 Jul 2018 02:45:18 -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 S1732749AbeGKJqb (ORCPT + 99 others); Wed, 11 Jul 2018 05:46:31 -0400 Received: from foss.arm.com ([217.140.101.70]:60358 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726500AbeGKJqa (ORCPT ); Wed, 11 Jul 2018 05:46:30 -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 7AE78ED1; Wed, 11 Jul 2018 02:43:03 -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 4D05D3F318; Wed, 11 Jul 2018 02:43:03 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 53DCA1AE3828; Wed, 11 Jul 2018 10:43:45 +0100 (BST) Date: Wed, 11 Jul 2018 10:43:45 +0100 From: Will Deacon To: Alan Stern Cc: "Paul E. McKenney" , LKMM Maintainers -- Akira Yokosawa , Andrea Parri , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Kernel development list Subject: Re: [PATCH v3] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Message-ID: <20180711094344.GE13963@arm.com> References: <20180710162555.GV3593@linux.vnet.ibm.com> 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 Hi Alan, On Tue, Jul 10, 2018 at 02:18:13PM -0400, Alan Stern wrote: > More than one kernel developer has expressed the opinion that the LKMM > should enforce ordering of writes by locking. In other words, given > the following code: > > WRITE_ONCE(x, 1); > spin_unlock(&s): > spin_lock(&s); > WRITE_ONCE(y, 1); > > the stores to x and y should be propagated in order to all other CPUs, > even though those other CPUs might not access the lock s. In terms of > the memory model, this means expanding the cumul-fence relation. > > Locks should also provide read-read (and read-write) ordering in a > similar way. Given: > > READ_ONCE(x); > spin_unlock(&s); > spin_lock(&s); > READ_ONCE(y); // or WRITE_ONCE(y, 1); > > the load of x should be executed before the load of (or store to) y. > The LKMM already provides this ordering, but it provides it even in > the case where the two accesses are separated by a release/acquire > pair of fences rather than unlock/lock. This would prevent > architectures from using weakly ordered implementations of release and > acquire, which seems like an unnecessary restriction. The patch > therefore removes the ordering requirement from the LKMM for that > case. > > All the architectures supported by the Linux kernel (including RISC-V) > do provide this ordering for locks, albeit for varying reasons. > Therefore this patch changes the model in accordance with the > developers' wishes. > > Signed-off-by: Alan Stern Thanks, I'm happy with this version of the patch: Reviewed-by: Will Deacon Will