From nobody Mon Jun 29 17:43:50 2026 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 E591CC433EF for ; Fri, 4 Feb 2022 23:53:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378556AbiBDXxw (ORCPT ); Fri, 4 Feb 2022 18:53:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378387AbiBDXxb (ORCPT ); Fri, 4 Feb 2022 18:53:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5477C06C946; Fri, 4 Feb 2022 15:53:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3AC9061CB0; Fri, 4 Feb 2022 23:53:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BEE4C004E1; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018809; bh=i+LxFoL2qy6w9Z6qXm97npWTHpaECn1x9fpv8uaHWLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rtlIY3rBngLczfbKFTlPCFAj8EvD0haosiuYGppIqRSqygHBkmYjauNpMchkOOV1y 5wSulHuw57pxs7FDo3hs3RY2XqibxCc4kmaIJwLshAfoiOjegnzMmJ0/yQLiTpaKtu tPbZ8GU0PUzdtI5Wek7B75QakcuMXzr2U1DnisoGYmANrWUczcdMGlTnArrg+3PZqe Vy6dd5zNSFO/x5xOLHElO/V8YxqtWC/6adSO3Km/PZXidqCjdTxeujHEgepO837r5S /HsfTqoKQxAX4p0WgEz9Akz5nCfucv4w6D6eNztNxlx49rnAW/mGzERVKvigg1hIwe I+mLJyp9GZmqg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 728485C0418; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 1/8] rcutorture: Print message before invoking ->cb_barrier() Date: Fri, 4 Feb 2022 15:53:20 -0800 Message-Id: <20220204235327.2948-1-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The various ->cb_barrier() functions, for example, rcu_barrier(), sometimes cause rcutorture hangs. But currently, the last console message is the unenlightening "Stopping rcu_torture_stats". This commit therefore prints a message of the form "rcu_torture_cleanup: Invoking rcu_barrier+0x0/0x1e0()" to help point people in the right direction. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 422f7e4cc08de..00400aef58184 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2905,8 +2905,10 @@ rcu_torture_cleanup(void) int i; =20 if (torture_cleanup_begin()) { - if (cur_ops->cb_barrier !=3D NULL) + if (cur_ops->cb_barrier !=3D NULL) { + pr_info("%s: Invoking %pS().\n", __func__, cur_ops->cb_barrier); cur_ops->cb_barrier(); + } return; } if (!cur_ops) { @@ -2961,8 +2963,10 @@ rcu_torture_cleanup(void) * Wait for all RCU callbacks to fire, then do torture-type-specific * cleanup operations. */ - if (cur_ops->cb_barrier !=3D NULL) + if (cur_ops->cb_barrier !=3D NULL) { + pr_info("%s: Invoking %pS().\n", __func__, cur_ops->cb_barrier); cur_ops->cb_barrier(); + } if (cur_ops->cleanup !=3D NULL) cur_ops->cleanup(); =20 --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 DE915C433EF for ; Fri, 4 Feb 2022 23:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378464AbiBDXxm (ORCPT ); Fri, 4 Feb 2022 18:53:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378408AbiBDXxc (ORCPT ); Fri, 4 Feb 2022 18:53:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3506BC06C94B; Fri, 4 Feb 2022 15:53:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E5716B81210; Fri, 4 Feb 2022 23:53:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F34C340ED; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018809; bh=VaAGDBn6uKvflCX1P8zwNnB516OO2C64Im2j7PiEN0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+4yQqHfLjxmEfTpGG2f9Qe5YDGC/USJBSM1y1O2HxfrTF3eCj+hIzoGT1cgCcQ0G KbwezbnPbEWA33WkavozgBA/eMsJzr+7TeFDIIqSuewVMwGCRpgM+nqKvlIDH1a7IG MhsbuqnBOSmdAXrJSBT6RLBKFfDUYnVeZCefx9cLHdxdRU2UtsgAU7EL6Fh4zw2OQX FbrNHtaOAfThPKV/UnoFoQUdWBMo7Mlvyy7umZnQoholFJeO8AopqcMNfxcD6l6rxB /fkxBqN9hjoqA1BQAIqUs/n28y4A8i54PXc7WA+pF3E6XwXD06KBamTDvYGycQCu2i ROmOpH6Am4cgg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 76BA75C0829; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 2/8] torture: Distinguish kthread stopping and being asked to stop Date: Fri, 4 Feb 2022 15:53:21 -0800 Message-Id: <20220204235327.2948-2-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Right now, if a given kthread (call it "kthread") realizes that it needs to stop, "Stopping kthread" is written to the console. When the cleanup code decides that it is time to stop that kthread, "Stopping kthread tasks" is written to the console. These two events might happen in either order, especially in the case of time-based torture-test shutdown. But it is hard to distinguish these, especially for those unfamiliar with the torture tests. This commit therefore changes the first case from "Stopping kthread" to "kthread is stopping" to make things more clear. Signed-off-by: Paul E. McKenney --- kernel/torture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/torture.c b/kernel/torture.c index ef27a6c824514..f55d803f995d4 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -911,7 +911,7 @@ void torture_kthread_stopping(char *title) { char buf[128]; =20 - snprintf(buf, sizeof(buf), "Stopping %s", title); + snprintf(buf, sizeof(buf), "%s is stopping", title); VERBOSE_TOROUT_STRING(buf); while (!kthread_should_stop()) { torture_shutdown_absorb(title); --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 74CDDC433EF for ; Fri, 4 Feb 2022 23:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378483AbiBDXxo (ORCPT ); Fri, 4 Feb 2022 18:53:44 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:45758 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378359AbiBDXxc (ORCPT ); Fri, 4 Feb 2022 18:53:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13AA2B83975; Fri, 4 Feb 2022 23:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B35BBC340F1; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018809; bh=gMEkExdEIHtGZYJMcRMC5CtUw2Kr5Mwkvh0M24YUqF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhV/RYYSsjDjI0qNGqJ2DYRoSz3pTf8cKxagRcd+9QoYKmI3uUV7Mam1AktBDSs6K 6y8L3f429/ykLR6JpaWRKCrcJEqzKXn8T9jmM6VKzwJ7QbbZDGU69Z0ErpSS6J489J bqvvHrLbHICjkSINdERcgRtIuHeE6DCFtvsEyn2b4xW3rU50bZp5dTAHw7JxZ1eeNx hYc2itObZwxmBahnDjoGJD9HoPbcZrU95Nm5omIRgNjdsMGAIDObXCcHlSmRD3vN/h toLSPJFe5M/VX/kf22JQRro5foc+1Y3DnQWzp7hGFEG7e0uv2DCiJ8rEvz46O2CfhS gnX/siPw5wkQQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 78C555C08B7; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 3/8] rcutorture: Increase visibility of forward-progress hangs Date: Fri, 4 Feb 2022 15:53:22 -0800 Message-Id: <20220204235327.2948-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit adds a few pr_alert() calls to rcutorture's forward-progress testing in order to better diagnose shutdown-time hangs. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 00400aef58184..fefc3fa1a9c2a 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2281,6 +2281,7 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *r= fp, unsigned long stopat; static DEFINE_TORTURE_RANDOM(trs); =20 + pr_alert("%s: Starting forward-progress test %d\n", __func__, rfp->rcu_fw= d_id); if (!cur_ops->sync) return; // Cannot do need_resched() forward progress testing without ->s= ync. if (cur_ops->call && cur_ops->cb_barrier) { @@ -2325,6 +2326,7 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *r= fp, if (selfpropcb) { WRITE_ONCE(fcs.stop, 1); cur_ops->sync(); /* Wait for running CB to complete. */ + pr_alert("%s: Waiting for CBs: %pS() %d\n", __func__, cur_ops->cb_barrie= r, rfp->rcu_fwd_id); cur_ops->cb_barrier(); /* Wait for queued callbacks. */ } =20 @@ -2353,6 +2355,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *r= fp) unsigned long stopat; unsigned long stoppedat; =20 + pr_alert("%s: Starting forward-progress test %d\n", __func__, rfp->rcu_fw= d_id); if (READ_ONCE(rcu_fwd_emergency_stop)) return; /* Get out of the way quickly, no GP wait! */ if (!cur_ops->call) @@ -2414,6 +2417,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *r= fp) n_launders_cb_snap =3D READ_ONCE(rfp->n_launders_cb); cver =3D READ_ONCE(rcu_torture_current_version) - cver; gps =3D rcutorture_seq_diff(cur_ops->get_gp_seq(), gps); + pr_alert("%s: Waiting for CBs: %pS() %d\n", __func__, cur_ops->cb_barrier= , rfp->rcu_fwd_id); cur_ops->cb_barrier(); /* Wait for callbacks to be invoked. */ (void)rcu_torture_fwd_prog_cbfree(rfp); =20 --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 C86D8C433F5 for ; Fri, 4 Feb 2022 23:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378487AbiBDXxs (ORCPT ); Fri, 4 Feb 2022 18:53:48 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:45760 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378366AbiBDXxc (ORCPT ); Fri, 4 Feb 2022 18:53:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 27266B83973; Fri, 4 Feb 2022 23:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B69F9C340F2; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018809; bh=Io8OOvJ7kPMPed5CAYEEfGmPgC4ynlJcaTeSoyVPSfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvNySBPy41L+uE/AP+XKfXsUGiEqyb6EvS/9P6HLdyXgpjXyBfIV0YYNoaIVH58Rz p98ba9dZ1AoeEbEHrXJBsI7b6kjz+cFVYO75jhjJSUiJuN4XGpv94eZYtoLVoUjUWI jRXJuBh8hNGb+jDxKTdYmzWeJgTBtCXv0lv8Wnp/LjkJVuPGVVPf1v0A5Jy7Oiltdk IL6RQfsMazxQsnSztHWdfEwZFh8bS6hIKKAnbZ8EbAbKLIc8b8jqQs+73PUG1Egy0P f49trSNrhjlM5m852TStUkHy1IInkA96Qf+3zEvsuw02KB3NloIvWPGDfD6ky2WJGf ePoBnkn5hLG3A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7AF635C08DD; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 4/8] rcutorture: Make rcu_fwd_cb_nodelay be a counter Date: Fri, 4 Feb 2022 15:53:23 -0800 Message-Id: <20220204235327.2948-4-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Back when only one rcutorture kthread could do forward-progress testing, it was just fine for rcu_fwd_cb_nodelay to be a non-atomic bool. It was set at the start of forward-progress testing and cleared at the end. But now that there are multiple threads, the value can be cleared while one of the threads is still doing forward-progress testing. This commit therefore makes rcu_fwd_cb_nodelay be an atomic counter, replacing the WRITE_ONCE() operations with atomic_inc() and atomic_dec(). Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index fefc3fa1a9c2a..afe95c6948957 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -284,7 +284,7 @@ static atomic_t barrier_cbs_invoked; /* Barrier callbac= ks invoked. */ static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */ static DECLARE_WAIT_QUEUE_HEAD(barrier_wq); =20 -static bool rcu_fwd_cb_nodelay; /* Short rcu_torture_delay() delays. */ +static atomic_t rcu_fwd_cb_nodelay; /* Short rcu_torture_delay() delays. */ =20 /* * Allocate an element from the rcu_tortures pool. @@ -387,7 +387,7 @@ rcu_read_delay(struct torture_random_state *rrsp, struc= t rt_read_seg *rtrsp) * period, and we want a long delay occasionally to trigger * force_quiescent_state. */ =20 - if (!READ_ONCE(rcu_fwd_cb_nodelay) && + if (!atomic_read(&rcu_fwd_cb_nodelay) && !(torture_random(rrsp) % (nrealreaders * 2000 * longdelay_ms))) { started =3D cur_ops->get_gp_seq(); ts =3D rcu_trace_clock_local(); @@ -1276,7 +1276,7 @@ rcu_torture_writer(void *arg) boot_ended =3D rcu_inkernel_boot_has_ended(); stutter_waited =3D stutter_wait("rcu_torture_writer"); if (stutter_waited && - !READ_ONCE(rcu_fwd_cb_nodelay) && + !atomic_read(&rcu_fwd_cb_nodelay) && !cur_ops->slow_gps && !torture_must_stop() && boot_ended) @@ -2290,7 +2290,7 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *r= fp, } =20 /* Tight loop containing cond_resched(). */ - WRITE_ONCE(rcu_fwd_cb_nodelay, true); + atomic_inc(&rcu_fwd_cb_nodelay); cur_ops->sync(); /* Later readers see above write. */ if (selfpropcb) { WRITE_ONCE(fcs.stop, 0); @@ -2335,7 +2335,7 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *r= fp, destroy_rcu_head_on_stack(&fcs.rh); } schedule_timeout_uninterruptible(HZ / 10); /* Let kthreads recover. */ - WRITE_ONCE(rcu_fwd_cb_nodelay, false); + atomic_dec(&rcu_fwd_cb_nodelay); } =20 /* Carry out call_rcu() forward-progress testing. */ @@ -2362,7 +2362,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *r= fp) return; /* Can't do call_rcu() fwd prog without ->call. */ =20 /* Loop continuously posting RCU callbacks. */ - WRITE_ONCE(rcu_fwd_cb_nodelay, true); + atomic_inc(&rcu_fwd_cb_nodelay); cur_ops->sync(); /* Later readers see above write. */ WRITE_ONCE(rfp->rcu_fwd_startat, jiffies); stopat =3D rfp->rcu_fwd_startat + MAX_FWD_CB_JIFFIES; @@ -2435,7 +2435,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *r= fp) } schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */ tick_dep_clear_task(current, TICK_DEP_BIT_RCU); - WRITE_ONCE(rcu_fwd_cb_nodelay, false); + atomic_dec(&rcu_fwd_cb_nodelay); } =20 =20 --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 6A157C4167B for ; Fri, 4 Feb 2022 23:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378441AbiBDXxh (ORCPT ); Fri, 4 Feb 2022 18:53:37 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:55808 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378292AbiBDXxa (ORCPT ); Fri, 4 Feb 2022 18:53:30 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5212661CCE; Fri, 4 Feb 2022 23:53:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3BADC340F3; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018809; bh=6YCDxc9if9WixflkeRLov5G7IDGmcJP5BCW5Y7LJKBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxcvrbOQEa9zelWGdVI1WCSUBtIUp2FJilBh1uHzj/A2qu06hZVNTMD8iKqEitrY5 Zr1ym2xlaWrR+ZNfzRLgU1PwT5vbRXS2uR5Wb6zfMBZvG9KN+OMK7aEzyF6T7T6yPh L0ipUAN40MtDK4kVbFi+ewCtp6cswLJhgtjFi4SKs1YprXzZ7t7cyve68WdGX1Sy4V U1a6IA1kugnSqSMPUXxJ9c1ZeCDkSD37e8V97pKHxl8BH/dAnJBQ2bNAQtpbk2wxRE 60wQaDnqc+wPuzbGie6/1eZg0x1XOtHkt3bSkT5rLxW2+JCZ/1lhA2N1WbTI+vRq4G tm/pXf83zpdAw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7CDED5C0992; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 5/8] rcutorture: Add end-of-test check to rcu_torture_fwd_prog() loop Date: Fri, 4 Feb 2022 15:53:24 -0800 Message-Id: <20220204235327.2948-5-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The second and subsequent forward-progress kthreads loop waiting for the first forward-progress kthread to start the next test interval. Unfortunately, if the test ends while one of those kthreads is waiting, the test will hang. This hang occurs because that wait loop fails to check for the end of the test. This commit therefore adds an end-of-test check to that wait loop. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index afe95c6948957..e99658efd97f4 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2515,7 +2515,7 @@ static int rcu_torture_fwd_prog(void *args) firsttime =3D false; WRITE_ONCE(rcu_fwd_seq, rcu_fwd_seq + 1); } else { - while (READ_ONCE(rcu_fwd_seq) =3D=3D oldseq) + while (READ_ONCE(rcu_fwd_seq) =3D=3D oldseq && !torture_must_stop()) schedule_timeout_interruptible(1); oldseq =3D READ_ONCE(rcu_fwd_seq); } --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 01584C433FE for ; Fri, 4 Feb 2022 23:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378359AbiBDXxq (ORCPT ); Fri, 4 Feb 2022 18:53:46 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:45768 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348892AbiBDXxc (ORCPT ); Fri, 4 Feb 2022 18:53:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 64386B83976; Fri, 4 Feb 2022 23:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDBB6C340F8; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018809; bh=APu/3aCknEcXKDub4KhH82mNQhHQnTLKFoAZJqOduhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dfkC9LUybIqs2n0dPhwuQnRc26yt6r/p/apaszeMcH0pg6us27JpbULe1XBcHApTE azvpSnaP0wnwkN1GoQnLAU2CBy3pW2/aA5PKC8lqGKtCHEttE/pzY3X4cByS5QH61s RmDHW78RErt2BxgZItCM28DyjkKcqocZQ5NvneYFsKwrRFq0nYKWa5q8IoUw/tLY7q X++KW2KY2B2ifNeC3i7CmEt4a31UN/USnz7DKRUkOqTz30AK9yI//zc1UZB6FtFnRq yxL/nYmEJwE6+7MJvvvudzfpDAHj2KptLMgx7PfCD9lLNuurpr6l52dZstgWkD/JUR LFE2v8cXAipwg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7EADC5C0A0A; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" , kernel test robot Subject: [PATCH rcu 6/8] rcutorture: Fix rcu_fwd_mutex deadlock Date: Fri, 4 Feb 2022 15:53:25 -0800 Message-Id: <20220204235327.2948-6-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The rcu_torture_fwd_cb_hist() function acquires rcu_fwd_mutex, but is invoked from rcutorture_oom_notify() function, which hold this same mutex across this call. This commit fixes the resulting deadlock. Reported-by: kernel test robot Tested-by: Oliver Sang Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index e99658efd97f4..1c8f40b90f70b 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2180,7 +2180,6 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *r= fp) for (i =3D ARRAY_SIZE(rfp->n_launders_hist) - 1; i > 0; i--) if (rfp->n_launders_hist[i].n_launders > 0) break; - mutex_lock(&rcu_fwd_mutex); // Serialize histograms. pr_alert("%s: Callback-invocation histogram %d (duration %lu jiffies):", __func__, rfp->rcu_fwd_id, jiffies - rfp->rcu_fwd_startat); gps_old =3D rfp->rcu_launder_gp_seq_start; @@ -2193,7 +2192,6 @@ static void rcu_torture_fwd_cb_hist(struct rcu_fwd *r= fp) gps_old =3D gps; } pr_cont("\n"); - mutex_unlock(&rcu_fwd_mutex); } =20 /* Callback function for continuous-flood RCU callbacks. */ @@ -2431,7 +2429,9 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *r= fp) n_launders, n_launders_sa, n_max_gps, n_max_cbs, cver, gps); atomic_long_add(n_max_cbs, &rcu_fwd_max_cbs); + mutex_lock(&rcu_fwd_mutex); // Serialize histograms. rcu_torture_fwd_cb_hist(rfp); + mutex_unlock(&rcu_fwd_mutex); } schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */ tick_dep_clear_task(current, TICK_DEP_BIT_RCU); --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 95FBCC433EF for ; Fri, 4 Feb 2022 23:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378453AbiBDXxj (ORCPT ); Fri, 4 Feb 2022 18:53:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378394AbiBDXxd (ORCPT ); Fri, 4 Feb 2022 18:53:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9C3C06C94C; Fri, 4 Feb 2022 15:53:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 68964B83978; Fri, 4 Feb 2022 23:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9F26C340FA; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018810; bh=CD9/OZPPyIm9sd6gKVYb1dK+c+5ezedy+TEEypg9DOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhi5fVmaEB0t3n39LHsGhX2HITZbKmJYYOvVXvJQDIDBr29n0R2JGzluGjVvGC7gN QZhJspl+ovlUXUlaijFgxomoYOOifiu5L6czU/c7XbqP79MN96thBiVRhcp/G3ZhvE tDrclwYUJvuGzbiV+VbN18GXFAxDL4St3KnsbQ5FoQ6AhnXUrYBKCDrB5hfpaoFxf0 2D2uBurj1XqXKmXhsXWBwAMy2ZqHeBvQGezVJfFUN5J0ywWeBnZ2nzNyvzTDcqrn+b jMckCRGfGlvfYFc/ccVhdtGevfboj6wClYQKHn2suqM6cbiVKUzHylxANnZmn+j8lo 3WpY9mz8CHWvw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 806E35C0A21; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Uladzislau Rezki Subject: [PATCH rcu 7/8] torture: Wake up kthreads after storing task_struct pointer Date: Fri, 4 Feb 2022 15:53:26 -0800 Message-Id: <20220204235327.2948-7-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently, _torture_create_kthread() uses kthread_run() to create torture-test kthreads, which means that the resulting task_struct pointer is stored after the newly created kthread has been marked runnable. This in turn can cause spurious failure of checks for code being run by a particular kthread. This commit therefore changes _torture_create_kthread() to use kthread_create(), then to do an explicit wake_up_process() after the task_struct pointer has been stored. Reported-by: Frederic Weisbecker Reviewed-by: Neeraj Upadhyay Reviewed-by: Uladzislau Rezki (Sony) Reviewed-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- kernel/torture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/torture.c b/kernel/torture.c index f55d803f995d4..789aeb0e1159c 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -931,12 +931,14 @@ int _torture_create_kthread(int (*fn)(void *arg), voi= d *arg, char *s, char *m, int ret =3D 0; =20 VERBOSE_TOROUT_STRING(m); - *tp =3D kthread_run(fn, arg, "%s", s); + *tp =3D kthread_create(fn, arg, "%s", s); if (IS_ERR(*tp)) { ret =3D PTR_ERR(*tp); TOROUT_ERRSTRING(f); *tp =3D NULL; + return ret; } + wake_up_process(*tp); // Process is sleeping, so ordering provided. torture_shuffle_task_register(*tp); return ret; } --=20 2.31.1.189.g2e36527f23 From nobody Mon Jun 29 17:43:50 2026 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 736B1C433FE for ; Fri, 4 Feb 2022 23:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378500AbiBDXxt (ORCPT ); Fri, 4 Feb 2022 18:53:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378372AbiBDXxb (ORCPT ); Fri, 4 Feb 2022 18:53:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5360CC06C947; Fri, 4 Feb 2022 15:53:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E226B61CD2; Fri, 4 Feb 2022 23:53:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F32A5C340FB; Fri, 4 Feb 2022 23:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644018810; bh=DMOYvBAXRRoyhUBWRSAHpF/K+fQJIPweBMqt5Vj1ut4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBYslGhwBQmT+Vmi/yvglKk9gle9XuyxAV9Hu8qw8KkKubmzitiBFmK3HWguDf5t7 oASQMjriPISvy+9Ucl5DzJEGyNlBRSkJ07H4FCosb1SPcot3euRLOebTIvOMMBeEbM hVaj+S4sGQP8jWpAL7kHRMKR4TjatpxTy+Ff364TPtbUUA53XXFVR9r6JKLOO5W+Tj XSuf83pCL1TwbLqLXv9pR6vzs5cYx++tLfqZWto45n2mHQknl1Bn7wj/3ja+JRtJ9+ YtwCzjyGgKMMRhOxXv4URAxe+aiZAmiUDeiSJ+pWMm0sA0/4OK3dlpsmffp5fiqbM4 ekunvp1ng26IA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 828025C0A6A; Fri, 4 Feb 2022 15:53:29 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 8/8] rcutorture: Enable limited callback-flooding tests of SRCU Date: Fri, 4 Feb 2022 15:53:27 -0800 Message-Id: <20220204235327.2948-8-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> References: <20220204235321.GA2511@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit allows up to 50,000 callbacks worth of callback-flooding tests of SRCU. The goal of this change is to exercise Tree SRCU's ability to transition from SRCU_SIZE_SMALL to SRCU_SIZE_BIG triggered by callback-queue-time lock contention. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 1c8f40b90f70b..b41db719085ef 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -674,6 +674,7 @@ static struct rcu_torture_ops srcu_ops =3D { .call =3D srcu_torture_call, .cb_barrier =3D srcu_torture_barrier, .stats =3D srcu_torture_stats, + .cbflood_max =3D 50000, .irq_capable =3D 1, .no_pi_lock =3D IS_ENABLED(CONFIG_TINY_SRCU), .name =3D "srcu" @@ -708,6 +709,7 @@ static struct rcu_torture_ops srcud_ops =3D { .call =3D srcu_torture_call, .cb_barrier =3D srcu_torture_barrier, .stats =3D srcu_torture_stats, + .cbflood_max =3D 50000, .irq_capable =3D 1, .no_pi_lock =3D IS_ENABLED(CONFIG_TINY_SRCU), .name =3D "srcud" --=20 2.31.1.189.g2e36527f23