From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8370FC001DC for ; Sun, 9 Jul 2023 14:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjGIO4A (ORCPT ); Sun, 9 Jul 2023 10:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjGIOzz (ORCPT ); Sun, 9 Jul 2023 10:55:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8BE21AB; Sun, 9 Jul 2023 07:55:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 157A060BF9; Sun, 9 Jul 2023 14:55:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 813D2C433C7; Sun, 9 Jul 2023 14:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688914544; bh=M9NtEIl64nDsKbemZul2F308cM8vsEwL8bCzuitqG1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M8vgA6+UgZdpDU91bAj3vH2KNBkf9yrmrFshaB472v7VVdnfBvRI/1T8t7ScTmO1s 1oIQ8suwaMg+SurF9WzAnw2WioNi4snp/zKDMfhBYAS2aqKNNIKrTowjdW3yODQ3/l r1h+Ww8+Sz/pHCNrk/xMjPXBW3jJgSi4AWqZIdO0IgXLXLyxx7FVjBoELGEKd/lZVq u1/Gd0DJ/Yr65UW6fjHvW4gYeSHZOYAWVJ61nCosAX3FFodbsM5HtvdpJkC4aVRha+ e5ffkxATciPG4pdiY0H0e6XEP09Aa4ukPb7g2acsOyafSaxWCSdIm/4O37yt7xJyoD CwSI+vBKQIdeg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Paul E. McKenney" , Sasha Levin , frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org, josh@joshtriplett.org, boqun.feng@gmail.com, rcu@vger.kernel.org Subject: [PATCH AUTOSEL 6.3 3/3] rcu: Mark rcu_cpu_kthread() accesses to ->rcu_cpu_has_work Date: Sun, 9 Jul 2023 10:55:38 -0400 Message-Id: <20230709145538.512238-3-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230709145538.512238-1-sashal@kernel.org> References: <20230709145538.512238-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.3.12 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit a24c1aab652ebacf9ea62470a166514174c96fe1 ] The rcu_data structure's ->rcu_cpu_has_work field can be modified by any CPU attempting to wake up the rcuc kthread. Therefore, this commit marks accesses to this field from the rcu_cpu_kthread() function. This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely. Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- kernel/rcu/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index a565dc5c54440..fbba4161060cd 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2455,12 +2455,12 @@ static void rcu_cpu_kthread(unsigned int cpu) *statusp = RCU_KTHREAD_RUNNING; local_irq_disable(); work = *workp; - *workp = 0; + WRITE_ONCE(*workp, 0); local_irq_enable(); if (work) rcu_core(); local_bh_enable(); - if (*workp == 0) { + if (!READ_ONCE(*workp)) { trace_rcu_utilization(TPS("End CPU kthread@rcu_wait")); *statusp = RCU_KTHREAD_WAITING; return; -- 2.39.2