Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2673904rwl; Sat, 8 Apr 2023 21:49:24 -0700 (PDT) X-Google-Smtp-Source: AKy350ZqEuupS5qovegRGUcGcSlsoaCEX7bk1hcCdhoYEgVnz8kaBF+hyFbEFz1M7lwHIMOpXm3U X-Received: by 2002:a17:907:8e93:b0:878:72f7:bd99 with SMTP id tx19-20020a1709078e9300b0087872f7bd99mr3883190ejc.6.1681015763779; Sat, 08 Apr 2023 21:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681015763; cv=none; d=google.com; s=arc-20160816; b=t6fb+JjWvBOq6D7sb28RZT/a7jnphkvknuEyhNiZwW24BPNHRh9yjb+cJCtaBxanBe cMkAxSL8sUBBcLnehYwLxqCshkz9nd3hH5NMFd1bb4BOxo7Rh58CCd168PBhgh7txNYt JCI66ICLWUJqnLqsuJYbFCaA1CGu+GDMltSmxlAi/PIaW6cOSpbNGLkDS+yTqzfQ9jaV kL3O5tutcX7TcWasT0YdYsqKvQZTJwO2xG3S9+Ym3jAdoWaQXfI+5V72x+GVgr4ljRwC VDY6zavmYYPern4Carfa7tNpXDP9jeoQkCqJmaqFUwWWJz+W2AGAKDQm3n2E4fEWM175 /0AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FDuFy9RPjn4n6kcj3GDtjcBDkENRtGj7xCf7X4HUB5g=; b=LdX3YL6/1ZjER3mzll7ASkTgNppoAFZnA+3dHrB+M1s78QdpD9NmnP53YGOpEkMpVT MT9i1F9pXC/KbPaZn2o2EdQH9uhwYiLSZTWyeG/qJcH4HO/hT1UytIlMKruSrbDYHnZB p9HSxhQNafhKFzT+lY100e7Cp2Sc0mdOelmoEMkiDMfh4F2oHzVjDsCteayUq3947qap ko/qYiI7up7v2vcEeegSfTFGOuIFmVlhrhbr3e6I/ujMAvqk+hjcq4y7FNMb0xRkDwO0 AVftz6LC0LnOqSzZ1gG+A3g1yWI6LQa7ULLlvSJbgi7lP6DuJFOUPIAsmHj0VetH8sBj +2Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=d4wiQoUR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce9-20020a170906b24900b0094a65a01cc6si858460ejb.1038.2023.04.08.21.48.48; Sat, 08 Apr 2023 21:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=d4wiQoUR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbjDIE3V (ORCPT + 99 others); Sun, 9 Apr 2023 00:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjDIE3U (ORCPT ); Sun, 9 Apr 2023 00:29:20 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D72B65277 for ; Sat, 8 Apr 2023 21:29:18 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id ks2so2729911qvb.1 for ; Sat, 08 Apr 2023 21:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1681014558; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=FDuFy9RPjn4n6kcj3GDtjcBDkENRtGj7xCf7X4HUB5g=; b=d4wiQoURlizx8dQxnBgls3y2Y3NLZxLGGqOlct0UigRk/Z8vXJFXimbhdqurCqikSs mbWNjv1P+vuVmWnxLCMNCX7hZUtgsERrY3g4rcYWYPBMi/IgpJFqvsHLNQNo81Lb0zG7 9Mg8rq1krY1m1L0jFI2zjhI9pvWGQhuQh+SGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681014558; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FDuFy9RPjn4n6kcj3GDtjcBDkENRtGj7xCf7X4HUB5g=; b=TJKuEpxqV+TH+ecaUMIHbNum+s4psfY3FJvklc/hE8o7vSnTJ4V70c6DscIHnQciUz vUmxumAkgMRJsfUPzaeXOzCBps9OToK6HyZviVEJppTZNGZptPENJGG1xUgIvh4XM4q+ 8X9eH2ru9aMKP6fkuAJ2LIPrjLIbbbA/x5J4lsZlnbQwAHSI8nO6wH2CIA2SFc25agFd Pe5SQMplNEYR1dGFhcS2yxJbKoI6a9MsqPmKDwfOH2BSqjYbuO1bYKAY7fDXwbFR5sPy NDLy/dIGSw+t7Dp7zMsBu0bZrSLxcqysgvVdHzolTIlQiTrl96VgzeLCIjqovlziF25+ NvkQ== X-Gm-Message-State: AAQBX9dYFuOFJDKxsc0gbxqLbxPgtwzb+35xmYQLKVIYkhBolxjGOdc5 L3MvFGgyRnaaJS0XYFMiGIluIbq3MTByf86yE7g= X-Received: by 2002:a05:6214:62c:b0:56e:9f19:71f9 with SMTP id a12-20020a056214062c00b0056e9f1971f9mr17393007qvx.17.1681014557940; Sat, 08 Apr 2023 21:29:17 -0700 (PDT) Received: from localhost (129.239.188.35.bc.googleusercontent.com. [35.188.239.129]) by smtp.gmail.com with ESMTPSA id s63-20020a37a942000000b00706b09b16fasm2433706qke.11.2023.04.08.21.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Apr 2023 21:29:17 -0700 (PDT) Date: Sun, 9 Apr 2023 04:29:16 +0000 From: Joel Fernandes To: Jonas Oberhauser Cc: "Paul E. McKenney" , Alan Stern , linux-kernel@vger.kernel.org, Boqun Feng , Jade Alglave , Luc Maranget , Peter Zijlstra , Will Deacon , Akira Yokosawa , Andrea Parri , Daniel Lustig , David Howells , Jonas Oberhauser , linux-arch@vger.kernel.org, Nicholas Piggin , Paul =?iso-8859-1?Q?Heidekr=FCger?= , Will Deacon Subject: Re: Litmus test names Message-ID: <20230409042916.GA768965@google.com> References: <3908932E-17D4-4B87-AB0C-D10564F10623@joelfernandes.org> <159545c3-0093-3cbd-e822-7298ae764966@huaweicloud.com> <20230408164956.GA680332@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 08, 2023 at 08:57:57PM +0200, Jonas Oberhauser wrote: > > On 4/8/2023 6:49 PM, Joel Fernandes wrote: > > On Fri, Apr 07, 2023 at 05:49:02PM -0700, Paul E. McKenney wrote: > > > On Fri, Apr 07, 2023 at 03:05:01PM +0200, Jonas Oberhauser wrote: > > > > > > > > On 4/7/2023 2:12 AM, Joel Fernandes wrote: > > > > > > > > > > > On Apr 6, 2023, at 6:34 PM, Paul E. McKenney wrote: > > > > > > > > > > > > On Thu, Apr 06, 2023 at 05:36:13PM -0400, Alan Stern wrote: > > > > > > > Paul: > > > > > > > > > > > > > > I just saw that two of the files in > > > > > > > tools/memory-model/litmus-tests have > > > > > > > almost identical names: > > > > > > > > > > > > > >  Z6.0+pooncelock+pooncelock+pombonce.litmus > > > > > > >  Z6.0+pooncelock+poonceLock+pombonce.litmus > > > > > > > > > > > > > > They differ only by a lower-case 'l' vs. a capital 'L'.  It's > > > > > > > not at all > > > > > > > easy to see, and won't play well in case-insensitive filesystems. > > > > > > > > > > > > > > Should one of them be renamed? > > > > > > > > FWIW, if I move that smp_mb_after..() a step lower, that also makes the test > > work (see below). > > > > If you may look over quickly my analysis of why this smp_mb_after..() is > > needed, it is because what I marked as a and d below don't have an hb > > relation right? > > I think a and d have an hb relation due to the > a ->po-rel X ->rfe Y ->acq-po d > edges (where X and Y are the unlock/lock events I annotated in your example > below). I kind of disagree with that, because if I understand correctly, a ->hb d means ALL CPUs agree as a universal fact that a happened before d. Clearly, without the smp_mb(), CPU P2 disagrees that a happened before d. So the po-rel acq-po doesn't imply a->hb d, IMHO. Correct me if I'm wrong though with any counter example. ;-) > > Generally, an mb_unlock_lock isn't used to give you hb, but to turn some > (coe/fre) ; hb* edges into pb edges > > In this case, that would probably be > f ->fre a ->hb* f   (where a ->hb* f comes from a ->hb* d ->hb e ->hb f) > By adding the mb_unlock_lock_po in one of the right places, this becomes f > ->pb f, > thus forbidden. This I fully agree with. I observed this litmus is actually the R-pattern with P0 split into 2 CPUs by spltting the thread of execution using a lock and ordering them with an ->rfe and the exists() clause. Otherwise it is identical. In the R-pattern also, you need an smp_mb() between the pair of accesses. Using the same annotations but instead applying them to the R-pattern, it looks like: P0(int *x, int *y) { WRITE_ONCE(*x, 1); // a // Here we need an smp_mb() to order the stores to x and z. WRITE_ONCE(*z, 1); // d } P2(int *x, int *z) { int r1; WRITE_ONCE(*z, 2); // e smp_mb(); r1 = READ_ONCE(*x); // f exists (z=2 /\ 2:r1=0) thanks, - Joel > > Have fun, > jonas > > > > > > (* > > b ->rf c > > > > d ->co e > > > > e ->hb f > > > > basically the issue is a ->po b ->rf c ->po d does not imply a ->hb d > > *) > > > > P0(int *x, int *y, spinlock_t *mylock) > > { > > spin_lock(mylock); > > WRITE_ONCE(*x, 1); // a > > WRITE_ONCE(*y, 1); // b > > spin_unlock(mylock); // X > > } > > > > P1(int *y, int *z, spinlock_t *mylock) > > { > > int r0; > > > > spin_lock(mylock); // Y > > r0 = READ_ONCE(*y); // c > > smp_mb__after_spinlock(); // moving this a bit lower also works fwiw. > > WRITE_ONCE(*z, 1); // d > > spin_unlock(mylock); > > } > > > > P2(int *x, int *z) > > { > > int r1; > > > > WRITE_ONCE(*z, 2); // e > > smp_mb(); > > r1 = READ_ONCE(*x); // f > > } > > > > exists (1:r0=1 /\ z=2 /\ 2:r1=0) > > > > > > > Would someone like to to a "git mv" send the resulting patch? > > Yes I can do that in return as I am thankful in advance for the above > > discussion. ;) > > > > thanks, > > > > - Joel > > >