Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5930956pxv; Thu, 29 Jul 2021 01:56:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1rOdI9dh8T9RtiQAdxWwqHu/2dTafn7uotTE0to7UJCsVRe/47Zl65Y/QEEbCin6vHlrm X-Received: by 2002:a17:906:705:: with SMTP id y5mr3514259ejb.149.1627549009647; Thu, 29 Jul 2021 01:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627549009; cv=none; d=google.com; s=arc-20160816; b=ZalbmU+LYDDaw8BSxN7GA5BHZgtppW1DdlWg0t5M5eWVHGBKaBzze2cogFwBbrqGXe 5WOKWl5Tqn8G/pGYFi/DI2eqkKBXhUJoiDkVJm20waxDtYN7jE+Gy2j0opLoSXp6MExs VDAvzFyV5+MH263uuwUzciU6DUts9ri43RmpC9rNonoTXE7WgGcRB4fgI+G2GDi6s34T Kq9JyYp4yMmcij6g5Iu8cXOs9TafuQDELOLoV5+pNtdPY3ETESWiBwLEJ8J1eII0vxhu 9h6GW6U4jDlz6bAZUCid2SijyFZKDBtPfnVFh37yyuvGUh5JwdJ0YUXrpJjzHa3VVNy5 FaBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=N6vdYNDn6gd/T46MoBvG9s7ZIUiNhoAqMIBR6eS+uK4=; b=D7emk4XmYRdZoQ7Q+q8heDaO1zFopB8kOE1tMIQyYR7byYLE2ch25o1h7ngTbQ0vCb 1RzHQg3KbTMj9xBgE06k8LN24CtjdewasJ+NtAFzNFSkG07Tg+z3s2xRADGRYIwGo3u4 NLV1kArhIi7l68mUXiNqhlE1oJotsb6klLuqwGfnWixYX+/e8rhU/rETjlkiOt2a9iYZ 07RjXBwUg1rStxwQDb6Tv0w2L2wMTQTtD8cgdsXGQ2IS6gUj7OAjW0GrehvcJwrHxwT8 QiLZgL2OoEOKPiFtTMsDNjHcBOrnp0+4okpiobxTtz57pjgGa63AXB1nrieJRFROIt9X a0aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SB763H4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id qa43si2269147ejc.484.2021.07.29.01.56.25; Thu, 29 Jul 2021 01:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SB763H4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235257AbhG2IzC (ORCPT + 99 others); Thu, 29 Jul 2021 04:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234886AbhG2IzA (ORCPT ); Thu, 29 Jul 2021 04:55:00 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D2EC061757; Thu, 29 Jul 2021 01:54:57 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id h1so6071098iol.9; Thu, 29 Jul 2021 01:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=N6vdYNDn6gd/T46MoBvG9s7ZIUiNhoAqMIBR6eS+uK4=; b=SB763H4tZcqpohMFCcNoF3GvCHnSZH8J+1quC9EHsN9XT3wwkZ4bm5jiWcIIqC8OXc zOo0iCGGbZLvmBDVVzc6K2yOgfBhyqoMPfcrpvzh9gbrpQXskubfZmnSNA7oVbP4uebY VvadoyZY32RbBf8/+pZQBC3na7qgndXVf09uYRflCvM9thfeWnrwvQKA3tsrtYNLfREN FviecqjwcNMwexaytGgGICvlEGk3KEAFdUlHU9l9yLU7DpcyogctoSN/DY2g8LKLX4FD 8ICByIYfueJPPbt8ZVunfHF11wb+MrjEFkFZYtNvD6aeS8yLtcRs97JFPx/cSlkPJ7sk /XUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=N6vdYNDn6gd/T46MoBvG9s7ZIUiNhoAqMIBR6eS+uK4=; b=d/Q/FqtZrDg+QS9FPKseMPUr7q7qwdw9oJTpTgJ/jK28w2nCRIw7ZHs+OUB/M6snkX L3nqZxkaiG17mSaGADyMtZ2jc53DKLUEG0IlsUYbzpRTiTH8xm9U1dl0SF9yWstq/vsj nNUodwVKqzK7SonAQlv/iYqVpUpZenevcxEErNQLzrXF3s9QBSl4xBQHPmn6WR0cMVFc Fq4y8gUhLaBg5xo02dCEwL4ULHuciN7bmv55cn2h86hn+72dsSB8MzdV4LNYcOz+JgKS NpC07Wcvx2khnUyFEZAvQ++K2me3q6H3CMnc6nzWNRnCYrdCIqOe7QWLTWAXvqd4jIYF LFaw== X-Gm-Message-State: AOAM533eMnZ3qE8XtCFrWx/9OFgq3cmsPDwgGy5dlkmcpH9mnvKbGAL/ +CXO0qlee3V0LK7Sd7QQPsA= X-Received: by 2002:a6b:f813:: with SMTP id o19mr3161518ioh.49.1627548896275; Thu, 29 Jul 2021 01:54:56 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id k4sm1826601ior.55.2021.07.29.01.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 01:54:55 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 66B7027C0054; Thu, 29 Jul 2021 04:54:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 29 Jul 2021 04:54:54 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrhedugddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpedvleeigedugfegveejhfejveeuveeiteejieekvdfgjeefudehfefhgfegvdeg jeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Jul 2021 04:54:52 -0400 (EDT) Date: Thu, 29 Jul 2021 16:54:30 +0800 From: Boqun Feng To: "Paul E. McKenney" Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org Subject: Re: [PATCH rcu 11/18] rcu: Mark lockless ->qsmask read in rcu_check_boost_fail() Message-ID: References: <20210721202042.GA1472052@paulmck-ThinkPad-P17-Gen-1> <20210721202127.2129660-11-paulmck@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210721202127.2129660-11-paulmck@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 21, 2021 at 01:21:19PM -0700, Paul E. McKenney wrote: > Accesses to ->qsmask are normally protected by ->lock, but there is an > exception in the diagnostic code in rcu_check_boost_fail(). This commit > therefore applies data_race() to this access to avoid KCSAN complaining > about the C-language writes protected by ->lock. > > Signed-off-by: Paul E. McKenney > --- > kernel/rcu/tree_stall.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h > index 42847caa3909b..6dd6c9aa3f757 100644 > --- a/kernel/rcu/tree_stall.h > +++ b/kernel/rcu/tree_stall.h > @@ -766,7 +766,7 @@ bool rcu_check_boost_fail(unsigned long gp_state, int *cpup) > > rcu_for_each_leaf_node(rnp) { > if (!cpup) { > - if (READ_ONCE(rnp->qsmask)) { > + if (data_race(READ_ONCE(rnp->qsmask))) { If the write sides allow normal writes, i.e. allowing store tearing, the READ_ONCE() here could read incomplete writes, which could be anything basically? And we get the same result if we remove the READ_ONCE(), don't we? Yes, I know, without the READ_ONCE(), compilers can do anything to optimize on rnp->qsmask, but the end result is same or similar to reading incomplete writes (which is also a result by compiler optimization). So if we mark something as data_race(), **in theory**, it makes no difference with or without the READ_ONCE(), so I think maybe we can remove the READ_ONCE() here? Regards, Boqun > return false; > } else { > if (READ_ONCE(rnp->gp_tasks)) > -- > 2.31.1.189.g2e36527f23 >