Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6894850ybe; Wed, 18 Sep 2019 10:46:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8nTQ8xlUoUUbnLxXAC+3k4+gyAlYU8A6ry3hz42aswF5jFNBOhZR1VbhAVptYWFL+KGvo X-Received: by 2002:aa7:c995:: with SMTP id c21mr11978030edt.129.1568828813309; Wed, 18 Sep 2019 10:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568828813; cv=none; d=google.com; s=arc-20160816; b=OZ0GxVfXVjiZf2FPYBuDJDM+qgrV8U8knqon72PqfIhJQux5R+RjL/7cI7q7Hkb5dU wJ3R8mSwo3AulesqOqNwePvmsBnqySXVtHwLx26ASGcsKSgtHmpPRmuWRoqj2HJU4BQL 2/67ltZlDcBpJipSADqM0ZODh8zUaZB+3U+tkcluv9mI5nAmfjJXpf0gmC/gem4f0Y+L /OrstFzTs/oqJqueOIan5DdKyVoUxhAQUeVkjkx1PXpyg9BMbeJ531dKwBMd7eRwIoVD BFS9ib/V54FpnBq5OEKvCcW0O/0hPDwM95J6RfkyjiVx2kgOjoTPY490ZXcfl1TB9jAg q74Q== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=yS6InJ3mvwWF3208qPs7dHzvBGPaB34AzwyRDO+vBro=; b=zSIwb3ZMFluVEoTjg745jOjIR2L4SL6hbh/1sECcg+5sJyIckhlBh8vgjciA6lf663 qjeEhUbbZLw5uEJJOPVT1SWlMEQbA9iX3HnYZkSipHsFxwXzvWUPWEaexPSJ4ANqoecV tK5TvYD3nw/nYkRuFj5l5am2ICh3OHOjN/zhGCncZo+Ix/lkytfzaPEaQy9DTegEGtZt vmftLIN8Dyx/RpmBq2GKZC3gIqlQ3OLMheLKP2fNbkqYseoIoYACbs2B6DKqGwMaibfo CEKam9bEfPk/+nkrEGjNZNH7xsGeVV/NMKRudizqYFteBT1GpnfYFUxyWL3SoixWjI1S E+Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bOnWVhH0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si3191478ejf.58.2019.09.18.10.46.30; Wed, 18 Sep 2019 10:46:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=bOnWVhH0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731229AbfIRRYO (ORCPT + 99 others); Wed, 18 Sep 2019 13:24:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:39930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728872AbfIRRYN (ORCPT ); Wed, 18 Sep 2019 13:24:13 -0400 Received: from paulmck-ThinkPad-P72 (unknown [50.237.200.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7096B208C0; Wed, 18 Sep 2019 17:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568827453; bh=A1V/EfLTbcRI9RyIqwgOE7WQoth8tsczLQUrafsktnI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=bOnWVhH0PQlbobozKVtZfWh0PQSA8QsUXeIY4Zw5HPFdvpm8cjDX4gCLldTjbw05A pG4lVHTmzefY7a3kOU2IeEkf5jRAm8PXGrx6ZjZRy4gu+7RNDHxRpN2J4vAZVTZVcc Hi1QB7friKdAZBYHCY7yu8GQ6e/OwOfkYTz5mbJA= Date: Wed, 18 Sep 2019 10:24:10 -0700 From: "Paul E. McKenney" To: Andrea Parri Cc: Alan Stern , LKMM Maintainers -- Akira Yokosawa , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Will Deacon , Kernel development list Subject: Re: [PATCH RFC] tools/memory-model: Fix data race detection for unordered store and load Message-ID: <20190918172410.GJ30224@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20190917113959.GA19404@andrea.guest.corp.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190917113959.GA19404@andrea.guest.corp.microsoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 17, 2019 at 01:39:59PM +0200, Andrea Parri wrote: > On Fri, Sep 06, 2019 at 04:57:22PM -0400, Alan Stern wrote: > > Currently the Linux Kernel Memory Model gives an incorrect response > > for the following litmus test: > > > > C plain-WWC > > > > {} > > > > P0(int *x) > > { > > WRITE_ONCE(*x, 2); > > } > > > > P1(int *x, int *y) > > { > > int r1; > > int r2; > > int r3; > > > > r1 = READ_ONCE(*x); > > if (r1 == 2) { > > smp_rmb(); > > r2 = *x; > > } > > smp_rmb(); > > r3 = READ_ONCE(*x); > > WRITE_ONCE(*y, r3 - 1); > > } > > > > P2(int *x, int *y) > > { > > int r4; > > > > r4 = READ_ONCE(*y); > > if (r4 > 0) > > WRITE_ONCE(*x, 1); > > } > > > > exists (x=2 /\ 1:r2=2 /\ 2:r4=1) > > > > The memory model says that the plain read of *x in P1 races with the > > WRITE_ONCE(*x) in P2. > > > > The problem is that we have a write W and a read R related by neither > > fre or rfe, but rather W ->coe W' ->rfe R, where W' is an intermediate > > write (the WRITE_ONCE() in P0). In this situation there is no > > particular ordering between W and R, so either a wr-vis link from W to > > R or an rw-xbstar link from R to W would prove that the accesses > > aren't concurrent. > > > > But the LKMM only looks for a wr-vis link, which is equivalent to > > assuming that W must execute before R. This is not necessarily true > > on non-multicopy-atomic systems, as the WWC pattern demonstrates. > > > > This patch changes the LKMM to accept either a wr-vis or a reverse > > rw-xbstar link as a proof of non-concurrency. > > > > Signed-off-by: Alan Stern > > Acked-by: Andrea Parri Applied, thank you both! Thanx, Paul