Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp566735imm; Wed, 11 Jul 2018 07:21:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpctOgDF7azxZ4MNFcaPVLmfwUWZZq3PZxm5OWGp1SRSjUVl5tleN/Vh1fuG60xwge5FFrR7 X-Received: by 2002:a62:e813:: with SMTP id c19-v6mr30017478pfi.124.1531318918739; Wed, 11 Jul 2018 07:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531318918; cv=none; d=google.com; s=arc-20160816; b=PH1hWZmno8mzwX4Q/uS3izpHvk4CrwitmnIy8a22qyjGvMTO35O2Kv+EYIXCXQPbnb I1URDXj2w/PX8NCESKqC0Lk3B62LyvDphzJ1fs0fmi0ZYI/vOOlq051SavCHuCj6Nu1e S/Z0xEdfqYqsDZLR056kz4hqmdSErX13mPR6RSXXXw+oIwB9CANJr3FvOjwEcxllD6CD JTyv6OuMt0CrwZdudECYFDNAjUUIQ7/6P1NH7JWTDvc2QOsrCrZEyK2PDSNjPhK0L4/N t2wCKOyhr/UzelDB1ohAH/czcb3zJ/wZ37AgGaVTykXsFW54WbsdeAKdWPYIM0rjolWc qNWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=xcMv6M59A55z+vwAeduNg5Ttboq2Bg9+lV98s/vFeJs=; b=LMh8r82sUobo3f3KAEY4ybvPc/NxPfFkwyD3DrcpZX/qoAY/FocuI4pzrHajpoSrN4 MU4qPkNN6sk3/a0U3Lrs36zm35reCFwgTl5Bskd+mPvxPMUJbmjK+8Tayprx/j0dTLY/ Rs5EW8Rg3IQy1DXorjTNcP6kg2wvEX2EJ9EAJWME9JaogMhujebU9/RhYjfox/72j3jP kvrV/MHz10L3u3ZMSAvnic/hRVpvF5BOsGfMy6JmC3ahPMZox42U455tWTYwWOXqNf5I b0opQmKX2AFCgZvQj4UPm3hoPfC7y+Rv3feW8spu2E5SsmkjNWx3FfEyAYOv3ov+uVfZ Lk6g== 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 z72-v6si18780983pgd.646.2018.07.11.07.21.42; Wed, 11 Jul 2018 07:21:58 -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 S2388426AbeGKOYV (ORCPT + 99 others); Wed, 11 Jul 2018 10:24:21 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:42354 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2387834AbeGKOYU (ORCPT ); Wed, 11 Jul 2018 10:24:20 -0400 Received: (qmail 1695 invoked by uid 2102); 11 Jul 2018 10:19:45 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 11 Jul 2018 10:19:45 -0400 Date: Wed, 11 Jul 2018 10:19:45 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrea Parri cc: Daniel Lustig , "Paul E. McKenney" , LKMM Maintainers -- Akira Yokosawa , Boqun Feng , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Will Deacon , Kernel development list Subject: Re: [PATCH v2] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire In-Reply-To: <20180710233152.GA11825@andrea> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Jul 2018, Andrea Parri wrote: > > > Does something like "po; [UL]; rf; [LKR]; po" fit in with the rest > > > of the model? If so, maybe that solves the asymmetry and also > > > legalizes the approach of putting fence.tso in front? > > > > That would work just as well. For this version of the patch it > > doesn't make any difference, because nothing that comes po-after the > > LKR is able to directly read the value stored by the UL. > > Consider: > > C v2-versus-v3 > > {} > > P0(spinlock_t *s, int *x) > { > spin_lock(s); /* A */ > spin_unlock(s); > spin_lock(s); > WRITE_ONCE(*x, 1); /* B */ > spin_unlock(s); > } > > P1(spinlock_t *s, int *x) > { > int r0; > int r1; > > r0 = READ_ONCE(*x); /* C */ > smp_rmb(); > r1 = spin_is_locked(s); /* D */ > } > > With v3, it's allowed that C reads from B and D reads from (the LKW of) A; > this is not allowed with v2 (unless I mis-applied/mis-read v2). Correct. But it doesn't affect the end result, because both versions allow C to read from B while D reads from the second spin_lock(), and there's no way to distinguish that from the case where D reads from A. If we were talking about arbitrary integers and rmw-acquire updates, there _would_ be a difference. But not with spinlocks. Alan