From nobody Mon May 11 02:06:52 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 D7C1AC433EF for ; Tue, 19 Apr 2022 00:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238106AbiDSAKw (ORCPT ); Mon, 18 Apr 2022 20:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237916AbiDSAKe (ORCPT ); Mon, 18 Apr 2022 20:10:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2456146; Mon, 18 Apr 2022 17:07:52 -0700 (PDT) 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 D8447B81123; Tue, 19 Apr 2022 00:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 749CFC385AD; Tue, 19 Apr 2022 00:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650326869; bh=DTyMhxWth7RqAgPi1iypc1zMc6X4txtA5mNp5ZnXW0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uch6D45tphaUYJEhFZ/9zQZIHDFs9/IWjA7ZiZvJbiN30ct9qpCv7JNCFsxyVhQ7c f+B/9iKtRf8oE9CR6lCzDWB0omUhc5+kUoPakjImJ6xsYxlBXaqe+MZlJfMWaqABKD Q96XHRF5vLojpMrq3olY+Yaa8/mf5WnX8AZ0dOkTcFpzlSZkPzvnBuluqmBblGONL+ CgY6T4/SiQqc+IJ5NLOQ5B9Gmezz8LE0h1bzFniIWb+s6BnAK611lkh0qjvYPWFDzn ejpP5Aypt2SIa+QgfGZ213eRnfJ3vJ7ARCMQaAqsuD5j4Tt++2ZcHy/J0e/04E60dm oqJlApUa1qcSg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 20D395C04BD; Mon, 18 Apr 2022 17:07:49 -0700 (PDT) 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/6] torture: Add rcu_normal and rcu_expedited runs to torture.sh Date: Mon, 18 Apr 2022 17:07:41 -0700 Message-Id: <20220419000746.3949667-1-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220419000541.GA3949109@paulmck-ThinkPad-P17-Gen-1> References: <20220419000541.GA3949109@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, the rcupdate.rcu_normal and rcupdate.rcu_expedited kernel boot parameters are not regularly tested. The potential addition of polled expedited grace-period APIs increases the amount of code that is affected by these kernel boot parameters. This commit therefore adds a "--do-rt" argument to torture.sh to exercise these kernel-boot options. Signed-off-by: Paul E. McKenney --- .../selftests/rcutorture/bin/torture.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/test= ing/selftests/rcutorture/bin/torture.sh index bfe09e2829c8..e657a6e06417 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -54,6 +54,7 @@ do_kvfree=3Dyes do_kasan=3Dyes do_kcsan=3Dno do_clocksourcewd=3Dyes +do_rt=3Dyes =20 # doyesno - Helper function for yes/no arguments function doyesno () { @@ -82,6 +83,7 @@ usage () { echo " --do-rcuscale / --do-no-rcuscale" echo " --do-rcutorture / --do-no-rcutorture" echo " --do-refscale / --do-no-refscale" + echo " --do-rt / --do-no-rt" echo " --do-scftorture / --do-no-scftorture" echo " --duration [ | h | d ]" echo " --kcsan-kmake-arg kernel-make-arguments" @@ -118,6 +120,7 @@ do do_scftorture=3Dyes do_rcuscale=3Dyes do_refscale=3Dyes + do_rt=3Dyes do_kvfree=3Dyes do_kasan=3Dyes do_kcsan=3Dyes @@ -148,6 +151,7 @@ do do_scftorture=3Dno do_rcuscale=3Dno do_refscale=3Dno + do_rt=3Dno do_kvfree=3Dno do_kasan=3Dno do_kcsan=3Dno @@ -162,6 +166,9 @@ do --do-refscale|--do-no-refscale) do_refscale=3D`doyesno "$1" --do-refscale` ;; + --do-rt|--do-no-rt) + do_rt=3D`doyesno "$1" --do-rt` + ;; --do-scftorture|--do-no-scftorture) do_scftorture=3D`doyesno "$1" --do-scftorture` ;; @@ -354,6 +361,17 @@ then torture_set "scftorture" tools/testing/selftests/rcutorture/bin/kvm.sh --= torture scf --allcpus --duration "$duration_scftorture" --configs "$configs= _scftorture" --kconfig "CONFIG_NR_CPUS=3D$HALF_ALLOTED_CPUS" --memory 1G --= trust-make fi =20 +if test "$do_rt" =3D "yes" +then + # With all post-boot grace periods forced to normal. + torture_bootargs=3D"rcupdate.rcu_cpu_stall_suppress_at_boot=3D1 torture.d= isable_onoff_at_boot rcupdate.rcu_task_stall_timeout=3D30000 rcupdate.rcu_n= ormal=3D1" + torture_set "rcurttorture" tools/testing/selftests/rcutorture/bin/kvm.sh = --allcpus --duration "$duration_rcutorture" --configs "TREE03" --trust-make + + # With all post-boot grace periods forced to expedited. + torture_bootargs=3D"rcupdate.rcu_cpu_stall_suppress_at_boot=3D1 torture.d= isable_onoff_at_boot rcupdate.rcu_task_stall_timeout=3D30000 rcupdate.rcu_e= xpedited=3D1" + torture_set "rcurttorture-exp" tools/testing/selftests/rcutorture/bin/kvm= .sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --trust-= make +fi + if test "$do_refscale" =3D yes then primlist=3D"`grep '\.name[ ]*=3D' kernel/rcu/refscale.c | sed -e 's/^[^"= ]*"//' -e 's/".*$//'`" --=20 2.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:52 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 84F02C433FE for ; Tue, 19 Apr 2022 00:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238016AbiDSAKh (ORCPT ); Mon, 18 Apr 2022 20:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237868AbiDSAKe (ORCPT ); Mon, 18 Apr 2022 20:10:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94660B07; Mon, 18 Apr 2022 17:07:50 -0700 (PDT) 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 2A5706123D; Tue, 19 Apr 2022 00:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76F23C385B0; Tue, 19 Apr 2022 00:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650326869; bh=Odu9Jp/hxYy/VMF9e4eVFNWBvKvfuFd+U74qxGLF8ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=clxgJoQ2pEzdSST8FXA+gyHzn/G2LU7vD7i7iM0uipY/ir+lmMpvulhzmgpGJOd2F zI6WUl8eAeCSH4kQLRMPUZ8OsR8o48Sp9x+9C4CacEmhzXP7ihFqkoNDe2xhydJXSF 70FUyxY4HqTQSg6MO1kuvfQwp0YVl3NGtvq/IFNtnNyPh6SJg1VprzaLUE0GwQwiA5 Ck08ROzo6lyJpR8uRsAmPOTun7gkLbUinV6wPt4zxcvHDrlvuXxG8R4WN6/HNJidSf l36nrmgK3sMKc4047KU2Tv+HpOnvpscSD/pFkKC88tSPKBa7+JicNYz1PvFhsCy6gr EdYh/SQC0EXkA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2263A5C03F4; Mon, 18 Apr 2022 17:07:49 -0700 (PDT) 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/6] rcutorture: Suppress debugging grace period delays during flooding Date: Mon, 18 Apr 2022 17:07:42 -0700 Message-Id: <20220419000746.3949667-2-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220419000541.GA3949109@paulmck-ThinkPad-P17-Gen-1> References: <20220419000541.GA3949109@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" Tree RCU supports grace-period delays using the rcutree.gp_cleanup_delay, rcutree.gp_init_delay, and rcutree.gp_preinit_delay kernel boot parameters. These delays are strictly for debugging purposes, and have proven quite effective at exposing bugs involving race with CPU-hotplug operations. However, these delays can result in false positives when used in conjunction with callback flooding, for example, those generated by the rcutorture.fwd_progress kernel boot parameter. This commit therefore suppresses grace-period delays while callback flooding is in progress. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcu.h | 4 ++++ kernel/rcu/rcutorture.c | 4 ++++ kernel/rcu/tree.c | 32 +++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 24b5f2c2de87..7a221393fcdb 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -523,6 +523,8 @@ static inline bool rcu_check_boost_fail(unsigned long g= p_state, int *cpup) { ret static inline void show_rcu_gp_kthreads(void) { } static inline int rcu_get_gp_kthreads_prio(void) { return 0; } static inline void rcu_fwd_progress_check(unsigned long j) { } +static inline void rcu_gp_slow_register(atomic_t *rgssp) { } +static inline void rcu_gp_slow_unregister(atomic_t *rgssp) { } #else /* #ifdef CONFIG_TINY_RCU */ bool rcu_dynticks_zero_in_eqs(int cpu, int *vp); unsigned long rcu_get_gp_seq(void); @@ -535,6 +537,8 @@ void rcu_fwd_progress_check(unsigned long j); void rcu_force_quiescent_state(void); extern struct workqueue_struct *rcu_gp_wq; extern struct workqueue_struct *rcu_par_gp_wq; +void rcu_gp_slow_register(atomic_t *rgssp); +void rcu_gp_slow_unregister(atomic_t *rgssp); #endif /* #else #ifdef CONFIG_TINY_RCU */ =20 #ifdef CONFIG_RCU_NOCB_CPU diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 55d049c39608..f37b7a01dcd0 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2916,10 +2916,12 @@ rcu_torture_cleanup(void) pr_info("%s: Invoking %pS().\n", __func__, cur_ops->cb_barrier); cur_ops->cb_barrier(); } + rcu_gp_slow_unregister(NULL); return; } if (!cur_ops) { torture_cleanup_end(); + rcu_gp_slow_unregister(NULL); return; } =20 @@ -3016,6 +3018,7 @@ rcu_torture_cleanup(void) else rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS"); torture_cleanup_end(); + rcu_gp_slow_unregister(&rcu_fwd_cb_nodelay); } =20 #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD @@ -3320,6 +3323,7 @@ rcu_torture_init(void) if (object_debug) rcu_test_debug_objects(); torture_init_end(); + rcu_gp_slow_register(&rcu_fwd_cb_nodelay); return 0; =20 unwind: diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index a4b8189455d5..db67dae8ed88 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1705,11 +1705,37 @@ static void note_gp_changes(struct rcu_data *rdp) rcu_gp_kthread_wake(); } =20 +static atomic_t *rcu_gp_slow_suppress; + +/* Register a counter to suppress debugging grace-period delays. */ +void rcu_gp_slow_register(atomic_t *rgssp) +{ + WARN_ON_ONCE(rcu_gp_slow_suppress); + + WRITE_ONCE(rcu_gp_slow_suppress, rgssp); +} +EXPORT_SYMBOL_GPL(rcu_gp_slow_register); + +/* Unregister a counter, with NULL for not caring which. */ +void rcu_gp_slow_unregister(atomic_t *rgssp) +{ + WARN_ON_ONCE(rgssp && rgssp !=3D rcu_gp_slow_suppress); + + WRITE_ONCE(rcu_gp_slow_suppress, NULL); +} +EXPORT_SYMBOL_GPL(rcu_gp_slow_unregister); + +static bool rcu_gp_slow_is_suppressed(void) +{ + atomic_t *rgssp =3D READ_ONCE(rcu_gp_slow_suppress); + + return rgssp && atomic_read(rgssp); +} + static void rcu_gp_slow(int delay) { - if (delay > 0 && - !(rcu_seq_ctr(rcu_state.gp_seq) % - (rcu_num_nodes * PER_RCU_NODE_PERIOD * delay))) + if (!rcu_gp_slow_is_suppressed() && delay > 0 && + !(rcu_seq_ctr(rcu_state.gp_seq) % (rcu_num_nodes * PER_RCU_NODE_PERIO= D * delay))) schedule_timeout_idle(delay); } =20 --=20 2.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:52 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 EEE9AC4332F for ; Tue, 19 Apr 2022 00:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238189AbiDSAKq (ORCPT ); Mon, 18 Apr 2022 20:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237921AbiDSAKe (ORCPT ); Mon, 18 Apr 2022 20:10:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108D55FB4; Mon, 18 Apr 2022 17:07:52 -0700 (PDT) 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 C83FCB81141; Tue, 19 Apr 2022 00:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E492C385AF; Tue, 19 Apr 2022 00:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650326869; bh=a+rWJevxec7dObhHrxLmxlRKyIcRrrEQ/UTfcqpgkMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=paP0T0xfRLShG6PxGBY/wCMVWHBIgjBrfN++DLTFgiBVVoNJToVUQLZJYhtuX48Zg DfwAjfULfSZZxzVnvPZPNETkY0Fkp/dYhHJXO1jOPIyan0jiaGpXAJaTkqKKuDrwzD OhlVEUKbcoFVwVmL0mrs6rlRDxkt6j8Ak5NZ+hqps2Nsj+bEP1VHg8D6JoeiUNGlm0 WF2YK+TD5UOgKj2YBuQkpVLvmbl5TyqtFg94oEsvzCkAMJP0vhdYnQJbh3ElQmG6eo K8uVA/Pm9J3yD9KJ+LAtxPZdtrkvxHvtTMtwq1cDYdPCu/wx6GdhSLwskCAcZ26T27 gwZ4BCTZx9qmg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 245FA5C0848; Mon, 18 Apr 2022 17:07:49 -0700 (PDT) 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/6] scftorture: Fix distribution of short handler delays Date: Mon, 18 Apr 2022 17:07:43 -0700 Message-Id: <20220419000746.3949667-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220419000541.GA3949109@paulmck-ThinkPad-P17-Gen-1> References: <20220419000541.GA3949109@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 scftorture test module's scf_handler() function is supposed to provide three different distributions of short delays (including "no delay") and one distribution of long delays, if specified by the scftorture.longwait module parameter. However, the second of the two non-zero-wait short delays is disabled due to the first such delay's "goto out" not being enclosed in the "then" clause with the "udelay()". This commit therefore adjusts the code to provide the intended set of delays. Fixes: e9d338a0b179 ("scftorture: Add smp_call_function() torture test") Signed-off-by: Paul E. McKenney --- kernel/scftorture.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/scftorture.c b/kernel/scftorture.c index dcb0410950e4..5d113aa59e77 100644 --- a/kernel/scftorture.c +++ b/kernel/scftorture.c @@ -267,9 +267,10 @@ static void scf_handler(void *scfc_in) } this_cpu_inc(scf_invoked_count); if (longwait <=3D 0) { - if (!(r & 0xffc0)) + if (!(r & 0xffc0)) { udelay(r & 0x3f); - goto out; + goto out; + } } if (r & 0xfff) goto out; --=20 2.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:52 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 104FDC433EF for ; Tue, 19 Apr 2022 00:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238075AbiDSAKn (ORCPT ); Mon, 18 Apr 2022 20:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237883AbiDSAKe (ORCPT ); Mon, 18 Apr 2022 20:10:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C822DE5; Mon, 18 Apr 2022 17:07:50 -0700 (PDT) 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 09E79612E6; Tue, 19 Apr 2022 00:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CA73C385A9; Tue, 19 Apr 2022 00:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650326869; bh=FfYldHDuDIR3YtfmA0EGplElFP2BYkBWmQJSnq5n8i4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7/K4hgFyaLNLYXJcaPW87HxCBNa+RPhMTmNUBnty2NymEQ2+ZX0/Nk95LqTTvvDg R76mrQx+nV6GAb/AKPTQqcVQ2ApcGua8YD/pwk4xarm063SwKITqXfP40iGmRL20gz fp4uDizXXo3D9wNEMRV9mte1F7LDPA81PWSpuAfyki4H3Vw68u0fVvWQdatmvjruOf 0no5cyqmCMocyomfuBz9Ch16u+5s4LrFu9fEnqOnKmrVpYufV/biIhgqdnrU9gAcTu a4071kx4CvaPBcNo8jmfY9RZlpcDOx7m5Lw/QbJzAjyQWCCyojguiVR4pvC3J9cgKR aVcpUtmEDa/UA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 264B75C0A0D; Mon, 18 Apr 2022 17:07:49 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, David Vernet , "Paul E . McKenney" Subject: [PATCH rcu 4/6] rcutorture: Avoid corner-case #DE with nsynctypes check Date: Mon, 18 Apr 2022 17:07:44 -0700 Message-Id: <20220419000746.3949667-4-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220419000541.GA3949109@paulmck-ThinkPad-P17-Gen-1> References: <20220419000541.GA3949109@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" From: David Vernet The rcutorture module is used to run torture tests that validate RCU. rcutorture takes a variety of module parameters that configure the functionality of the test. Amongst these parameters are the types of synchronization mechanisms that the rcu_torture_writer and rcu_torture_fakewriter tasks may use, and the torture_type of the run which determines what read and sync operations are used by the various writer and reader tasks that run throughout the test. When the module is configured to only use sync types for which the specified torture_type does not implement the necessary operations, we can end up in a state where nsynctypes is 0. This is not an erroneous state, but it currently crashes the kernel with a #DE due to nsynctypes being used with a modulo operator in rcu_torture_fakewriter(). Here is an example of such a #DE: $ insmod ./rcutorture.ko gp_cond=3D1 gp_cond_exp=3D0 gp_exp=3D0 gp_poll_exp= =3D0 gp_normal=3D0 gp_poll=3D0 gp_poll_exp=3D0 verbose=3D9999 torture_type=3Dtri= vial ... [ 8536.525096] divide error: 0000 [#1] PREEMPT SMP PTI [ 8536.525101] CPU: 30 PID: 392138 Comm: rcu_torture_fak Kdump: loaded Tain= ted: G S 5.17.0-rc1-00179-gc8c42c80febd #24 [ 8536.525105] Hardware name: Quanta Twin Lakes MP/Twin Lakes Passive MP, B= IOS F09_3A23 12/08/2020 [ 8536.525106] RIP: 0010:rcu_torture_fakewriter+0xf1/0x2d0 [rcutorture] [ 8536.525121] Code: 00 31 d2 8d 0c f5 00 00 00 00 48 63 c9 48 f7 f1 48 85 = d2 0f 84 79 ff ff ff 48 89 e7 e8 78 78 01 00 48 63 0d 29 ca 00 00 31 d2 <48= > f7 f1 8b 04 95 00 05 4e a0 83 f8 06 0f 84 ad 00 00 00 7f 1f 83 [ 8536.525124] RSP: 0018:ffffc9000777fef0 EFLAGS: 00010246 [ 8536.525127] RAX: 00000000223d006e RBX: cccccccccccccccd RCX: 00000000000= 00000 [ 8536.525130] RDX: 0000000000000000 RSI: ffffffff824315b9 RDI: ffffc900077= 7fef0 [ 8536.525132] RBP: ffffc9000487bb30 R08: 0000000000000002 R09: 00000000000= 2a580 [ 8536.525134] R10: ffffffff82c5f920 R11: 0000000000000000 R12: ffff8881a2c= 35d00 [ 8536.525136] R13: ffff8881540c8d00 R14: ffffffffa04d39d0 R15: 00000000000= 00000 [ 8536.525137] FS: 0000000000000000(0000) GS:ffff88903ff80000(0000) knlGS:= 0000000000000000 [ 8536.525140] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 8536.525142] CR2: 00007f839f022000 CR3: 0000000002c0a006 CR4: 00000000007= 706e0 [ 8536.525144] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 00000000000= 00000 [ 8536.525145] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 00000000000= 00400 [ 8536.525147] PKRU: 55555554 [ 8536.525148] Call Trace: [ 8536.525150] [ 8536.525153] kthread+0xe8/0x110 [ 8536.525161] ? kthread_complete_and_exit+0x20/0x20 [ 8536.525167] ret_from_fork+0x22/0x30 [ 8536.525174] The solution is to gracefully handle the case of nsynctypes being 0 in rcu_torture_fakewriter() by not performing any work. This is already being done in rcu_torture_writer(), though there is a missing return on that path which will be fixed in a subsequent patch. Signed-off-by: David Vernet Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index f37b7a01dcd0..d5105fb6c980 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1322,6 +1322,17 @@ rcu_torture_fakewriter(void *arg) VERBOSE_TOROUT_STRING("rcu_torture_fakewriter task started"); set_user_nice(current, MAX_NICE); =20 + if (WARN_ONCE(nsynctypes =3D=3D 0, + "%s: No update-side primitives.\n", __func__)) { + /* + * No updates primitives, so don't try updating. + * The resulting test won't be testing much, hence the + * above WARN_ONCE(). + */ + torture_kthread_stopping("rcu_torture_fakewriter"); + return 0; + } + do { torture_hrtimeout_jiffies(torture_random(&rand) % 10, &rand); if (cur_ops->cb_barrier !=3D NULL && --=20 2.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:52 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 E3378C433F5 for ; Tue, 19 Apr 2022 00:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238391AbiDSAK7 (ORCPT ); Mon, 18 Apr 2022 20:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237905AbiDSAKe (ORCPT ); Mon, 18 Apr 2022 20:10:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088DE3A7; Mon, 18 Apr 2022 17:07:52 -0700 (PDT) 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 B2887B81128; Tue, 19 Apr 2022 00:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69CC2C385A7; Tue, 19 Apr 2022 00:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650326869; bh=foMf23lIes/rMz31pIG7k0ikz3d3jyzbGaaxO/rqneQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDWcWieJ9hUB60S2H6udEw6eCNgTrAhp+Z3TGaTP0n5G3sZ6ZHCP+jhTfTkAvunk3 L5h+oVLbidYo6TcZDIwKBrZctHuvWKMCv7i+8qiCoBHB556yqWcXuVIGM+Bts8Ef1o UrZYZT7YPoQpuYbY/DqrMNeMgr4SnijxW+vpi4I3BEryq+CcRk1wduxT/qC0wXv1jQ 2VkiJ06d6iQ2M6HQfHsBKG1vbdVCqmeSwcLcRTpjxcDTWJW2N3T1XNVTKxFrJk7yth LH3v3zbi1zdlvNGMlpOJe4NtQMGT3fGdJ1aGetddvEKTpypjJSXLoVbjlYmVC5FuGH hbeN8BgQmN2yg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2887A5C0A23; Mon, 18 Apr 2022 17:07:49 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, David Vernet , "Paul E . McKenney" Subject: [PATCH rcu 5/6] rcutorture: Add missing return and use __func__ in warning Date: Mon, 18 Apr 2022 17:07:45 -0700 Message-Id: <20220419000746.3949667-5-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220419000541.GA3949109@paulmck-ThinkPad-P17-Gen-1> References: <20220419000541.GA3949109@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" From: David Vernet The rcutorture module has an rcu_torture_writer task that repeatedly performs writes, synchronizations, and deletes. There is a corner-case check in rcu_torture_writer() wherein if nsynctypes is 0, a warning is issued and the task waits to be stopped via a call to torture_kthread_stopping() rather than performing any work. There should be a return statement following this call to torture_kthread_stopping(), as the intention with issuing the call to torture_kthread_stopping() in the first place is to avoid the rcu_torture_writer task from performing any work. Some of the work may even be dangerous to perform, such as potentially causing a #DE due to nsynctypes being used in a modulo operator when querying for sync updates to issue. This patch adds the missing return call. As a bonus, it also fixes a checkpatch warning that was emitted due to the WARN_ONCE() call using the name of the function rather than __func__. Signed-off-by: David Vernet Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index d5105fb6c980..f1292d9e86b5 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1178,7 +1178,7 @@ rcu_torture_writer(void *arg) " GP expediting controlled from boot/sysfs for %s.\n", torture_type, cur_ops->name); if (WARN_ONCE(nsynctypes =3D=3D 0, - "rcu_torture_writer: No update-side primitives.\n")) { + "%s: No update-side primitives.\n", __func__)) { /* * No updates primitives, so don't try updating. * The resulting test won't be testing much, hence the @@ -1186,6 +1186,7 @@ rcu_torture_writer(void *arg) */ rcu_torture_writer_state =3D RTWS_STOPPING; torture_kthread_stopping("rcu_torture_writer"); + return 0; } =20 do { --=20 2.31.1.189.g2e36527f23 From nobody Mon May 11 02:06:52 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 670BEC433F5 for ; Tue, 19 Apr 2022 00:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238234AbiDSAKs (ORCPT ); Mon, 18 Apr 2022 20:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237940AbiDSAKe (ORCPT ); Mon, 18 Apr 2022 20:10:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A654663D6; Mon, 18 Apr 2022 17:07:52 -0700 (PDT) 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 58FE8B8113A; Tue, 19 Apr 2022 00:07:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF473C385B7; Tue, 19 Apr 2022 00:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650326869; bh=He2ZUlSMEvn9zM0ylx3h/dbdQFC19ze5vEZT/mXl27Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2uS3++JmOpIsaj7TfjHXB6rdC7h/XHLbGy02RGZRGoVq0PoIr4L+wJep0WcVl0Rg /YMkRUSTVWgW3b8b2O9tZvpcaZwDMRtfAoXAtFd48B3Y47HmGV1R4T43gmascbD1Yw kNOHK096PPfWOVb4Mt7qmUEJBMVOp74O6s5bCX12D/7vyyYa3jonshy9d8e4MKgsvL eCyYGf/9UpT0b3mWTMhdVndOrtBjn69nJTiLhrUWGTiMG+mzrXxOsXEbfBVILvRBG2 RjpiyrsqXQag3e2UhfwK/gI3x4DzCuY6WS5xn8zMMX3TMgMkQ1DAVrpCOiahsgPV6J 9ojJ+q+/n/ODw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2A6A05C0B86; Mon, 18 Apr 2022 17:07:49 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Frederic Weisbecker , "Paul E . McKenney" Subject: [PATCH rcu 6/6] rcutorture: Call preempt_schedule() through static call/key Date: Mon, 18 Apr 2022 17:07:46 -0700 Message-Id: <20220419000746.3949667-6-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220419000541.GA3949109@paulmck-ThinkPad-P17-Gen-1> References: <20220419000541.GA3949109@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" From: Frederic Weisbecker The rcutorture test suite sometimess triggers a random scheduler preemption call while simulating a read delay. Unfortunately, its direct call to preempt_schedule() bypasses the static call/key filter used by CONFIG_PREEMPT_DYNAMIC. This breaks the no-preempt assumption when the dynamic preemption mode is "none". For example, rcu_blocking_is_gp() is fooled and abbreviates grace periods when the CPU runs in no-preempt UP mode. Fix this by making torture_preempt_schedule() call __preempt_schedule(), which uses the static call/key. Reported-by: Paul E. McKenney Signed-off-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- include/linux/torture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/torture.h b/include/linux/torture.h index 63fa4196e51c..7038104463e4 100644 --- a/include/linux/torture.h +++ b/include/linux/torture.h @@ -118,7 +118,7 @@ void _torture_stop_kthread(char *m, struct task_struct = **tp); _torture_stop_kthread("Stopping " #n " task", &(tp)) =20 #ifdef CONFIG_PREEMPTION -#define torture_preempt_schedule() preempt_schedule() +#define torture_preempt_schedule() __preempt_schedule() #else #define torture_preempt_schedule() do { } while (0) #endif --=20 2.31.1.189.g2e36527f23