Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2791261ybd; Mon, 24 Jun 2019 12:44:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqw84xE4Ss1IivibuJdtMwqbNJ2SwzQtUCqvkPsdMvBORJcgXVtk2jKpwwVSJ2BgY9OlGw2L X-Received: by 2002:a65:64d5:: with SMTP id t21mr35343011pgv.310.1561405493856; Mon, 24 Jun 2019 12:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561405493; cv=none; d=google.com; s=arc-20160816; b=S1FOXMQjy0bWeJMYvjDvY8oYBsT+M6ihxpFUjFcdNcKsOpU+/JW+jeKo8FarULc9Vn rdS9VYMmc1gn8hJjo/QS9jOjvd/G16UzRHqHnwlldi0fJQFGtxv7rCz3qepo5lOA0akq oIjxXB4ulFKu+74pgfplWh2SdscJfuFUq3p3Sg5lZWqYFvnrj2OIlxtcJ0UVZEtoaMcE pENz0hPEzibOHgUvaHOwYFhbw9pqtSmww7uuM1knsQr+13Rpxin3thrlTD7YdbGR5L9W LE2BvdRi62p2eN5slYcTncnSCZI8hvLkq5t27CX0J2KtjAjXLDpIHunxaDT7RfKRbS2D Z08w== 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; bh=wtWiRsQSvpRAOsw3V41giPMTEZFcSNfrJjFTgT25eJs=; b=RAZuUlG3u9rpsiuTeYmHfBDYRKRsVsiU3gaNJsJZ8wpgBHdg6dOdZsyzvr6NuEo1+A NV6EW1KQd4jNpCUf7qjQdwxrTVtfzVZSiFyrKhPlYRvxS8Zy9l4u2k/TkWp+EE6vJn1J yaEgS9CJz8Fk7DNK7HLHdmBd2ePS0tZaNoy2w6/jL33eheGH50C8kMPNRDHw2XMY0nVT oaVxeuciRI8cThG/GSX3bIJ/1qbo4EfrfoIhdxUXRay4VdLH9wPAFkS7Xc7AscZE5EPB 64U0VZOjlNV6PUWZIS9bhgujri+ZxdvmE9HsK028t/lZt3bUGj4DGIT76teHxvba6aTo dZ3A== 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 i62si11538891pge.573.2019.06.24.12.44.38; Mon, 24 Jun 2019 12:44: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; 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 S1731232AbfFXPj1 (ORCPT + 99 others); Mon, 24 Jun 2019 11:39:27 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:57208 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726551AbfFXPjY (ORCPT ); Mon, 24 Jun 2019 11:39:24 -0400 Received: (qmail 4704 invoked by uid 2102); 24 Jun 2019 11:39:23 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 24 Jun 2019 11:39:23 -0400 Date: Mon, 24 Jun 2019 11:39:23 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Paul E. McKenney" cc: Akira Yokosawa , Andrea Parri , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Will Deacon , Herbert Xu , Kernel development list Subject: Re: [PATCH 3/3] tools: memory-model: Improve data-race detection In-Reply-To: <20190624152126.GA828@linux.ibm.com> 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 Mon, 24 Jun 2019, Paul E. McKenney wrote: > On Sun, Jun 23, 2019 at 09:34:55PM -0700, Paul E. McKenney wrote: > > On Sun, Jun 23, 2019 at 11:15:06AM -0400, Alan Stern wrote: > > > On Sun, 23 Jun 2019, Akira Yokosawa wrote: > > > > > > > Hi Paul and Alan, > > > > > > > > On 2019/06/22 8:54, Paul E. McKenney wrote: > > > > > On Fri, Jun 21, 2019 at 10:25:23AM -0400, Alan Stern wrote: > > > > >> On Fri, 21 Jun 2019, Andrea Parri wrote: > > > > >> > > > > >>> On Thu, Jun 20, 2019 at 11:55:58AM -0400, Alan Stern wrote: > > > > >>>> Herbert Xu recently reported a problem concerning RCU and compiler > > > > >>>> barriers. In the course of discussing the problem, he put forth a > > > > >>>> litmus test which illustrated a serious defect in the Linux Kernel > > > > >>>> Memory Model's data-race-detection code. > > > > > > > > I was not involved in the mail thread and wondering what the litmus test > > > > looked like. Some searching of the archive has suggested that Alan presented > > > > a properly formatted test based on Herbert's idea in [1]. > > > > > > > > [1]: https://lore.kernel.org/lkml/Pine.LNX.4.44L0.1906041026570.1731-100000@iolanthe.rowland.org/ > > > > > > Yes, that's it. The test is also available at: > > > > > > https://github.com/paulmckrcu/litmus/blob/master/manual/plain/C-S-rcunoderef-2.litmus > > > > > > Alan > > > > > > > If this is the case, adding the link (or message id) in the change > > > > log would help people see the circumstances, I suppose. > > > > Paul, can you amend the change log? > > > > > > > > I ran herd7 on said litmus test at both "lkmm" and "dev" of -rcu and > > > > confirmed that this patch fixes the result. > > > > > > > > So, > > > > > > > > Tested-by: Akira Yokosawa > > > > Thank you both! I will apply these changes tomorrow morning, Pacific Time. > > And done. Please see below for the updated commit. > > Thanx, Paul > > ------------------------------------------------------------------------ > > commit 46a020e9464aff884df56e5fd483134c8801e39f > Author: Alan Stern > Date: Thu Jun 20 11:55:58 2019 -0400 > > tools/memory-model: Improve data-race detection > > Herbert Xu recently reported a problem concerning RCU and compiler > barriers. In the course of discussing the problem, he put forth a > litmus test which illustrated a serious defect in the Linux Kernel > Memory Model's data-race-detection code [1]. > > The defect was that the LKMM assumed visibility and executes-before > ordering of plain accesses had to be mediated by marked accesses. In > Herbert's litmus test this wasn't so, and the LKMM claimed the litmus > test was allowed and contained a data race although neither is true. > > In fact, plain accesses can be ordered by fences even in the absence > of marked accesses. In most cases this doesn't matter, because most > fences only order accesses within a single thread. But the rcu-fence > relation is different; it can order (and induce visibility between) > accesses in different threads -- events which otherwise might be > concurrent. This makes it relevant to data-race detection. > > This patch makes two changes to the memory model to incorporate the > new insight: > > If a store is separated by a fence from another access, > the store is necessarily visible to the other access (as > reflected in the ww-vis and wr-vis relations). Similarly, > if a load is separated by a fence from another access then > the load necessarily executes before the other access (as > reflected in the rw-xbstar relation). > > If a store is separated by a strong fence from a marked access > then it is necessarily visible to any access that executes > after the marked access (as reflected in the ww-vis and wr-vis > relations). > > With these changes, the LKMM gives the desired result for Herbert's > litmus test and other related ones [2]. > > [1] https://lore.kernel.org/lkml/Pine.LNX.4.44L0.1906041026570.1731-100000@iolanthe.rowland.org/ > > [2] https://github.com/paulmckrcu/litmus/blob/master/manual/plain/C-S-rcunoderef-1.litmus > https://github.com/paulmckrcu/litmus/blob/master/manual/plain/C-S-rcunoderef-2.litmus > https://github.com/paulmckrcu/litmus/blob/master/manual/plain/C-S-rcunoderef-3.litmus > https://github.com/paulmckrcu/litmus/blob/master/manual/plain/C-S-rcunoderef-4.litmus Please add: https://github.com/paulmckrcu/litmus/blob/master/manual/plain/strong-vis.litmus Alan