Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp811936pxb; Thu, 30 Sep 2021 18:37:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNZcYdUjopmsJNkubPP1rtV1fWC7axkD1N3lNrUX/w1CN/kw8lwm3TYPenrfic8Z84cErT X-Received: by 2002:a17:90a:1a42:: with SMTP id 2mr10173895pjl.202.1633052249970; Thu, 30 Sep 2021 18:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633052249; cv=none; d=google.com; s=arc-20160816; b=CprQU+Mt1mXwhtfrBUmKuSy3RbD+wd2zbjhn5rTpIkEfGE/Zk0HBZmwHHw5cBO4k6x SDhUE72o+hmZ6j66edb+hYDgn6COCj7SebRR+9hPgHh9DA+kRpDJtqaY7UUBT4Sp2E5M aurdp2iviAEGOBBBwPTY/CVHU+zb01C0qSoD1pTTjVIZS+D6iMqwEGWX4Sbdda2QMdOt F4QMKoHUPQzz+maoNruYWRHHOeAlNU1WCVjaR7Lhdbx4n/t499VHb/+8iP27EsJ7buNP ED2Ylh1EV4/BgWl5m3fvc32DtA/P3dvtueFgYqczC1pv7thAmyM3oy9laCKWaxRKX+l8 9RJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7Vuqa0HJySth3mCiodUovLSHY2AAe775uksDMLrb4Jg=; b=MFdlcX+G1vRQe01lpYyjZj+rNzFSu9WtMBTBJ08aGN0dyxqmtB0XVYO8MFWH3sPBqa pg7Xxc6DVexypudmGPEAalHsmqYbHgtPXlYtngTKMDhguOv7+LkzbrN+6SAK2pOZ/zf7 VLbvPf2JPgHO57VQM4uDTwbWiNUUWHjoWw92j59wZLv2zrJigwQ5WADX0y2yG1N6kQ8L W6Bc6o2XDwAdlARDDDJndNQDy4ivP/52S4HZ4JUAMpBiGWPmPo0f42Yko/KJExbbM9gs c78OkWlJC9zrk40GQwLh+vSDTBXnEgNBojc5//ilQlYx7vmEbqHGQ/sUOTjt1oppbZrb tCFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h184si5855559pge.184.2021.09.30.18.37.14; Thu, 30 Sep 2021 18:37:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351252AbhJABck (ORCPT + 99 others); Thu, 30 Sep 2021 21:32:40 -0400 Received: from netrider.rowland.org ([192.131.102.5]:38105 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S230256AbhJABcj (ORCPT ); Thu, 30 Sep 2021 21:32:39 -0400 Received: (qmail 489090 invoked by uid 1000); 30 Sep 2021 21:30:55 -0400 Date: Thu, 30 Sep 2021 21:30:55 -0400 From: Alan Stern To: Boqun Feng Cc: "Paul E. McKenney" , Linux Kernel Mailing List , Dan Lustig , Will Deacon , Peter Zijlstra , Linus Torvalds , Alexander Shishkin , Peter Anvin , Andrea Parri , Ingo Molnar , Vince Weaver , Thomas Gleixner , Jiri Olsa , Arnaldo Carvalho de Melo , Stephane Eranian , palmer@dabbelt.com, paul.walmsley@sifive.com, mpe@ellerman.id.au Subject: Re: [PATCH] tools/memory-model: Provide extra ordering for unlock+lock pair on the same CPU Message-ID: <20211001013055.GA489012@rowland.harvard.edu> References: <20210930130823.2103688-1-boqun.feng@gmail.com> <20210930152033.GD464826@rowland.harvard.edu> <20210930181753.GH880162@paulmck-ThinkPad-P17-Gen-1> <20210930204634.GB482974@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 08:12:56AM +0800, Boqun Feng wrote: > On Thu, Sep 30, 2021 at 04:46:34PM -0400, Alan Stern wrote: > > On Thu, Sep 30, 2021 at 11:17:53AM -0700, Paul E. McKenney wrote: > > > On Thu, Sep 30, 2021 at 11:20:33AM -0400, Alan Stern wrote: > > > > On Thu, Sep 30, 2021 at 09:08:23PM +0800, Boqun Feng wrote: > > > > > A recent discussion[1] shows that we are in favor of strengthening the > > > > > ordering of unlock + lock on the same CPU: a unlock and a po-after lock > > > > > should provide the so-called RCtso ordering, that is a memory access S > > > > > po-before the unlock should be ordered against a memory access R > > > > > po-after the lock, unless S is a store and R is a load. > > > > > > > > > > The strengthening meets programmers' expection that "sequence of two > > > > > locked regions to be ordered wrt each other" (from Linus), and can > > > > > reduce the mental burden when using locks. Therefore add it in LKMM. > > > > > > > > > > [1]: https://lore.kernel.org/lkml/20210909185937.GA12379@rowland.harvard.edu/ > > > > > > > > > > Co-developed-by: Alan Stern > > > > > Signed-off-by: Alan Stern > > > > > Signed-off-by: Boqun Feng > > > > > --- > > > > > Alan, > > > > > > > > > > I added the "Co-developed-by" and "Signed-off-by" tags since most of the > > > > > work is done by you. Feel free to let me know if you want to change > > > > > anything. > > > > > > > > It looks good to me. However, do we really want to add these litmus > > > > tests to the kernel source, or would it be better to keep them with > > > > the thousands of other tests in Paul's archives? > > > > > > Either way works for me. But if they are referred to from within the > > > kernel, it is best to have them in the kernel source. Which might be seen > > > as a reason to minimize referring to litmus tests from the kernel. ;-) > > > > In this case the litmus tests are not referred to within the kernel > > source. > > > > I'm OK to drop the litmus tests, but the reason I add the two litmus > tests is that they directly describe one of our memory model rules. The > two litmus tests tells developers "you can use unlock+lock on the same > CPU to order READ->WRITE or WRITE->WRITE", so they are kind of part of > the manual of our memory model. Thoughts? The explanation.txt file already contains example litmus tests (not in a form acceptable to herd7, though) for these things. Alan