From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E9A402652A2; Fri, 31 Jul 2026 01:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; cv=none; b=osQfszL0RJnYDhCWD+LJiP374MKajKJf1iOcc/A6u+eeCUtPjCmL1BIib5nzPlYgBDUvKz5z89Q5MTJcLzGsd0Qdwcq1fex+fQbwZ4FI3QSbthRMglbp4s3a6Lpi4sSVroXBR4nvvSt4A73iV3rneXEXuem9BnuSJpIbNUa3Q3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; c=relaxed/simple; bh=TJZl+inXya+bKzsV0ZvGX1qSGLWmt0PKu81BCP+l2Vs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u5ogCeetI7OqjJO6Pf5A7oN3M9Kvf4ReVfjXmIaVibbPcm/O4Bt6l8grCLYdO6l/E//AkIENzYEkMeLq31PtfUAQI5WUamHSpkXckDCoQxS5F3HbuZUVXMkigOpHaiMITHj5I9zNzMtsVoiOI9zZS4QzLhn0T1SZvt4AGitPl14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oVosythP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oVosythP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEEAC1F000E9; Fri, 31 Jul 2026 01:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459714; bh=s2pp7xMhQIRb1HuLwmqNhcY2hIgp6WI9Kbpk3dFfE+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oVosythPGk7D2HpLk3M91yT0ICL70zbyO4F6yyIPtG6/nsTrOAu0pV2A/2yZnHqLa CCgLcow6lgR7lmK4XhGvto5ZKmUA0sTbfuVnjAeGyPWbsl8ICxtS5eqKpceDIea1Zs KklzvTTlKy1y70BcCTHCi+DA2ig8M3skfN4LIFPY0RFQst8rAAVyFEuOQycafgtj/e ZKpPhUpgg1B9S3b8swzYIYbGb9SfeIgD6rPW4qZZNPSOxJpLYfsRgKntJeNtOT6qcG VMxDuWyDIgcDpmLUQou+bzZUjxi5mRdsaEmo/7ifr+Kg52ToCBJ7pZudnevyXQb2sU Dcqrl4KQb9gew== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A3370CE0F69; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Kunwu Chan , Zqiang , Wang Lian , "Paul E . McKenney" Subject: [PATCH RFC 01/16] rcu: Use task_state_to_char() in stall-warning prints Date: Thu, 30 Jul 2026 18:01:38 -0700 Message-Id: <20260731010153.3531313-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kunwu Chan RCU stall warnings currently print task states as raw hexadecimal values, requiring developers to manually decode them. Use task_state_to_char() so that stall warnings show the same symbolic task-state representation used elsewhere in the kernel. For example: ->state=3D0x402 becomes ->state=3DI ->state=3D0x0 becomes ->state=3DR ->state=3D0x2 becomes ->state=3DD This improves readability while preserving the underlying diagnostic information. Suggested-by: Zqiang Co-developed-by: Wang Lian Signed-off-by: Wang Lian Signed-off-by: Kunwu Chan Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_stall.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index cf7ae51cba4033..45b9856ccd2b23 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -573,13 +573,13 @@ static void rcu_check_gp_kthread_starvation(void) =20 if (rcu_is_gp_kthread_starving(&j)) { cpu =3D gpk ? task_cpu(gpk) : -1; - pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=3D%= #x ->cpu=3D%d\n", + pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=3D%= c ->cpu=3D%d\n", rcu_state.name, j, (long)rcu_seq_current(&rcu_state.gp_seq), data_race(READ_ONCE(rcu_state.gp_flags)), gp_state_getname(rcu_state.gp_state), data_race(READ_ONCE(rcu_state.gp_state)), - gpk ? data_race(READ_ONCE(gpk->__state)) : ~0, cpu); + gpk ? task_state_to_char(gpk) : '?', cpu); if (gpk) { struct rcu_data *rdp =3D per_cpu_ptr(&rcu_data, cpu); =20 @@ -616,12 +616,12 @@ static void rcu_check_gp_kthread_expired_fqs_timer(vo= id) time_after(jiffies, jiffies_fqs + RCU_STALL_MIGHT_MIN) && gpk && !READ_ONCE(gpk->on_rq)) { cpu =3D task_cpu(gpk); - pr_err("%s kthread timer wakeup didn't happen for %ld jiffies! g%ld f%#x= %s(%d) ->state=3D%#x\n", + pr_err("%s kthread timer wakeup didn't happen for %ld jiffies! g%ld f%#x= %s(%d) ->state=3D%c\n", rcu_state.name, (jiffies - jiffies_fqs), (long)rcu_seq_current(&rcu_state.gp_seq), data_race(READ_ONCE(rcu_state.gp_flags)), // Diagnostic read gp_state_getname(RCU_GP_WAIT_FQS), RCU_GP_WAIT_FQS, - data_race(READ_ONCE(gpk->__state))); + task_state_to_char(gpk)); pr_err("\tPossible timer handling issue on cpu=3D%d timer-softirq=3D%u\n= ", cpu, kstat_softirqs_cpu(TIMER_SOFTIRQ, cpu)); } @@ -948,10 +948,10 @@ void show_rcu_gp_kthreads(void) jr =3D j - data_race(READ_ONCE(rcu_state.gp_req_activity)); js =3D j - data_race(READ_ONCE(rcu_state.gp_start)); jw =3D j - data_race(READ_ONCE(rcu_state.gp_wake_time)); - pr_info("%s: wait state: %s(%d) ->state: %#x ->rt_priority %u delta ->gp_= start %lu ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_w= ake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_max %lu ->gp_flags %#x\n", + pr_info("%s: wait state: %s(%d) ->state: %c ->rt_priority %u delta ->gp_s= tart %lu ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wa= ke_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_max %lu ->gp_flags %#x\n", rcu_state.name, gp_state_getname(rcu_state.gp_state), data_race(READ_ONCE(rcu_state.gp_state)), - t ? data_race(READ_ONCE(t->__state)) : 0x1ffff, t ? t->rt_priority : 0xf= fU, + t ? task_state_to_char(t) : '?', t ? t->rt_priority : 0xffU, js, ja, jr, jw, (long)data_race(READ_ONCE(rcu_state.gp_wake_seq)), (long)data_race(READ_ONCE(rcu_state.gp_seq)), (long)data_race(READ_ONCE(rcu_get_root()->gp_seq_needed)), --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 071E0288C2C; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; cv=none; b=ttPykrrfVd7xC1mJgB22GsbIyzwopFIqjXHHvmmxccJxzKMEeISpF2oJ26HQWtAzOqD1VIVRa2EAVid+lGgSrkaZ06WgCGuzFHZh3kRZUZAU+/mqYd/R/tuvLL+X6LofVhRIp+sAG9R9BFnwBqSS8VxruB2LWwsaUWH3kojxQ4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; c=relaxed/simple; bh=Yl88lflJiv8h6fgZKJ4Y2kkrLo395TLzV3PY6LBaolk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KOTlqHJd19Hw6IV7mXA3oLO6HSmQ82fr2ZHltVIe8RLaEvkZJ/saK9fYKoQqrpHK6L81yF1cvHkO2EMXWiVLsJBE7qKA5hg4Ce/xUs/9+c5RApqW2+5CYA95tS83SzuCTP6aXGgcd+S5pckFImKGJMl0aeGQd0FfgxnNDUbbAuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jczWSYcT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jczWSYcT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBCEB1F00A3A; Fri, 31 Jul 2026 01:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459714; bh=GwXWaesWDGtEGGBh/9BmcgoD/ocnRp5Yoj+6V8USxfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jczWSYcTlRJK7Z1iKi8oiE8NDVe5SwbpH+CeU7pGz2v7DvoowAezbttaljzxwkGgd f94IA8v0Ut01L5GN27ZmyZBXlJTc+iVc4L63mJuUaBrVDWhh0lBWdAEOUMo4nR+368 SZNjDtdjAZvXlC/rdcQCUNgs1JmvwBLAujFmrylKB6u4o0yiDonsxDAAvS0iaUdz6h zZ5cQA2u5NsaaG0sfx3Fw/4GqsCejtzNIy8vSV/ybOhx4AXnZCa5d0a8HG9Am4mFIj VQCMyLs2GszzdcZvTVKnJ6OT2OyWYGcTGykmdxd95GZiIXIXVYImoi+xmax4pL18V1 /kHuEDbbN7kjQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A54E6CE0F6A; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Christoph Hellwig , Marco Elver , Nilay Shroff Subject: [PATCH RFC 02/16] rcu: Mark __rcu_access_pointer() as context_unsafe() Date: Thu, 30 Jul 2026 18:01:39 -0700 Message-Id: <20260731010153.3531313-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A simple comparison of a pointer returned by rcu_access_pointer() results in a context-analysis warning for lockless inspection of the RCU-protected (also known as __rcu-protected) pointer. This can be suppressed by placing context_unsafe() calls around calls rcu_access_pointer(), but this is messy and distracting. This commit therefore wraps the underlying __rcu_access_pointer() macro with a call to context_unsafe(), thereby informing the context-analysis code that rcu_access_pointer() may safely be invoked outside of an RCU read-side critical section. Reported-by: Christoph Hellwig Suggested-by: Marco Elver Signed-off-by: Paul E. McKenney Tested-by: Nilay Shroff Reviewed-by: Marco Elver --- include/linux/rcupdate.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 5e95acc33989b6..e40dc2e20c5b1f 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -490,12 +490,12 @@ context_unsafe( \ */ #define unrcu_pointer(p) __unrcu_pointer(p, __UNIQUE_ID(rcu)) =20 -#define __rcu_access_pointer(p, local, space) \ +#define __rcu_access_pointer(p, local, space) context_unsafe( \ ({ \ typeof(*p) *local =3D (typeof(*p) *__force)READ_ONCE(p); \ rcu_check_sparse(p, space); \ ((typeof(*p) __force __kernel *)(local)); \ -}) +}) ) #define __rcu_dereference_check(p, local, c, space) \ ({ \ /* Dependency order vs. p above. */ \ --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 50F322C0F6D; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; cv=none; b=qTQGtyuqKmpib5YhqxvMiL7QYwwzOGkDhtfN0oF3NTJ+Xb7g5aQGF2C5UNotx3Qf8hmF1FpX1MZaxF08eUc4t3OMgPAQKjjhmkKiP9PdAtQDg3BM5Z896h5V6QdtpcJugN4Jkxg/T0nGKgbPqvewGmVRzES7TxfE7F3+zUI36WI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; c=relaxed/simple; bh=EkZRF18fal3/zfiMFfCdfrq65vTfzdrDabPLzL+E9kg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CGgC/uXzIuWGG6xymPBGkUQAWw/Hpdj2VrnzsXD3hO4TQ9Z6+w8+BRMgzmYIfPOlOlOT9Uj849cPg3ZqJEok19WUonuUg3qNDDehaaj3yHDPdo7bvp7r7TULF/2cQE1GzYQjxCJAmtwmSL8cA6yYF9M1B4ZfXByHT3Wp0QQtW2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JvIPmG7c; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JvIPmG7c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5EBE1F00A3D; Fri, 31 Jul 2026 01:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459714; bh=6v74Vr+JDl4aQFyesJLzqi6KC90vCW4EqJ5C7/ir9F0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JvIPmG7cQqWKmkS+GhW4MMqtErHMSpLcLj0WwFLiCgw9Ne4rxCOkd5RbhW4Grmg9U PlprtAtQQv13/GB6drk2/OWp8XH7sLAt2R6B0CbTe9Txr/71zOIkTZ+XJCmqbxeLyM nXp5xJHFAszFcyOCZHVVyuBoidFT9rIEMF6nlsl/M5IVngw42UOwbpAsOj66SgC9SI AWu+BjYZvyZuTpRy6YtPVqaIcPLzsIsOfsRGK1velNrHCmVWs82pDQlUGL8wLbxTdg ptOxb7COVPV4w7uy2n3ADLT6y2EMRUuVdUcLjWaMhAOXTihbZYsx28ZEy5S5kQm3Q9 GiCgIcNBT02pA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A7ED3CE0F7B; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Manuel Ebner , "Paul E . McKenney" Subject: [PATCH RFC 03/16] doc: RCU: Adopt new coding style of type-aware kmalloc-family - part 2/2 Date: Thu, 30 Jul 2026 18:01:40 -0700 Message-Id: <20260731010153.3531313-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Manuel Ebner Update Documentation/RCU/* to suggest using the new type-aware kmalloc_obj() per commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family") p =3D kmalloc(...); -> p =3D kmalloc_obj(...); Signed-off-by: Manuel Ebner Signed-off-by: Paul E. McKenney --- Documentation/RCU/rcu_dereference.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/RCU/rcu_dereference.rst b/Documentation/RCU/rcu_= dereference.rst index 2524dcdadde2b8..5bc3785ebfc2ae 100644 --- a/Documentation/RCU/rcu_dereference.rst +++ b/Documentation/RCU/rcu_dereference.rst @@ -236,7 +236,7 @@ precautions. To see this, consider the following code = fragment:: { struct foo *p; =20 - p =3D kmalloc(...); + p =3D kmalloc_obj(*p); if (p =3D=3D NULL) deal_with_it(); p->a =3D 42; /* Each field in its own cache line. */ @@ -293,7 +293,7 @@ Then one approach is to use locking, for example, as fo= llows:: { struct foo *p; =20 - p =3D kmalloc(...); + p =3D kmalloc_obj(*p); if (p =3D=3D NULL) deal_with_it(); spin_lock(&p->lock); --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 50EBD2BF002; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; cv=none; b=e1hO6JXjXsE3HAZtH2kpetC4DZcXl9zZvJo0CsuBWFN7BeFV5rvfTPwMlebcRux0TDdOmaLkiF1E5W5ran41ihP44c6e24YttZD7Tl90DEWxnddxE7Z232xn5ylNdLj700Iw/Wx/TilwX+9uClcZrRcgx61hvON/LFOgMAQW/Gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459716; c=relaxed/simple; bh=mc9NEZIorPJjdaORA+vKGv+Y4mGP0Y2nM4Pw5HrxZAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=doS5Zog+rkgqGkUeoOdirxi1S92ceolgcn51YkURJIU1wL4Qn/lnU00ZMH3TDOOmElDduOKwRntCK00byBFCJBzMd6zlMqJ3s+Kaa3dkEZu9ZBN0Mcr78jF9azy+fPzZtBdzUhY4JZmq2D3fL5NKCsBWhZnxXo23Yx6GvZeYEOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=maPutNAP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="maPutNAP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC6811F00A3F; Fri, 31 Jul 2026 01:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=eKklVX3VgDMz+JyKSn/kR/vQ4ctDUmrdEUdbFfrwoac=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=maPutNAPI44k6qTzuksN/BgRf9kU5SqmWZHIJwba/IcC/Oy4t/abGdlmDbyjs8pru 3EUJBTKi15CPUE80PBtm4TXpxXP/LASpArf+nvGNXhRGZWuyw45If1P4DSmTs/rZ61 uvN+F8OQNNpYgoMMdLP9IrEGFCHenEh0jJMbHD4ITeWfwhU2Cl0/cLsFmzhigH/fcg /W/MUfIioAyqV7s0VOmncgOBHQmlXpsJZrbw5ytEry9Y+ludqY7tPtQaf49ORUx3sO GKKgzScrAgxcraRLGyhrasEbAuNSo8o4zvF/GzrqmuV5mCEz41DTnXwwzhUE1GMSGx 5+3XzmSJzXnDQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AAE4BCE0F82; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Manuel Ebner , "Paul E . McKenney" Subject: [PATCH RFC 04/16] doc: RCU: Fix brackets Date: Thu, 30 Jul 2026 18:01:41 -0700 Message-Id: <20260731010153.3531313-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Manuel Ebner Remove needless brackets and add missing brackets. Signed-off-by: Manuel Ebner Signed-off-by: Paul E. McKenney --- .../Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst | 2 +- Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg | 2 +- Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg | 2 +- Documentation/RCU/Design/Requirements/Requirements.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Gra= ce-Periods.rst b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited= -Grace-Periods.rst index 414f8a2012d684..cf0f9cdca7e8cb 100644 --- a/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Peri= ods.rst +++ b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Peri= ods.rst @@ -410,7 +410,7 @@ workqueues (see Documentation/core-api/workqueue.rst). =20 The requesting task still does counter snapshotting and funnel-lock processing, but the task reaching the top of the funnel lock does a -``schedule_work()`` (from ``_synchronize_rcu_expedited()`` so that a +``schedule_work()`` (from ``_synchronize_rcu_expedited()``) so that a workqueue kthread does the actual grace-period processing. Because workqueue kthreads do not accept POSIX signals, grace-period-wait processing need not allow for POSIX signals. In addition, this approach diff --git a/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg b/Docu= mentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg index d05bc7b27edb7a..95a66de40ca5a2 100644 --- a/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg +++ b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg @@ -3933,7 +3933,7 @@ font-style=3D"normal" y=3D"-3914.085" x=3D"3745.7725" - xml:space=3D"preserve">rcu__report_qs_rdp()) + xml:space=3D"preserve">rcu__report_qs_rdp() rcu__report_qs_rdp()) + xml:space=3D"preserve">rcu__report_qs_rdp() To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Joel Fernandes , "Paul E . McKenney" Subject: [PATCH RFC 05/16] rcu: introduce rcu_defer_qs_clear() helper Date: Thu, 30 Jul 2026 18:01:42 -0700 Message-Id: <20260731010153.3531313-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joel Fernandes Currently rdp->defer_qs_pending transitions from DEFER_QS_PENDING to DEFER_QS_IDLE at two sites: rcu_preempt_deferred_qs_irqrestore() and rcu_preempt_deferred_qs_handler() (depth>0 reset). Both write the IDLE value directly. Introduce a single inline helper rcu_defer_qs_clear() in tree.h and route both sites through it. This becomes the single PENDING->IDLE transition point for upcoming work. Signed-off-by: Joel Fernandes Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.h | 5 +++++ kernel/rcu/tree_plugin.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 7dfc57e9adb18e..4069132f9d4446 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -296,6 +296,11 @@ struct rcu_data { int cpu; }; =20 +static inline void rcu_defer_qs_clear(struct rcu_data *rdp) +{ + WRITE_ONCE(rdp->defer_qs_pending, DEFER_QS_IDLE); +} + /* Values for nocb_defer_wakeup field in struct rcu_data. */ #define RCU_NOCB_WAKE_NOT 0 #define RCU_NOCB_WAKE_BYPASS 1 diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 95ad967adcf3cb..8637f405cb472f 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -488,7 +488,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *= t, unsigned long flags) =20 rdp =3D this_cpu_ptr(&rcu_data); if (rdp->defer_qs_pending =3D=3D DEFER_QS_PENDING) - rdp->defer_qs_pending =3D DEFER_QS_IDLE; + rcu_defer_qs_clear(rdp); =20 /* * If RCU core is waiting for this CPU to exit its critical section, @@ -645,7 +645,7 @@ static void rcu_preempt_deferred_qs_handler(struct irq_= work *iwp) * 5. Deferred QS reporting does not happen. */ if (rcu_preempt_depth() > 0) - WRITE_ONCE(rdp->defer_qs_pending, DEFER_QS_IDLE); + rcu_defer_qs_clear(rdp); } =20 /* --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3695B2D73A6; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459717; cv=none; b=jj5YSXnSQ9olrnDoax+CaA5GYTOEKcIfmqugrlrro83EBM+AkfKfhNR6ayKP3CeQL/4+9kGvVU0bxgYCa+TfoNB6Cwx91xwwS4uMq/7tiggnqlbiebLEQfyiLAsuGVOgvdyuBnmnGYt9FvmtI6on1opJma15KMk6z/OI7ZTPA9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459717; c=relaxed/simple; bh=5Fl+jixV+111LdJWKLj28h0xJ4Wa+YXtPbADF+JcAXM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NnU22gRyzQTt0axpihrilrRg0lyKuXwBGl+AsajITBeAxqWnsIgnisD4J99bfUC7ZSB2jLEUVskVcOvvtE9iYKMOgbUj6jnuQH0JqHVHOzzW9J5NvU5PvflOVKhhtz3xUJ8FQbkgIXM7h0mkimkp14GfVJEbS0sXkPaKaSUDjc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bMzIEYfm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bMzIEYfm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CAD31F00ADE; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=cYMHLUJByBXeSM5FJPpp9HkR0BuwBLZFM7nxWlaVTKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bMzIEYfmK/tsTBGqpBrQQjxy1OMwX4LM6ynhv+ZwkALHYtbFfm6ODM3CMtJWHw2JS 21ntdPJoFo2J1jhQ1/5l1y43k8/wYlrZ/EbCrZlAFWQ3bR6V02gv0pp+GKudcF/8sS 40rvsUUICxNn3+S8BovervNEoXq4SzPm0QiCHUXBN7z5gkx4RyLClx9hin6+/cY3ha zY+ovBd3lJYHMhAp37fbofxRN0CU7teJkhGemwDumJYiN5Sb1h+f/REzte1dPfyMGc 1gqDB0EqvH4xx3xCMtMZ0NYoETy3UKriorD40CZCu2ZrMKolWfND4X1gmenBS8qD2n yURM4TjjRTZLw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B019CCE1018; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Joel Fernandes , "Paul E . McKenney" Subject: [PATCH RFC 06/16] rcu: clear defer_qs_pending in deferred-QS bail when nesting > 0 Date: Thu, 30 Jul 2026 18:01:43 -0700 Message-Id: <20260731010153.3531313-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joel Fernandes Paul McKenney noted that a softirq (or irq_work) handler arming for a deferred QS can fire and find rcu_preempt_depth() > 0 -- the task is still inside its outer reader, so rcu_preempt_need_deferred_qs() bails without reporting the QS. At that point the queued mechanism has been consumed but ->defer_qs_pending stays in DEFER_QS_PENDING. In the meantime, the only remaining path back to a quiescent state on this CPU may be a local_irq_disable()/_enable() pair that does not call preempt_check_resched() (it is just `sti`/`cli`). patch 6's unconditional set_need_resched_current() makes need_resched true, but without an irq_work being raised the next outer rcu_read_unlock_special() hits the P-gate at the arming code: if (rdp->defer_qs_pending !=3D DEFER_QS_PENDING) { rdp->defer_qs_pending =3D DEFER_QS_PENDING; irq_work_queue_on(...); // <-- skipped } so no irq_work is queued for the hardirq-exit preempt_schedule_irq() path either. The deferred QS now waits until the next timer tick (or similar preempt-safe boundary), needlessly extending expedited grace period latency. Clear ->defer_qs_pending in the bail-out path of rcu_preempt_deferred_qs() when rcu_preempt_depth() > 0. The recursion guard semantics introduced by commit b41642c87716 ("rcu: Fix rcu_read_unlock() deadloop due to IRQ work"). The clear is also safe against fresh recursion at this exact program point: rcu_preempt_depth() > 0 guarantees we are still inside an outer reader, so any inner rcu_read_unlock() from tracing infrastructure brings nesting back to outer (>0), never to 0. The slow path of rcu_read_unlock_special() is structurally unreachable under that condition, so no recursive raise_softirq_irqoff()/irq_work_queue_on() can be triggered by the clear. Essentially, the mechanism will work to prevent the following recursion which Xiongfeng had previously reported: irq_exit() -> __irq_exit_rcu() -> tick_irq_exit() -> tick_nohz_irq_exit() -> tick_nohz_stop_sched_tick() -> trace_tick_stop() // BPF prog hooked here -> rcu_read_unlock_special() -> irq_work_queue_on(&rdp->defer_qs_iw, rdp->cpu) // self-IPI re-= enters irq_exit Reported-by: Paul E. McKenney Signed-off-by: Joel Fernandes Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_plugin.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 8637f405cb472f..9ba136a4233a26 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -614,9 +614,35 @@ static notrace bool rcu_preempt_need_deferred_qs(struc= t task_struct *t) notrace void rcu_preempt_deferred_qs(struct task_struct *t) { unsigned long flags; + struct rcu_data *rdp; =20 - if (!rcu_preempt_need_deferred_qs(t)) + if (!rcu_preempt_need_deferred_qs(t)) { + /* + * If we got here from a softirq/irq_work that fired while + * rcu_preempt_depth() > 0, the deferred-QS mechanism has been + * consumed without doing any work: rcu_preempt_need_deferred_qs() + * just returned false because the task is still in a reader, so + * the actual QS report has to wait for the next + * rcu_read_unlock(). + * + * Clear ->defer_qs_pending here so the next outer + * rcu_read_unlock_special() can re-arm a fresh mechanism (in + * particular the irq_work path, which the local_irq_enable() + * recovery boundary cannot itself reschedule from). + * + * Recursion safety: rcu_preempt_depth() > 0 means we are inside + * an outer reader, so any inner rcu_read_unlock() reached via + * tracing (bpf programs attached to trace points) brings + * nesting to outer (> 0), never to 0, so no recursive + * raise_softirq_irqoff()/irq_work_queue_on() can be triggered + * by this clear. + */ + if (rcu_preempt_depth() > 0) { + rdp =3D this_cpu_ptr(&rcu_data); + rcu_defer_qs_clear(rdp); + } return; + } local_irq_save(flags); rcu_preempt_deferred_qs_irqrestore(t, flags); } --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2631B2D739C; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=vC+xBCwLI9NvgCWLzAPV4fC5/+L7SDbX4hB5TMQiPNlPJ8JiofvV+Bqg8MFJbtL1ztcALki036UhJ+QE4TzZ11BqXdlVsLhMW9JiA2zFc8xf+497vzslq4z3SPsRuUBMvn1IU1bjB2hGFz97IglC8xXemsRsHvHQGubmR4BGQRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=H/LywIBhDN+7gS6h2t/zpJNCBkFiQp9SnPcP3462Yb8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BsMeBvk8I/RTrFVTK5JNVOEwpVMoNozEFmqf3sF5hsztpSq6r+TiPZFx6atoRyeO6pYexHzXSYSmrVL4jsF4STzWSDrasHYqOklC29UciNXO4EkHFD7kvQ7ZZ3MZuJMbvOVUbJm4bPF5kDbId6C6fuaStg0dQeRpAbGZhGrmDdw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XuNqD11L; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XuNqD11L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25ADA1F00ADF; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=8nXrgC14QXbEPY+ClX2MuAHMfuWbHbQvcoYUAqNNUBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XuNqD11LB85ul7phFDq8hJ3kAH/FFQmc9/0vlQhnf8J2oB3i0Oiqx0It800kqr1hM 8V4Achgav+tG3MTMIU0D4hSEUrbBiMbFDYlVd5HYD2EJ5qHVZUWMURQLU33cGc3Ati iE+qSwuL3gMfAW4OiU65d809D7YgZqMXZawMurEkI/4TQOR0DzSPHNY6/RfGuGCW3k AGvwDeVis14qa/6eCorK38DE6K6ceBr1R/wiyJdqhhOS3eQF7BvNxvyR4JiYzodjyJ mvihvRrwTs/LbQocFUoY9J3lcUuZGG1CJOq4QUfFbh+deOU17dyziZTajFjmgneHIz 7caC0oYShfaIg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B27DCCE1059; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH RFC 07/16] rcu: Use this_cpu_{read,write}() for ->cpu_no_qs.b.exp Date: Thu, 30 Jul 2026 18:01:44 -0700 Message-Id: <20260731010153.3531313-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently __this_cpu_read() and __this_cpu_write() is used to access the ->cpu_no_qs.b.exp field of the per-CPU rcu_data structure. However, this can fail when the accesses can happen in interrupt handlers, as recently started being exercised by rcutorture. This commit therefore upgrades the uses of __this_cpu_read() and __this_cpu_write() to their interrupt-safe counterparts this_cpu_read() and this_cpu_write(). KCSAN located this issue. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_exp.h | 4 ++-- kernel/rcu/tree_plugin.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 82cada459e5d0c..e03cb3d447a57d 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -731,7 +731,7 @@ static void rcu_exp_need_qs(void) { lockdep_assert_irqs_disabled(); ASSERT_EXCLUSIVE_WRITER_SCOPED(*this_cpu_ptr(&rcu_data.cpu_no_qs.b.exp)); - __this_cpu_write(rcu_data.cpu_no_qs.b.exp, true); + this_cpu_write(rcu_data.cpu_no_qs.b.exp, true); /* Store .exp before .rcu_urgent_qs. */ smp_store_release(this_cpu_ptr(&rcu_data.rcu_urgent_qs), true); set_need_resched_current(); @@ -870,7 +870,7 @@ static void rcu_exp_handler(void *unused) =20 ASSERT_EXCLUSIVE_WRITER_SCOPED(rdp->cpu_no_qs.b.exp); if (!(READ_ONCE(rnp->expmask) & rdp->grpmask) || - __this_cpu_read(rcu_data.cpu_no_qs.b.exp)) + this_cpu_read(rcu_data.cpu_no_qs.b.exp)) return; if (rcu_is_cpu_rrupt_from_idle() || (IS_ENABLED(CONFIG_PREEMPT_COUNT) && preempt_bh_enabled)) { diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 9ba136a4233a26..c3db1ad4a2807a 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -599,7 +599,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *= t, unsigned long flags) */ static notrace bool rcu_preempt_need_deferred_qs(struct task_struct *t) { - return (__this_cpu_read(rcu_data.cpu_no_qs.b.exp) || + return (this_cpu_read(rcu_data.cpu_no_qs.b.exp) || READ_ONCE(t->rcu_read_unlock_special.s)) && rcu_preempt_depth() =3D=3D 0; } @@ -981,7 +981,7 @@ static void rcu_qs(void) trace_rcu_grace_period(TPS("rcu_sched"), __this_cpu_read(rcu_data.gp_seq), TPS("cpuqs")); __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); - if (__this_cpu_read(rcu_data.cpu_no_qs.b.exp)) + if (this_cpu_read(rcu_data.cpu_no_qs.b.exp)) rcu_report_exp_rdp(this_cpu_ptr(&rcu_data)); } =20 --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 474D12DEA6B; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459717; cv=none; b=ozowrpQ6aiSwys9SBm1ysAIOKxUMV9s+pjIahhxjiaviyNxRHQvgnLsbJmDyLUkevjLy/FixH2shXxjIcwY4DX3YuN3N+7EUAwGOzT5d5+dVi4qIcShbdzKTaZMPsIRVN4AV22SqoFvydZPTDIuYH2PPJDdZCpw6zz5OKf8yY14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459717; c=relaxed/simple; bh=SPQ1/BUBlVcPW0YL9pl+7LJ6fudss7Cc5flDcSz3Cxg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FHmx3gN014Yq6UlGxRME8hdkfWMOvjqmv6/gAzvXGROoCVD92xtgKtSTTbttodH/EORNZJSAFnK3K6tsVpdGRuZjvhjWL/Tna0E0rSCDWsRd9Sw0ofPC9GuZSbijBHCPp8EqHIcTmqFrc6zbVm6HFWC41Aq/hrfJRUrVllAav/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bprqa4Ub; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bprqa4Ub" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B14F1F00ACF; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=w3yDZIsaofBYHwPlrh6CqR5JrMhsol0jdD2BGuIKVOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Bprqa4Ub3Pu39FxWUhvluMpCYw6kwP6Rpdzoz1SuEDYCPdQYXIC6OSJug+5TheC6M OsycQ9Dd6DtkitMZgy7YJXXuMcz0RtGG6B9PSbSPDZuTMeSHLxuyvoYr7hLjnUrtEP r4KKcA4/ZXbmHxO58VI2kW6E1eBKPkwpxk0cmspavcTcgt5IWOCx1ARl5ZFk8YmeI5 Iw5lG58H9djj0ZNQSvgqqKCne6GjLGK1M1KwIfIO/BMvvQsUTPN6ndekzRaqp2gRso RbufSTtPMqQKkn4Mci2ZZ3e50GBlHhTSF5oFA25VkVlUB/PN+JyfLbikO7Wj+cQa+4 tQkR+twwjNpJg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B5242CE1497; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH RFC 08/16] rcu: Use WRITE_ONCE() for ->rcu_need_heavy_qs Date: Thu, 30 Jul 2026 18:01:45 -0700 Message-Id: <20260731010153.3531313-8-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently raw_cpu_write() is used to clear the ->rcu_need_heavy_qs field of the per-CPU rcu_data structure. However, on x86 this is a normal assignment, which does not play well with concurrent accesses. This commit therefore upgrades the uses of raw_cpu_write() to its concurrency-safe counterpart WRITE_ONCE() of an rdp pointer obtained from this_cpu_ptr(&rcu_data). KCSAN located this issue. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 03a43d3d261607..91d5b4dd08bf5c 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -357,9 +357,10 @@ bool rcu_watching_zero_in_eqs(int cpu, int *vp) */ notrace void rcu_momentary_eqs(void) { + struct rcu_data *rdp =3D this_cpu_ptr(&rcu_data); int seq; =20 - raw_cpu_write(rcu_data.rcu_need_heavy_qs, false); + WRITE_ONCE(rdp->rcu_need_heavy_qs, false); seq =3D ct_state_inc(2 * CT_RCU_WATCHING); /* It is illegal to call this from idle state. */ WARN_ON_ONCE(!(seq & CT_RCU_WATCHING)); --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 57ABE2DEA7B; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459717; cv=none; b=Gc4CW2oNSb2n7PIFhm1Fj76KyUUuNQ/91mHhkjM1+3H3co5wbBCuthAPJjsZOrnJRevGVGfVl0JyE0sx0uwRSvCJBk0zz5I7Fmy4riiC0XrloddWNC134QKbbVoeJHbeV9VaUh+pNzLptMChdLryr+IjAo1OXJcrvBvkw9oJ0KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459717; c=relaxed/simple; bh=pCRX8+l1IN+X5y8V4I17znb7He/4+TOcNXkyr+OWpN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nnxyF4nFugOjAi2XovV35Ze3DYoMWnhNaq4Ald2KMbNyLNQEuBI6I5QAS7omtRqbJqJdwuLEALaZda3CbUd6K2v7pYCXtpzDGK3QRx5D8oloR8HqmW8qQEk1g9AYFJoMBq3xQ+ccZalK8ua4HzXlSppa518M7w0jX6eSLGYQSOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XpL0Fkl4; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XpL0Fkl4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 324101F01558; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=CbTCQ1g3TRtR5B10oGb8BErMIh3Q8zsIuXKRGr+KqM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XpL0Fkl4WUWPPNFJN7KdODAGnIaj7fsUdfx+nbmxTrB0UZ8ld/saHw3WFsyKNr/2A J6xerWoAjFrZTtxkVrodt/kviMiwndzlgDZ2+fiFgqp9x3JbARlDpk3IWTB0sVujzh u4SjYqwvZ7F7N+wpM7f/K24CA33h4hucGDK2KHdPo4Nxx02e6b48DU0ksueDctp9s5 DvJ9BIu0soDjgBTa9e4N+ZJkS2VBuJPbX2czupbTfM80+oxkSQ4altU6U7WE70BX4F ssnQk5xa+Y77uSL+OIj2DrHfHJG7wHphSczK9CNfM0QFzY7gl+IHq49MaJAFd9Llr5 R4wce8Jw7h/+w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B774FCE14D9; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Joel Fernandes , "Paul E . McKenney" Subject: [PATCH RFC 09/16] rcu: Remove unused expedited_need_qs field from rcu_state Date: Thu, 30 Jul 2026 18:01:46 -0700 Message-Id: <20260731010153.3531313-9-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joel Fernandes The ->expedited_need_qs counter was part of the old expedited grace-period machinery that spun waiting for each CPU to check in. The current implementation instead tracks holdout CPUs via the rcu_node structures' ->expmask fields and waits on the ->exp_wq[] wait queues, so nothing reads or writes ->expedited_need_qs any longer. Remove the field to avoid wasting space in rcu_state and to keep readers of the expedited code from searching for nonexistent users. Signed-off-by: Joel Fernandes Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.h | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 4069132f9d4446..587bd71396eaa3 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -391,7 +391,6 @@ struct rcu_state { struct mutex exp_mutex; /* Serialize expedited GP. */ struct mutex exp_wake_mutex; /* Serialize wakeup. */ unsigned long expedited_sequence; /* Take a ticket. */ - atomic_t expedited_need_qs; /* # CPUs left to check in. */ struct swait_queue_head expedited_wq; /* Wait for check-ins. */ int ncpus_snap; /* # CPUs seen last time. */ u8 cbovld; /* Callback overload now? */ --=20 2.40.1 From nobody Fri Oct 2 14:03:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8E0B22DF6E9; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=kSxbYsOkrITJED5jMv3nOTveTD8H8+TthsqiFlV2ERN0h97C0IMgq7CjVS/lO+L0QbrVpETGddpsF8gA9gM6Ph9wg4e+9mq6auUe9Y1AjMf8XKz5NZYro6s8480raBARqj90Iv8sqKgpAokTCQgDg4Lz+UkiE5kQgJp4GRszGVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=dhSjR3vDrtZvSwAI9l7DzmPyRTQldlTikhvP7DqtDvc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RPI0clbt+5t+5E8Cvhw84nhKLxkaT179Hzx21zsuHgGM99f2nyvrWNcpkNJ6+xVBjI/11l34NOR8FRoc3bFdKQ3ObqWR+Zihmmv0p9W60E3VQeLvACyvpBd6fneJPk/oBhF3GwwjIECS2yhhNURkeNOn5QyBNflICr2/GKZF4wY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cvs/cxd5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cvs/cxd5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35E461F01559; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=qVUn+HvYcqrUN3yFZCWJp+z6JszIeDOMxvQANkWtJx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cvs/cxd5QgLm3kix3Z9nbFPn49vEfWu6klvQhKYJCWEmQ2C7sZhD9QtFgSNeYK9Mn C9Kd5Hp5KQ7sHA5hpQYna8sX6na10Mnc2iLRlmvfhwsK188uNhF6DMbhkCiKuuVy5S hQwluFjcPsWRiH+uU0dL4x2CdymnwdP4tuQqLpal8zMmYHWekbv8cYl1IP1dt49dJX XhiBD9w70zbMJCR3RFsvP9RCNs3ZIQVcT2VZlLNSXeCb85vG6MCW4i5SI7w19seoKG BC7qHEt5jh15QuryLdoXyrT3s0QBXMu+1MX5vPogSIw55mSDQm9H23LLOPbGJG4gZ/ Zjwtx3bNrlSgQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B9DF4CE14DB; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Joel Fernandes , "Paul E . McKenney" Subject: [PATCH RFC 10/16] rcu: Remove unused func parameter from callback-enqueue functions Date: Thu, 30 Jul 2026 18:01:47 -0700 Message-Id: <20260731010153.3531313-10-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joel Fernandes Ever since the kvfree_rcu() tracing moved out of the callback-enqueue path, rcutree_enqueue() no longer looks at the callback function pointer: By the time it is invoked, __call_rcu_common() has already stored the function into rhp->func, and the enqueue path only adds the rcu_head to the segmented callback list and emits tracepoints that do not take the function pointer. Nevertheless, the function pointer is still threaded through call_rcu_core(), call_rcu_nocb(), and rcutree_enqueue(), forcing each level to carry a dead argument. Remove the parameter from all three functions, from the no-CBs stub, and from the corresponding declarations. Anything needing the callback function can still get it from rhp->func. No functional change. Signed-off-by: Joel Fernandes Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 10 +++++----- kernel/rcu/tree.h | 2 +- kernel/rcu/tree_nocb.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 91d5b4dd08bf5c..390dad82675db5 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3024,7 +3024,7 @@ static int __init rcu_spawn_core_kthreads(void) return 0; } =20 -static void rcutree_enqueue(struct rcu_data *rdp, struct rcu_head *head, r= cu_callback_t func) +static void rcutree_enqueue(struct rcu_data *rdp, struct rcu_head *head) { rcu_segcblist_enqueue(&rdp->cblist, head); trace_rcu_callback(rcu_state.name, head, @@ -3036,9 +3036,9 @@ static void rcutree_enqueue(struct rcu_data *rdp, str= uct rcu_head *head, rcu_cal * Handle any core-RCU processing required by a call_rcu() invocation. */ static void call_rcu_core(struct rcu_data *rdp, struct rcu_head *head, - rcu_callback_t func, unsigned long flags) + unsigned long flags) { - rcutree_enqueue(rdp, head, func); + rcutree_enqueue(rdp, head); /* * If called from an extended quiescent state, invoke the RCU * core in order to force a re-evaluation of RCU's idleness. @@ -3179,9 +3179,9 @@ __call_rcu_common(struct rcu_head *head, rcu_callback= _t func, bool lazy_in) check_cb_ovld(rdp); =20 if (unlikely(rcu_rdp_is_offloaded(rdp))) - call_rcu_nocb(rdp, head, func, flags, lazy); + call_rcu_nocb(rdp, head, flags, lazy); else - call_rcu_core(rdp, head, func, flags); + call_rcu_core(rdp, head, flags); local_irq_restore(flags); } =20 diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index 587bd71396eaa3..ca88aaa29d615e 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -507,7 +507,7 @@ static bool wake_nocb_gp(struct rcu_data *rdp); static bool rcu_nocb_flush_bypass(struct rcu_data *rdp, struct rcu_head *r= hp, unsigned long j, bool lazy); static void call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *head, - rcu_callback_t func, unsigned long flags, bool lazy); + unsigned long flags, bool lazy); static void __maybe_unused __call_rcu_nocb_wake(struct rcu_data *rdp, bool= was_empty, unsigned long flags); static int rcu_nocb_need_deferred_wakeup(struct rcu_data *rdp, int level); diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 373b877cf171d3..95dbf33462a2ff 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -603,13 +603,13 @@ static void __call_rcu_nocb_wake(struct rcu_data *rdp= , bool was_alldone, } =20 static void call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *head, - rcu_callback_t func, unsigned long flags, bool lazy) + unsigned long flags, bool lazy) { bool was_alldone; =20 if (!rcu_nocb_try_bypass(rdp, head, &was_alldone, flags, lazy)) { /* Not enqueued on bypass but locked, do regular enqueue */ - rcutree_enqueue(rdp, head, func); + rcutree_enqueue(rdp, head); __call_rcu_nocb_wake(rdp, was_alldone, flags); /* unlocks */ } } @@ -1666,7 +1666,7 @@ static bool rcu_nocb_flush_bypass(struct rcu_data *rd= p, struct rcu_head *rhp, } =20 static void call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *head, - rcu_callback_t func, unsigned long flags, bool lazy) + unsigned long flags, bool lazy) { WARN_ON_ONCE(1); /* Should be dead code! */ } --=20 2.40.1 From nobody Fri Oct 2 14:03:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8E1692E0B5C; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=hF48qh48motKNtOmmEZi22pggABzYDnSHvl/Re3uT+vhXkkRAOToxj2A2rKj+j82b86EJpfZSly0aa8SvkbdJtrbiTzPOuhDyKpDfCbXLIUtKutKFGdjQGWXQidk8Z3WP7es7mbPgCJ801BQJNfAfiEGP01QVZXAXKYrpi92ZyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=8dRscm5WjZJJ6gnnEC3G11Y1b0fADU3e4aeIuAkhUq0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CR30uQ30DO0xLszf8ZRf36KokySUeNJ9rcgROYdpxDmv93JHWAWtazT/0WTJscacOOT+F8Xy9cUuNrCItvizjYj1RCiRe3WdyQoU5Gac/WLfZ5+qFwftlIGoy/H8P6MG/VSHa+6Er3qscVF21Dxp9ENgl9UQvRtkkHvDzdUgBko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SSFsLVjG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SSFsLVjG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A0761F0155A; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=i35NiPZ9XyqWbZPDmlJF5mksq725ThYC0oGPQKHrPlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SSFsLVjGgOl1O1mBihfcGn7Cdm4JztNmHkSJtGMCKk6h++SDJ9qIF90fGWrQrgFQF o4j6dLzOyz8J9PzzO27l/azCYPN2WKF8kiU9+0tEG0s2VaBE+0PfAqg4iMKx2yE/oI v2Bul0qLVNbjTYUXpAO9FrW0OLuvE8v2MsKqLa5/N9T2AnA77x6PxGlwTJF1HYPKns +fQhTxV+hxA1v7i2Y2RnrCeED6QbioMg/2u4nus2MjY/beuwZLIriEMbly0ptBtUvN Sog7bkhO2uwPxVefB/TKXbp3MrOxvKcLHcqbKRreH2JfbujTBQNHFLk8NmBr5X+2tJ YdwVKcPZcuzBQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BC6E4CE1716; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH RFC 11/16] rcu: Mark accesses to rdp->rcu_cpu_has_work Date: Thu, 30 Jul 2026 18:01:48 -0700 Message-Id: <20260731010153.3531313-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Although the rdp->rcu_cpu_has_work field is accessed only by the corresponding CPU, it can be accessed by both interrupt handlers via invoke_rcu_core_kthread() and at task level via rcu_cpu_kthread(). This means that we need this_cpu_read() rather than __this_cpu_read(), this_cpu_write() rather than __this_cpu_write(), and READ_ONCE() rather than plain C-language loads. The exception is the boot-time rcu_spawn_core_kthreads(), which cannot race with kthreads that have not yet been spawned. This commit therefore makes it so. KCSAN located this issue. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 390dad82675db5..c9780e7c0e2afa 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2671,7 +2671,7 @@ static void rcu_do_batch(struct rcu_data *rdp) // reporting, so check time limits for them. if (rdp->rcu_cpu_kthread_status =3D=3D RCU_KTHREAD_RUNNING && rcu_do_batch_check_time(count, tlimit, jlimit_check, jlimit)) { - rdp->rcu_cpu_has_work =3D 1; + WRITE_ONCE(rdp->rcu_cpu_has_work, 1); break; } } @@ -2931,7 +2931,7 @@ static void invoke_rcu_core_kthread(void) unsigned long flags; =20 local_irq_save(flags); - __this_cpu_write(rcu_data.rcu_cpu_has_work, 1); + this_cpu_write(rcu_data.rcu_cpu_has_work, 1); t =3D __this_cpu_read(rcu_data.rcu_cpu_kthread_task); if (t !=3D NULL && t !=3D current) rcu_wake_cond(t, __this_cpu_read(rcu_data.rcu_cpu_kthread_status)); @@ -2958,7 +2958,7 @@ static void rcu_cpu_kthread_park(unsigned int cpu) =20 static int rcu_cpu_kthread_should_run(unsigned int cpu) { - return __this_cpu_read(rcu_data.rcu_cpu_has_work); + return this_cpu_read(rcu_data.rcu_cpu_has_work); } =20 /* @@ -2979,7 +2979,7 @@ static void rcu_cpu_kthread(unsigned int cpu) local_bh_disable(); *statusp =3D RCU_KTHREAD_RUNNING; local_irq_disable(); - work =3D *workp; + work =3D READ_ONCE(*workp); WRITE_ONCE(*workp, 0); local_irq_enable(); if (work) --=20 2.40.1 From nobody Fri Oct 2 14:03:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D5D472E7375; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=BZtbPxR+2syiCCvYY8m/EoTCOF9if/GDCjV9DzGAE8bPbqLWoLXMdyNDnegP8/erEkDgqeo5wT5MabJL5vV2xAYFCuhRToMGaouU3yO7dWnknwXkTPHY7yvGESOQSKYSCWQNdAPVhwz0iKa7ulta+ELADqSsSyqy1p88I3lt2xM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=w8G5cfYcQaM/fV8HeFYsbwcu7Zre3Ch3XgDCUA23tFQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p7BuvfAKLFhAJS+EddPCGFbzary2F/Sh2VjBZpH51LKs3zu/bXRn/lWpZswrrfJ9/kYjfVLdh9sOra64F+SIbSTaVwAbre6g69OwTjTtm+up7RuOBLZKptyP5f8gjTKWuv6lNl6pg4irX74I3hxkW3tlM5g4wT70QgbrCJSW3aw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QhI6HjXd; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QhI6HjXd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 402B71F00ADB; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=d90N1ezebPs22Y5VYk294ZLHVDI0r826ZopT19z5q6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QhI6HjXdV+QvPqYaUthxq3peP2Nl3I5tsbrnPTDqguHYFfs6w293ZKHeqEAiZEjUk xOAmSi6RRtE1H1cBOdY0EzqM0tuVP7KfjahaOlXGhmtVdR0ReV7OPEHypx+3Sb/XKi kmRCL1a5WODL1vCL6JHh8ZYyUS0HQSyneg2Fm+a2WUZg97uDGDWCwM21RJCgBdJHSO fbI06HR2tzkRJS/7xAQVJA9nntfQ97h9A6ZyvUQHMKiLTk+b9nUsLXNJbkY6sigkJi +EI/aN2LxTeMPiUl6IjNDNp+XrzReJHpcldak0w9b7hVNlwjJrnHSmaXJdEQCIVFUn 0ZOba7mVrsABg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BEC1FCE17C1; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH RFC 12/16] rcu: Mark interrupts-enabled accesses to rdp->cpu_no_qs.b.norm Date: Thu, 30 Jul 2026 18:01:49 -0700 Message-Id: <20260731010153.3531313-12-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The rdp->cpu_no_qs.b.norm field is accessed only by the current CPU, but can be accessed both at task level and from interrupt handlers. All accesses from interrupts-enabled code must therefore be marked. This commit therefore converts from __this_cpu_read() to this_cpu_read(), from __this_cpu_write() to this_cpu_write(), and plain C-language accesses to READ_ONCE() and WRITE_ONCE(), but only in interrupts-enabled code. KCSAN located this issue. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- kernel/rcu/tree_plugin.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index c9780e7c0e2afa..377153e0d93440 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2540,7 +2540,7 @@ rcu_check_quiescent_state(struct rcu_data *rdp) * Was there a quiescent state since the beginning of the grace * period? If no, then exit and wait for the next call. */ - if (rdp->cpu_no_qs.b.norm) + if (READ_ONCE(rdp->cpu_no_qs.b.norm)) return; =20 /* diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index c3db1ad4a2807a..353effac5a37f1 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -298,11 +298,11 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *r= np, struct rcu_data *rdp) static void rcu_qs(void) { RCU_LOCKDEP_WARN(preemptible(), "rcu_qs() invoked with preemption enabled= !!!\n"); - if (__this_cpu_read(rcu_data.cpu_no_qs.b.norm)) { + if (this_cpu_read(rcu_data.cpu_no_qs.b.norm)) { trace_rcu_grace_period(TPS("rcu_preempt"), __this_cpu_read(rcu_data.gp_seq), TPS("cpuqs")); - __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); + this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); barrier(); /* Coordinate with rcu_flavor_sched_clock_irq(). */ WRITE_ONCE(current->rcu_read_unlock_special.b.need_qs, false); } @@ -952,7 +952,7 @@ void rcu_read_unlock_strict(void) * __rcu_read_unlock(). */ rdp =3D this_cpu_ptr(&rcu_data); - rdp->cpu_no_qs.b.norm =3D false; + WRITE_ONCE(rdp->cpu_no_qs.b.norm, false); rcu_report_qs_rdp(rdp); udelay(rcu_unlock_delay); } @@ -980,7 +980,7 @@ static void rcu_qs(void) return; trace_rcu_grace_period(TPS("rcu_sched"), __this_cpu_read(rcu_data.gp_seq), TPS("cpuqs")); - __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); + this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); if (this_cpu_read(rcu_data.cpu_no_qs.b.exp)) rcu_report_exp_rdp(this_cpu_ptr(&rcu_data)); } --=20 2.40.1 From nobody Fri Oct 2 14:03:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D60E12E737D; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=FIPED87VCkEENMTvyU/D0Fp4f2SB6xYiaqwjR0rC6IF1na10C2pMGZ8nsTFh610OhZm21bChzl3MUrxkwyF9IuouAWJ7IhQ5qIDNqe9eWACdZE9COac+OF4mOHyzaYJH9XuWUn/KShAr0xq6CxNZNH/Ct0AaSP38tGzPSnkPaX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=DD9x53YWgK/M5p4JEQQBQJE41f0Bxkxoh/tgT/hXIcw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tTELrgvFIT5HJ0rcjp1gMbxPk9yT0H774TYUwfwlPoHobmB/c2LYIwxYjyI6ggtbmudZBs7ddYweh/EbQ5qU64V1CYkFx7AaO8tXIJ7Yl0haHL+i0jr4caWm3/a0OVOEoOD1XiDIqhJhUpbBUCJwz5IIZtmFGKWk7naPcsc6mHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cIb6rwkn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cIb6rwkn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A2221F0155D; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=8wTMVIMquaIq9IDftApy8iAaPEckI9PdhSiLZ7SuAtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cIb6rwkncRo9+6VFJLx94DpBEq4U0NfLYlKsoFuLjrdmEY7KDnqJdeKmpCisdrufm H4r+vD+bD2zSSBgThK30CSxN6uiAkDDZLZhZNcr8/sDFQ8Pr3shYkqG9Mbrm/NEAmJ p0aAigeISkjf1JLXAOrjYGN4GBXNhM/ygbU6b19p8npW8gRZjqe03YFzXZCCc9TPYu nT6R3MUpJEYxaP2R01eGoIXM0O+vdqzewI3EWB9Ks4iUZL+XcyXCHCa6ZF/eH8TbVG xBTFGMZKzt7BI3ioniyM3ES0s/KRidAZTBHvRv/KCrjC8rhRqQl4V1l7XAMpVtiq84 0HORl0YHwfeZQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C1607CE19A4; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Zqiang , "Paul E . McKenney" Subject: [PATCH RFC 13/16] rcu: Remove unused rdp parameter from rcu_check_gp_start_stall() Date: Thu, 30 Jul 2026 18:01:50 -0700 Message-Id: <20260731010153.3531313-13-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zqiang The rcu_check_gp_start_stall() works entirely on rnp parameter, and never uses it's rdp parameter. this commit therefore drop it, updating both callers and the declaration. No functional change. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- kernel/rcu/tree.h | 3 +-- kernel/rcu/tree_stall.h | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 377153e0d93440..5dbc7506c0c0c0 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2890,7 +2890,7 @@ static __latent_entropy void rcu_core(void) rcu_accelerate_cbs_unlocked(rnp, rdp); } =20 - rcu_check_gp_start_stall(rnp, rdp, rcu_jiffies_till_stall_check()); + rcu_check_gp_start_stall(rnp, rcu_jiffies_till_stall_check()); =20 /* If there are callbacks ready, invoke them. */ if (!rcu_rdp_is_offloaded(rdp) && rcu_segcblist_ready_cbs(&rdp->cblist) && diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index ca88aaa29d615e..c3662c6ba39549 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -544,8 +544,7 @@ static bool rcu_nohz_full_cpu(void); static void record_gp_stall_check_time(void); static void rcu_iw_handler(struct irq_work *iwp); static void check_cpu_stall(struct rcu_data *rdp); -static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data= *rdp, - const unsigned long gpssdelay); +static void rcu_check_gp_start_stall(struct rcu_node *rnp, const unsigned = long gpssdelay); =20 /* Forward declarations for tree_exp.h. */ static void sync_rcu_do_polled_gp(struct work_struct *wp); diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 45b9856ccd2b23..02684dadb4ee08 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -998,8 +998,7 @@ EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads); * This function checks for grace-period requests that fail to motivate * RCU to come out of its idle mode. */ -static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data= *rdp, - const unsigned long gpssdelay) +static void rcu_check_gp_start_stall(struct rcu_node *rnp, const unsigned = long gpssdelay) { unsigned long flags; unsigned long j; @@ -1074,7 +1073,7 @@ void rcu_fwd_progress_check(unsigned long j) __func__, jiffies - data_race(READ_ONCE(rcu_state.gp_end))); preempt_disable(); rdp =3D this_cpu_ptr(&rcu_data); - rcu_check_gp_start_stall(rdp->mynode, rdp, j); + rcu_check_gp_start_stall(rdp->mynode, j); preempt_enable(); } for_each_possible_cpu(cpu) { --=20 2.40.1 From nobody Fri Oct 2 14:03:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D5E322E7378; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=ebSr7JFyr0S2zdhnRuFHtHmPH9zirZNd7f9k2d6hIzDoOQJhLvMMwb1foqhdLL93Rg4mU4cAGRN/vMsfaw6sOpC5rcwwF9k3zdGzETOszlqH/VNxrrT/ddNlMSWYBAX3SNMSAKE/G+eJKtVH3cu6F/zo627YJs7UifeXYrEYXDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=NOD7h8A130NxjLdL1JhNvSi0xbDjOhnoKk7yWYbIHnc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JeoFVIUqTsyzMOQdJ5xESlLmLQN5MdutfbwapFsiVw2B/GmwSPHvVzrhQOfV8aom/RKT0AcydoQ8aLV85JBJEcvy/pyhMQ/DRZnubjFxaBij5ZH8VyQcEjMSW/7IlSgLdPEb5Ao5b8LPnRWatdK9G+yWs+XTHIR9hb+zFLPMB6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JHDYK6lg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JHDYK6lg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50D9D1F0155B; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=+uHQqjlhA8kcMxl9eau4DVudI4JBlvQd5ZmavBxnPVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JHDYK6lg1DnQkJGZWUFxlqxD/BNWWviMarCvNfz6yuRQIjWHXuQX1J45JvGm8gwi9 ey5o+8RUxwE8M3nqLlYq2PwgQAuIFWJr+eAiqA/FzDU15WXjn0+oGFmAIZh5UP2sP6 AvQOk7PMd6kiW0DMNXml0JWEWFVZ7XB4NXOgczl2b8Yz23caC+KabC4RKdy2IlTbCY zPDn6/Qle6YOqiP0YF6JFpY1TduhEpEPHzANp5DYmAAfgXOe84iKNw5PEuuqvNlpT7 CiCJPDuP3Z9ASSTYXKDqJCSv5aoRhygPEp2iWzaeRNWF5aewTrXusWbtvPEAcmncDQ QmCeivbkQNLLw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C3C5BCE1A23; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Itai Handler , "Paul E . McKenney" Subject: [PATCH RFC 14/16] rcu: Mark accesses to ->rcu_urgent_qs and ->rcu_need_heavy_qs Date: Thu, 30 Jul 2026 18:01:51 -0700 Message-Id: <20260731010153.3531313-14-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Itai Handler rcu_all_qs() and rcu_note_context_switch() read/clear the per-CPU ->rcu_urgent_qs and ->rcu_need_heavy_qs flags with plain raw_cpu_read() and this_cpu_write(), while the RCU core clears them with WRITE_ONCE() in rcu_disable_urgency_upon_qs(). KCSAN flags the resulting same-CPU race: BUG: KCSAN: data-race in rcu_all_qs / rcu_disable_urgency_upon_qs It is benign -- the flags are advisory and rcu_all_qs() re-reads ->rcu_urgent_qs with smp_load_acquire() before acting on it -- but these are the last unmarked accesses to the two flags; every other access already uses READ_ONCE()/WRITE_ONCE()/smp_*. Mark them to match. No functional change. Reproduced on a PREEMPT_NONE, CONFIG_KCSAN_INTERRUPT_WATCHER=3Dy kernel with a pthreads program whose threads (two per CPU) loop reading a large file: for (;;) { int fd =3D open("/proc/kallsyms", O_RDONLY); while (read(fd, buf, sizeof(buf)) > 0) ; close(fd); } The read()s drive cond_resched() -> rcu_all_qs() while the busy CPUs keep the grace period urgent, so the RCU core clears the flags concurrently. Fixes: 2dba13f0b6c2 ("rcu: Switch urgent quiescent-state requests to rcu_da= ta structure") Signed-off-by: Itai Handler Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_plugin.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 353effac5a37f1..844a9ced67cc0e 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -996,7 +996,7 @@ void rcu_all_qs(void) { unsigned long flags; =20 - if (!raw_cpu_read(rcu_data.rcu_urgent_qs)) + if (!READ_ONCE(*raw_cpu_ptr(&rcu_data.rcu_urgent_qs))) return; preempt_disable(); // For CONFIG_PREEMPT_COUNT=3Dy kernels /* Load rcu_urgent_qs before other flags. */ @@ -1004,8 +1004,8 @@ void rcu_all_qs(void) preempt_enable(); return; } - this_cpu_write(rcu_data.rcu_urgent_qs, false); - if (unlikely(raw_cpu_read(rcu_data.rcu_need_heavy_qs))) { + WRITE_ONCE(*this_cpu_ptr(&rcu_data.rcu_urgent_qs), false); + if (unlikely(READ_ONCE(*this_cpu_ptr(&rcu_data.rcu_need_heavy_qs)))) { local_irq_save(flags); rcu_momentary_eqs(); local_irq_restore(flags); @@ -1025,8 +1025,8 @@ void rcu_note_context_switch(bool preempt) /* Load rcu_urgent_qs before other flags. */ if (!smp_load_acquire(this_cpu_ptr(&rcu_data.rcu_urgent_qs))) goto out; - this_cpu_write(rcu_data.rcu_urgent_qs, false); - if (unlikely(raw_cpu_read(rcu_data.rcu_need_heavy_qs))) + WRITE_ONCE(*this_cpu_ptr(&rcu_data.rcu_urgent_qs), false); + if (unlikely(READ_ONCE(*this_cpu_ptr(&rcu_data.rcu_need_heavy_qs)))) rcu_momentary_eqs(); out: rcu_tasks_qs(current, preempt); --=20 2.40.1 From nobody Fri Oct 2 14:03:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D488E2E736D; Fri, 31 Jul 2026 01:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; cv=none; b=mm44IUM1/k0Z7AL1C47vSZav49aEjdF+9nIxCs4EzNL/IzcEjarxWitnrwH+hgFgQ+z7HvdWRUoEoAWJv0OP/lOiGHj1nyD87PiroR9BLqiUAfdSKdOOFyUL5mJQ8fFBnoQwKOaKkygKl+xbyLXuUNxxNumWyAHURc88PSSXmCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459718; c=relaxed/simple; bh=s2CwlRfCct6t9x6RRZxvV5lxYUPkezJqvXdfzesKwUA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c18i8djOBdEWltoQ8LX7q49gyrvO0sot3K4zlz9k2WKv8XF083R41CEQfjOq0NR3/iXz8N+U1T+PhLAiulVOhjwIyzSPiPEFqpXcGyJGAPQ92As509ar55sJp9SfzE/v5ieXNuMUbOOqIduA+Lk+lSGBSKIr4Xqr15PPnw7RGq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NEGavETn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NEGavETn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53F5D1F0155E; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=zBVVmWWxAq5z4UE2XkEILIkHspGzzHIP0ODNGBb69JU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NEGavETnIVm/WYh0U0luJGngciBxGPMS+Ox72Y6nlcAMv8q9IwZB0+quRPFEF2126 eDWSsc3BInHGhx7QEzrUZtqwGngsrCYPPBHxz5aKO4VtJNHzY6GXBnBrJMslJKRlN9 9yASlEpng6cUoil9nH18uNa4GIUGeeC3uVLpLuestyGQEpSDj2JU9LOXa4cYdQeVTj RBJ0ACjOPdQaewah6t9oWaxKn+4VoR9W5OOT25zYBeHyA8yKuCv4CF5hJwiF5jVqRt QOW8agG9xYLbvfvvf8tkvZk2Lc9Ahjv9qSjdpNHlyQXpOqZsjBXb8WgNAVM3iAhyg/ 5dd4//mB+x0dw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C6866CE1A3C; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Zqiang , "Paul E . McKenney" Subject: [PATCH RFC 15/16] rcu: Reduce stack usage in show_rcu_gp_kthreads() Date: Thu, 30 Jul 2026 18:01:52 -0700 Message-Id: <20260731010153.3531313-15-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zqiang When CONFIG_KASAN=3Dy and CONFIG_KASAN_STACK=3Dy builds, the show_rcu_gp_kthreads() exceeds the 1024-byte frame-size limit: make kernel/rcu/tree.o KCFLAGS=3D"-fstack-usage" DESCEND objtool DESCEND bpf/resolve_btfids INSTALL libsubcmd_headers CC kernel/rcu/tree.o In file included from kernel/rcu/tree.c:4998: kernel/rcu/tree_stall.h: In function 'show_rcu_gp_kthreads': kernel/rcu/tree_stall.h:994:1: warning: the frame size of 1656 bytes is lar= ger than 1024 bytes [-Wframe-larger-than=3D] grep show_rcu kernel/rcu/tree.su tree_nocb.h:1622:13:show_rcu_nocb_state 896 dynamic,bounded tree_stall.h:933:6:show_rcu_gp_kthreads 1784 dynamic,bounded tree_stall.h:1102:13:sysrq_show_rcu 16 static Wrap the pr_info() into two noinline_for_stack helpers function: show_rcu_state() print rcu_state status, and show_rcu_node() print single rcu_node status. After apply this change: grep show_rcu kernel/rcu/tree.su tree_stall.h:955:22:show_rcu_node 696 dynamic,bounded tree_stall.h:930:22:show_rcu_state 872 dynamic,bounded tree_nocb.h:1622:13:show_rcu_nocb_state 896 dynamic,bounded tree_stall.h:972:6:show_rcu_gp_kthreads 544 static tree_stall.h:1113:13:sysrq_show_rcu 16 static Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_stall.h | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 02684dadb4ee08..20634edfb44d8a 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -927,20 +927,13 @@ bool rcu_check_boost_fail(unsigned long gp_state, int= *cpup) } EXPORT_SYMBOL_GPL(rcu_check_boost_fail); =20 -/* - * Show the state of the grace-period kthreads. - */ -void show_rcu_gp_kthreads(void) +static noinline_for_stack void show_rcu_state(void) { - unsigned long cbs =3D 0; - int cpu; unsigned long j; unsigned long ja; unsigned long jr; unsigned long js; unsigned long jw; - struct rcu_data *rdp; - struct rcu_node *rnp; struct task_struct *t =3D READ_ONCE(rcu_state.gp_kthread); =20 j =3D jiffies; @@ -957,21 +950,39 @@ void show_rcu_gp_kthreads(void) (long)data_race(READ_ONCE(rcu_get_root()->gp_seq_needed)), data_race(READ_ONCE(rcu_state.gp_max)), data_race(READ_ONCE(rcu_state.gp_flags))); +} + +static noinline_for_stack void show_rcu_node(struct rcu_node *rnp) +{ + pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld ->qsmask %#lx = %c%c%c%c ->n_boosts %ld\n", + rnp->grplo, rnp->grphi, + (long)data_race(READ_ONCE(rnp->gp_seq)), + (long)data_race(READ_ONCE(rnp->gp_seq_needed)), + data_race(READ_ONCE(rnp->qsmask)), + ".b"[!!data_race(READ_ONCE(rnp->boost_kthread_task))], + ".B"[!!data_race(READ_ONCE(rnp->boost_tasks))], + ".E"[!!data_race(READ_ONCE(rnp->exp_tasks))], + ".G"[!!data_race(READ_ONCE(rnp->gp_tasks))], + data_race(READ_ONCE(rnp->n_boosts))); +} + +/* + * Show the state of the grace-period kthreads. + */ +void show_rcu_gp_kthreads(void) +{ + unsigned long cbs =3D 0; + int cpu; + struct rcu_data *rdp; + struct rcu_node *rnp; + + show_rcu_state(); rcu_for_each_node_breadth_first(rnp) { if (ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq), READ_ONCE(rnp->gp_seq_need= ed)) && !data_race(READ_ONCE(rnp->qsmask)) && !data_race(READ_ONCE(rnp->boos= t_tasks)) && !data_race(READ_ONCE(rnp->exp_tasks)) && !data_race(READ_ONCE(rnp->g= p_tasks))) continue; - pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld ->qsmask %#lx= %c%c%c%c ->n_boosts %ld\n", - rnp->grplo, rnp->grphi, - (long)data_race(READ_ONCE(rnp->gp_seq)), - (long)data_race(READ_ONCE(rnp->gp_seq_needed)), - data_race(READ_ONCE(rnp->qsmask)), - ".b"[!!data_race(READ_ONCE(rnp->boost_kthread_task))], - ".B"[!!data_race(READ_ONCE(rnp->boost_tasks))], - ".E"[!!data_race(READ_ONCE(rnp->exp_tasks))], - ".G"[!!data_race(READ_ONCE(rnp->gp_tasks))], - data_race(READ_ONCE(rnp->n_boosts))); + show_rcu_node(rnp); if (!rcu_is_leaf_node(rnp)) continue; for_each_leaf_node_possible_cpu(rnp, cpu) { --=20 2.40.1 From nobody Fri Oct 2 14:03:23 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 956E92F12AC; Fri, 31 Jul 2026 01:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459719; cv=none; b=IBbK71tBbMsjxz0kgc3pOGggjrBaMTc9ej8vKi0toScJ9VZPrXG+q3jQT2KkRFyIeqdwiE2o4ATgBc+d/eeWf1DXxHCJpPP6/I8x674XLKmgZpU4wReAPR9Mt11rA1L+QBHc0l/9vXMzaiQmyVfmybVtkizo1sTkRj9ruTMTAJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785459719; c=relaxed/simple; bh=t5WQzXm82XcY2lmG6o7wKIY6+mlLPq2sqJQIuT00QvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b7mSCTwdRO4+LHt9/wLFF62cVEd4/eFMsdBKD0OZYmmjHozzNhOLsatixFOEtecRAyWN+CDL8WJhwUTFWdXXwM7w1C7LYzy1RTsivNJgQhNGM6kbQvZT/SkH7Da1u9X+YrCLiTAIwcGgriSTwXVrDuZowvanaZkK4fCp3nygY7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y8gXgSYH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y8gXgSYH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D6281F0155C; Fri, 31 Jul 2026 01:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785459715; bh=kUJWSJos+ec0YSV4gsbHXxgDbpvO7KILoAM/0D0XkZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y8gXgSYHFUh9S7zcajrOLrWdxodX1tbrOZ+uoU5Nstfum6fFjr5WZlE9S3BnmhohF orbnnp1H99+Lb5tG50aawGW8nVuymv1NNjKvmnX69J5iG1Bo1r1PeYcnii0qfMgYlG JRDQgBVgFVukDFiAaVe6JCEPE440RMO3q12Qo56jTxfP4tQmZzAyzi9YMyistUgBJ4 VREdLsdqLeBqfSEMeXnlsgbOJDVaCwB8haU8C6j+Hv00c51H5nxpVZuh7aaZbcGdw3 bW5iSu/BKQMmY/DLfsHJkHZo03SQV0vL0Zz36HrOuGYrJ38wOt7Ux7b8Nx4t+If5nG lut0xu7f8U/cw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C8E78CE1A76; Thu, 30 Jul 2026 18:01:54 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH RFC 16/16] rcu: Mark interrupts-enabled accesses to rdp->cpu_no_qs.s Date: Thu, 30 Jul 2026 18:01:53 -0700 Message-Id: <20260731010153.3531313-16-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> References: <9de287bc-e565-4f21-bd3c-5c17792e6abc@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The rdp->cpu_no_qs.s field is accessed only by the current CPU, but can be accessed both at task level and from interrupt handlers. All accesses from interrupts-enabled code must therefore be marked. This commit therefore converts from __this_cpu_read() to this_cpu_read(), but only in interrupts-enabled code, that is, the rcu_qs() function. KCSAN located this issue. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 844a9ced67cc0e..6904a4f826d1ea 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -976,7 +976,7 @@ static void __init rcu_bootup_announce(void) static void rcu_qs(void) { RCU_LOCKDEP_WARN(preemptible(), "rcu_qs() invoked with preemption enabled= !!!"); - if (!__this_cpu_read(rcu_data.cpu_no_qs.s)) + if (!this_cpu_read(rcu_data.cpu_no_qs.s)) return; trace_rcu_grace_period(TPS("rcu_sched"), __this_cpu_read(rcu_data.gp_seq), TPS("cpuqs")); --=20 2.40.1