Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1225550ybd; Sun, 23 Jun 2019 02:57:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZuSZgBnVkOz9mgOQUUtFUeO7AWdpWZr/WegQNPWXAGCmY2/fxhLa9epzJZt4KD6ps6ilS X-Received: by 2002:a17:902:ab90:: with SMTP id f16mr138686752plr.262.1561283835881; Sun, 23 Jun 2019 02:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561283835; cv=none; d=google.com; s=arc-20160816; b=ZBZDiw1k5z56dPfzxWWiGbrBw+Ndb6o6srmBak8mgmRcaRm3Pv+ahaXzzlgAIk9eg3 CLFKf/sH490eRyLXAcdesNpYQM8FGCL1lUMJyL4IZvQXSeIKS5TyqsDptT1KSxjmpPpj ORh5n+6AvpK1RbcaI2h4ur2Gpw2ld4/ibRpJ6tGiJSSLl2UGgtRABiVI6hE+LEnOER4x XNrNpXQSFoQBC7TBTmycy/DzDQrVxI/zNPYtaUaG+VjVI/ZhEIMOeZH9Y9TaOTIMEjF4 7HX5zmNihevAzBVZx/oGYxUpbnAKTtV7qMR7zxaNu6n11HI7UTQFonD3V2u7s0jNya+z 979w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=RqUHLEsccNI1hj4DCJDYKmH8si6r0vguFQAwU1QV9kQ=; b=aDi7E9KgqZE0nVzkWAFz3e4b3UffySI+vtmAgJ/D10Lp9RQX50Ehr1q+Jl47jdrFNB 782I9Thv2mrU1i2CFs5PzyB6LOgoGK8y7PXelHmKfYSOtUHK/SGUriXqbevaLWMVpoqs iozKVR+xFV+n/+B4pPG2tMZyOFkmPoJrWViIKJYirGuDqZTqB68G8mprKdRgp3UQ0uky p2ou32zYnCeqUkMrrWQfokwBCs4xIRvu5FOuTbBOgoisuWwaD9AJrY93seVRELZE2yR+ 5i7bGhpSh5Ax5BSJTI0FuQNGloKQdGqhkHmb3QUWhL25dukMXvVuyPsJaIxj/NMRWqLz f9Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="IMpPFe/G"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si7765387pjr.100.2019.06.23.02.56.31; Sun, 23 Jun 2019 02:57:15 -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=@gmail.com header.s=20161025 header.b="IMpPFe/G"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726484AbfFWJhY (ORCPT + 99 others); Sun, 23 Jun 2019 05:37:24 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42727 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbfFWJhY (ORCPT ); Sun, 23 Jun 2019 05:37:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id l19so5480577pgh.9 for ; Sun, 23 Jun 2019 02:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=RqUHLEsccNI1hj4DCJDYKmH8si6r0vguFQAwU1QV9kQ=; b=IMpPFe/GbIv/wiuQ97qK7WgGyOsqbRv0ro63JAYkamFt553gBG1L/Di2etxvuZJw4z IT5WUPjL8T8txJaoNMCf4c6V2ynWOOto7rrBN/L+j2dDKHosJBy0MD1+ErJkJN+y8g2i l+A+3jp2KZiWeOja+QQ5+Uz0494kd1iXQ0Omf7gwtUMByw915irHj6JXDXnPx2StU/q8 2Kh8RBVdhcsE3lBXDCpU4mEnmmo8a47a0QtiCT1hPxIeZ9c/LnIBSsk1Eech3Pow4BCA zSuR3DHK5bgZzQSPCMbKE6zWMJUbAAgUr/K0FKU75WY8P56L9YgvwLrFnGUV4+myy8FB yYFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=RqUHLEsccNI1hj4DCJDYKmH8si6r0vguFQAwU1QV9kQ=; b=WlpFjRqYrBiHKYijiwTUUdMIFzGxnQk3r98m4VCM7ujkWti+SHdYUJyP9f7h123ina GwtFHF84H5XFTd9DMewUIl8BPdvAVviTt9YLrP2KmciXxzTjAfVlqUIwVI0K4QWtIYeE V5bfOX+6rCd6ucPa1alcr6f1o8hzslJLZz+xTNlMeVC7VLtuvQkqmQNA1GqQ5O7YHWcu lrEVDFIx+vMm4bGnT0fRnGgO5PHwiDDiXtaeLLYrev2lBXS7ha8g3UWZdtVMFFkagO6M 7uX3OUAFVtMVIc0qn8kNPurXfGsiCBFF/XZOA5QA4bGUCCMpxoCA99u1ffaNP4NLLzJ1 dqJg== X-Gm-Message-State: APjAAAUugCRrVZWqILslohvqVkDipzm85qibuSWPAVcb4rU66ptGNeIl XCGgQ0MaqWkZcSfdM4mYmJHzjAw+ X-Received: by 2002:a17:90a:3463:: with SMTP id o90mr18208289pjb.15.1561282642666; Sun, 23 Jun 2019 02:37:22 -0700 (PDT) Received: from [192.168.11.2] (KD106167171201.ppp-bb.dion.ne.jp. [106.167.171.201]) by smtp.gmail.com with ESMTPSA id w16sm10383572pfj.85.2019.06.23.02.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jun 2019 02:37:22 -0700 (PDT) Subject: Re: [PATCH 3/3] tools: memory-model: Improve data-race detection To: "Paul E. McKenney" , Alan Stern Cc: Andrea Parri , Boqun Feng , Daniel Lustig , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Will Deacon , Herbert Xu , Kernel development list References: <20190621084129.GA6827@andrea> <20190621235439.GJ26519@linux.ibm.com> From: Akira Yokosawa Message-ID: <91a9c6f8-7bbf-376d-b1e0-0e2693c84ee8@gmail.com> Date: Sun, 23 Jun 2019 18:37:14 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190621235439.GJ26519@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ 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 Thanks, Akira >>>> >>>> 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. >>>> >>>> Signed-off-by: Alan Stern >>>> Reported-by: Herbert Xu >>> >>> For the entire series: >>> >>> Acked-by: Andrea Parri >>> >>> Two nits, but up to Paul AFAIAC: >>> >>> - This is a first time for "tools: memory-model:" in Subject; we were >>> kind of converging to "tools/memory-model:"... >> >> Yeah, sure. That's the sort of detail I have a hard time remembering. >> >>> - The report preceded the patch; we might as well reflect this in the >>> order of the tags. >> >> Either way is okay with me. > > I applied Andrea's acks and edited as called out above, thank you both! > > Thanx, Paul >