Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1562388lqo; Sun, 12 May 2024 07:58:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUifBM8cuWRqc3EuAy+4bcOsoNoF71IrfyTd/f3skOJJbzGPOin6+8JDU76khqleSKVhx2IiqApcQZnj1dD6iJUcSu2jhcGouNFMSpXLw== X-Google-Smtp-Source: AGHT+IGdYtg/PG2hkHwTEPhm+5NyfyY2foqP3Xz6hflRzAFcgIbo9gO50m4mIWKE+izGna7KnGuG X-Received: by 2002:a05:6358:431c:b0:17e:8e7f:59f9 with SMTP id e5c5f4694b2df-193bcfc5b63mr916458755d.26.1715525881642; Sun, 12 May 2024 07:58:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715525881; cv=pass; d=google.com; s=arc-20160816; b=oPHV/zjKBmE4lz6qB8EvSeMHVR0GbcZ4t6OueiPPOw4bIyP2g8c+GCkJNrfRVM4vt4 A9v3IidwsQtUXY7ZSf6RV5wJsTnDkp21w8Mm2h3OliybJev34URaYwwEc4oMvUkQDa32 mqQhdkt13JM3mwQKpvts6ldg39Los1QKi4e3ffk85CJclAToz5/QtAQLRw915K9DGM3X IJAGbFWO/GzUtNq3ceLv/Y7E2DRN6xnCgmTaaAzdT56Z+htNgCWMYLl+2QCUEVazBtaf XUAsafuccYwrGBG3+MdKNpsNgskfCECdK7BGypCXgEFeqcsYHg5jdf3CjT+40YHJZY4p f27A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=pk75m6cLDzivKCLkwY7Fp2xZX1a0jyhNZwN+WZj/STI=; fh=ta/AWrqpBnkTjfn7SHqgQbWj9PGTpah1H21k6ji8tSU=; b=M9g1D3VZ/IE4Ji8MNXt/ntbDpFgzpBOFhYEpYOPLeOVw442H6w4EO8U8/b7kq5mTge pisAaErzFcomvsX1AvQLkClza+CZ2GLq4BQdYUGxxx8enlB6KAKO9UiWx1xthmWJTtY/ Pz//nsOQOXX2eAaIpCZHH+FU4B29QKx+IpvlvSuGO7A+2up5o8UXZ/BM9gl3YNJy13U2 5XU0ZdqeipmfJvjaqv4r08QALo/EzM6boB1674WtYHsQ/VN6zBsiOe3cOfWVtRa9gb9+ doX9HXsAZDC+UUaXdkyDPvDdPvEPnbRxdv4PThntwmKAiZ9xID4BKEHq6XHYn20mPunM XPKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cVSj0Oht; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176905-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176905-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412f140c3si7505632a12.780.2024.05.12.07.58.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 07:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176905-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cVSj0Oht; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176905-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176905-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BD7AFB20B97 for ; Sun, 12 May 2024 14:57:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 890232E827; Sun, 12 May 2024 14:57:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cVSj0Oht" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5F3C1C683; Sun, 12 May 2024 14:57:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715525871; cv=none; b=tkc4jDU2m9lgTMcfp8TlxaxFkHHfTnbat94E704vAW1N5T/2aJQsqZ8Pe+tJQgTyTAJgSh3CRONao0LKluc0ii6TGXh0/I06Q7RcZQuS5n4RR8XGtOItpeWQqJv19Xp19s3yEVM4wfC6MmckK+qB1wvtCCubdXvm2fki7RQgf3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715525871; c=relaxed/simple; bh=q9eH8/eFg6/9RnNca9YlQBwsiRfQ4xzp1iIUc84JUa8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CX5EBjMqbwC3/7KLtAzXdVv33sJ0Pg7k9X6fZw+HnZSmYIjln6cWjYTc2rPsmCr83LI2vIHoxnvoS6lrJq7xlKutMDjp52VLWz99B3xMq2r/Tf4EpmDhDj0So7d/WljEVK+oMkFy9CQJwsUJ0r/9ys8NRUUxJmdHOnq2crGFhPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cVSj0Oht; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D574C116B1; Sun, 12 May 2024 14:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715525871; bh=q9eH8/eFg6/9RnNca9YlQBwsiRfQ4xzp1iIUc84JUa8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=cVSj0OhtDq8l0Jj/CKq6Ythv6D7HpvruflZM+djSyZc+49ww12/j4vbhxBZFHTH48 nZas8B/kfFT2ZoMnDvxkTmFX9Gclhh5x6cB9LWzUVeJS4Jcs4/i46KNG6xMdGezPHP Dd/KpYXNzFrhSJ+CxbQF8PaPZS2RAjh5izxcHWqqSmK2sxTp3QhPJWdio6Ah15VzmF XWdaEWT2w3Owj+DjFkPnqfDSqSQTAXLOYvX1IYhAel6rYHnGYageW4Nq7DSSRybHe+ Tg2Z4N6INfMwa05dChYR1TFKj8MlcnlZCsfa6lKWrkA4/zXILJN0z5UlHQ5t+XDI9G GzOji2qSZjPhA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7A3D1CE105C; Sun, 12 May 2024 07:57:50 -0700 (PDT) Date: Sun, 12 May 2024 07:57:50 -0700 From: "Paul E. McKenney" To: Oleg Nesterov Cc: "Uladzislau Rezki (Sony)" , RCU , Neeraj upadhyay , Boqun Feng , Hillf Danton , Joel Fernandes , LKML , Oleksiy Avramchenko , Frederic Weisbecker , Peter Zijlstra Subject: Re: [PATCH 25/48] rcu: Mark writes to rcu_sync ->gp_count field Message-ID: <26f2d843-b76f-452a-a5d0-b3a146351bb2@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240507093530.3043-1-urezki@gmail.com> <20240507093530.3043-26-urezki@gmail.com> <4c9e89b5-c981-4809-8bc2-247563ce04e9@paulmck-laptop> <20240509151312.GA22612@redhat.com> <20240510113149.GA24764@redhat.com> <8ca02df3-5034-4483-8e64-3fc22eb14431@paulmck-laptop> <20240512105305.GB7541@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240512105305.GB7541@redhat.com> On Sun, May 12, 2024 at 12:53:06PM +0200, Oleg Nesterov wrote: > On 05/10, Paul E. McKenney wrote: > > > > On Fri, May 10, 2024 at 01:31:49PM +0200, Oleg Nesterov wrote: > > > > > Why is that? > > > > Because I run KCSAN on RCU using Kconfig options that cause KCSAN > > to be more strict. > > Yes, I see now. > > > > but how can KCSAN detect that all accesses to X are properly marked? I see nothing > > > KCSAN-related in the definition of WRITE_ONCE() or READ_ONCE(). > > > > The trick is that KCSAN sees the volatile cast that both READ_ONCE() > > and WRITE_ONCE() use. > > Hmm. grep-grep-grep... I seem to understand, DEFINE_TSAN_VOLATILE_READ_WRITE. > So __tsan_volatile_readX() will use KCSAN_ACCESS_ATOMIC. > > Thanks! You got it!!! > > > And what does the "all accesses" above actually mean? The 2nd version does > > > > > > WRITE_ONCE(X, X+1); > > > > > > but "X + 1" is the plain/unmarked access? > > > > ... > > > > In that case, the "X+1" cannot be involved in a data race, so KCSAN > > won't complain. > > Yes, yes, I understand now. > > Paul, thanks for your explanations! and sorry for wasting your time by > provoking the unnecessarily long discussion. Not a problem and absolutely no need to apologize! Of course, please do pass this information on to anyone else needing it. > I am going to send the trivial patch which moves these WARN_ON()'s under > spin_lock(), this looks more clean to me. But I won't argue if you prefer > your original patch. Actually, I like your patch quite a bit better than I do my original. In fact, I feel quite foolish that I did not think of this to begin with. With your way, we have strict locking for that field and can therefore just use plain C-language accesses for all accesses to it. KCSAN will then warn us of any buggy lockless access to that field, even if that buggy access uses READ_ONCE(). Much much better your way!!! So thank you for persisting on this! Thanx, Paul