Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4958880ybv; Mon, 17 Feb 2020 09:13:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyytKwxi+C2QBU5i/eKyYfHHtuKveqyT8bj/BJggenIOpnpSqvo4+LdotobDM6GsvlwIQfJ X-Received: by 2002:a9d:7b50:: with SMTP id f16mr13016331oto.18.1581959621540; Mon, 17 Feb 2020 09:13:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581959621; cv=none; d=google.com; s=arc-20160816; b=g/eLIGquO/9QVy6zLUUKAhrcW8VqJfQBq0nw25UIn8RbPUA9VjQSb3+UODXHhzrZ8g mRqgOgC/7KFfACT5UTJXDnHsT2v1ej0+LzDeI3CeATe9fs2vU31auQO7LRiQD6wAU1cX JffoSVZ0gGkcvgaLSAPi+ZhdD5VLPEk48RI/mFarDtTb1f+KK8/UbcvTRVKoHTSETnCd RqJGgesbjagFCd+dMzcxQdaFusTwCkR+Qx7f7645YO8XCvZZDCuhKLW3aRJy8nplshFP dZEvILItd19tXTtua5RffHTa/LhThNZyIrx+DKf0S61f1HLyBk5mhC2hH9Uh3wZk+ua1 odJg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=hAkY+PHcqgUVHvVTlHhhrkpeznoFmCxKBnJE+5h2WKM=; b=qeCRK0bbcMFy9DClW9Shd75M0ScQY7VX4Wd+cikhpsGZQubaRMlY+5R7c6s6y0AFHT ef46mV54CtY4wg2mlMucvEUoy4RB3axBUeXF0C42ZmiPR1au7JDe6MNDjOJm7dkWl/I7 1F3oa7TS8tWhlXD1g5wRiRoOLLMPGjpYg9JL/1h1+tXSNPGvv2j0FqBqSxFF4hyBZICh uSpVoaS3yGMVpXxeTu+qCtaYXxx7bga+lWxbKp07McpxFskhevL2+AFRTA+/pWxrILBQ LCtYSuhCQOuvrz7g+4zdozbi0/rFTzJZmQU7P95lWlbyqpa6yE/NffG4T3GZxRPATkhw d3rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rLOREUYK; 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 w24si6526184oic.260.2020.02.17.09.13.29; Mon, 17 Feb 2020 09:13:41 -0800 (PST) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rLOREUYK; 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 S1729021AbgBQRLn (ORCPT + 99 others); Mon, 17 Feb 2020 12:11:43 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:40548 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbgBQRLn (ORCPT ); Mon, 17 Feb 2020 12:11:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hAkY+PHcqgUVHvVTlHhhrkpeznoFmCxKBnJE+5h2WKM=; b=rLOREUYK7Hx54iTQMj70doR7BS 55qa4HZJnZwT8W7SO/rDdJ6eYzDXi+Xy4ZnYcsI+j9fLHfDDkyqnvPXzwc9rzKoz5VJAWsaYFklt6 p0lVZ+Hy8kFcRcgXwGG9v2riXi4cUFAFF2I8fhzXq6m7bquRtoSOagVOiGSMkWLsSA/vyJd3rzxHN yLFophGX+1BDxY2AeeUfS5sR2Ey7l03o/E/tzadmJlJnedxErXGhAd/vECOCJBOfSFWZWspHulgtK leqEOxpnm01qR5eF3fv8kL8HEJWkhN9RR3kZSB4tqZkuynE6SRd1qPb6ORBOvfoJ8cE/zquDUFhHw XM2g6dWA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j3jvH-0007Cc-2T; Mon, 17 Feb 2020 17:11:07 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 32B71300565; Mon, 17 Feb 2020 18:09:13 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 86C5B2B92586D; Mon, 17 Feb 2020 18:11:04 +0100 (CET) Date: Mon, 17 Feb 2020 18:11:04 +0100 From: Peter Zijlstra To: Joel Fernandes Cc: paulmck@kernel.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com Subject: Re: [PATCH tip/core/rcu 1/4] srcu: Fix __call_srcu()/process_srcu() datarace Message-ID: <20200217171104.GV14914@hirez.programming.kicks-ass.net> References: <20200215002907.GA15895@paulmck-ThinkPad-P72> <20200215002932.15976-1-paulmck@kernel.org> <20200217124231.GS14914@hirez.programming.kicks-ass.net> <20200217170157.GA166797@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200217170157.GA166797@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 17, 2020 at 12:01:57PM -0500, Joel Fernandes wrote: > Peter it sounds like you have a failure scenario in mind. Could you describe > more if so? > > I am curious if you were thinking of invented-stores issue here. > > For educational purposes, I was trying to come up with an example where my > compiler does something bad to code without WRITE_ONCE(). So far I only can > reproduce a write-tearing example when write with an immediate value is split > into 2 writes, like Will mentioned: > http://lore.kernel.org/r/20190821103200.kpufwtviqhpbuv2n@willie-the-truck > But that does not seem to apply to this code. > > > - snp->srcu_gp_seq_needed_exp = gpseq; > > > + WRITE_ONCE(snp->srcu_gp_seq_needed_exp, gpseq); Yeah, store tearing. No sane compiler will actually do that, but it is allowed to do random permutations of byte stores just to fuck with us. WRITE_ONCE() disallows that. In that case, the READ_ONCE()s could observe garbage and the compare might accidentally report the wrong thing.