From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE8DDC433F5 for ; Thu, 9 Sep 2021 18:59:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC3E16115B for ; Thu, 9 Sep 2021 18:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242328AbhIITAu (ORCPT ); Thu, 9 Sep 2021 15:00:50 -0400 Received: from netrider.rowland.org ([192.131.102.5]:56163 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S231422AbhIITAs (ORCPT ); Thu, 9 Sep 2021 15:00:48 -0400 Received: (qmail 13113 invoked by uid 1000); 9 Sep 2021 14:59:37 -0400 Date: Thu, 9 Sep 2021 14:59:37 -0400 From: Alan Stern To: Linus Torvalds Cc: Will Deacon , Peter Zijlstra , Alexander Shishkin , Peter Anvin , Andrea Parri , Ingo Molnar , "Paul E. McKenney" , Vince Weaver , Thomas Gleixner , Jiri Olsa , Arnaldo Carvalho de Melo , Linux Kernel Mailing List , Stephane Eranian , linux-tip-commits@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Daniel Lustig , Michael Ellerman Subject: Re: [tip:locking/core] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Message-ID: <20210909185937.GA12379@rowland.harvard.edu> References: <20180926182920.27644-2-paulmck@linux.ibm.com> <20210908144217.GA603644@rowland.harvard.edu> <20210909133535.GA9722@willie-the-truck> 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 Thu, Sep 09, 2021 at 10:02:13AM -0700, Linus Torvalds wrote: > On Thu, Sep 9, 2021 at 6:35 AM Will Deacon wrote: > > > > I don't think we should require the accesses to the actual lockwords to > > be ordered here, as it becomes pretty onerous for relaxed LL/SC > > architectures where you'd end up with an extra barrier either after the > > unlock() or before the lock() operation. However, I remain absolutely in > > favour of strengthening the ordering of the _critical sections_ guarded by > > the locks to be RCsc. > > Ack. The actual locking operations themselves can obviously overlap, > it's what they protect that should be ordered if at all possible. > > Because anything else will be too confusing for words, and if we have > to add memory barriers *and* locking we're just screwed. > > Because I think it is entirely understandable for people to expect > that sequence of two locked regions to be ordered wrt each other. > > While memory ordering is subtle and confusing, we should strive to > make our "..but I used locks" to be as straightforward and as > understandable to people who really really don't want to even think > about memory order as at all reasonable. > > I think we should have a very strong reason for accepting unordered > locked regions (with "strong reason" being defined as "on this > architecture that is hugely important, anything else would slow down > locks enormously"). > > It sounds like no such architecture exists, much less is important. All right. Currently the memory model has RCtso ordering of accesses in separate critical sections for the same lock, as observed by other CPUs not holding the lock. Peter is proposing (and Linus agrees) to expand this to cover critical sections for different locks, so long as both critical sections are on the same CPU. But he didn't propose strengthening the ordering to RCsc, and I presume we don't want to do this because of the slowdown it would incur on Power. Does everyone agree that this correctly summarizes the change to be made to the memory model? Alan