From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E9F92215073; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=GNHT7Q1kEQdmkAe3EVUoRizTr/zpABPIkoe7m6YUFHvTwXEBn/HkAKCoEIaVuR2TiWosTKVhIfI1uCUXobyKw3QrFgcq7nGR8qT3pdaySDjhwpAhJDtfWk8/dAI1QBG8h7z2+CHAJpocuLKJz/pH2ZaBZiIZyZGhuYWcwHPu7RA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=77AYLHKjJDUAxlPSNSjE5Yx8FldJR4VJKjnY8y5KFC8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mgdwFamwBlq9UTmfGmdZ60CM+O1/KunWUsRnCU6FivHgAIi+6dlZcrmKdUIiTfmKELyuCGQzh66Cb+pcxRrPs9KM0UbX87F+5iPZR/XMmV0BmvrEg1on79ZLp7jPcm8Ph4wtRi95B3Bj4rJQiuwmAmpm33LyLxH4QkeUSD25hYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=slC7fkxD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="slC7fkxD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71B86C4CEE5; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=77AYLHKjJDUAxlPSNSjE5Yx8FldJR4VJKjnY8y5KFC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slC7fkxDPp+7PFcG720jp6SwhBm+3ATcG0jFNAUE+luEy+OwRfgdFNAaH2x4JUc1F sPmu67F93C0sLm1jWHB6SW2f1uiXt1Dx3ElIrY9/XbyUPltel150jXpO3H1kyx/FIc /nqgWjwIJDmOWkd+Evl/lw7X8JiRAatKUS5oXTbFU+0n4HUJiq191M2FColzRHDDBN aIR650fdt5LRdo1BWAMiUmQXsaysoTGFlBHASF+hD1bxtLaiv3m4nU0hd8eBmP1ESg v2XGo/MqR85E6T5AjjWBfa+kFpR9hKKXnXyZFQ3b+D9GPwMZ3GGCj3CN2Q3ar/VQuB wlHl/l9Q4UcaA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 230E5CE0869; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 01/12] rcutorture: Make srcu_lockdep.sh check kernel Kconfig Date: Mon, 31 Mar 2025 14:03:03 -0700 Message-Id: <20250331210314.590622-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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 srcu_lockdep.sh currently blindly trusts the rcutorture SRCU-P scenario to build its kernel with lockdep enabled. Of course, this dependency might not be obvious to someone rebalancing SRCU scenarios. This commit therefore adds code to srcu_lockdep.sh that verifies that the .config file has lockdep enabled. Signed-off-by: Paul E. McKenney --- .../testing/selftests/rcutorture/bin/srcu_lockdep.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools= /testing/selftests/rcutorture/bin/srcu_lockdep.sh index 2db12c5cad9c6..b94f6d3445c6c 100755 --- a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh +++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh @@ -39,8 +39,9 @@ do shift done =20 -err=3D nerrs=3D0 + +# Test lockdep's handling of deadlocks. for d in 0 1 do for t in 0 1 2 @@ -52,6 +53,12 @@ do tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s -= -configs "SRCU-P" --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=3Dy" --bootarg= s "rcutorture.test_srcu_lockdep=3D$val rcutorture.reader_flavor=3D0x2" --tr= ust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1 ret=3D$? mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val" + if ! grep -q '^CONFIG_PROVE_LOCKING=3Dy' .config + then + echo "rcu_torture_init_srcu_lockdep:Error: CONFIG_PROVE_LOCKING disabl= ed in rcutorture SRCU-P scenario" + nerrs=3D$((nerrs+1)) + err=3D1 + fi if test "$d" -ne 0 && test "$ret" -eq 0 then err=3D1 @@ -71,6 +78,8 @@ do done done done + +# Set up exit code. if test "$nerrs" -ne 0 then exit 1 --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E9F3A21147A; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=Y/+3+Q/Voe9nsE+A04WTthPMVc0qvws3V+dKfMx9OZvhyYh03VK6RJaaogyHqz3NmIogX3Rzs6ROsahCU3tSrJMWnjM9j89UbhSgL6gBbR0flDzkDh465aEGTlU+e5vrQJocNS/dTZuuZ5jraiwH2qKJV4fH4gU9jBrpoJrodvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=Vh4wzubR/QtoBshTTizJkq+P2DARWdEyUI69hQkMTBQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hs2rjcz0A+suksNxOdpdGKuvsrRBY46NBQGeVF4+/3PFRscPkmkGsqKdu0hqAZz0urWPwkfNzjYSIXRI4dIVakRPJuNovx7pGguySsMTSjNz8s9qZj1cbiExWpfIbSotR1JZ5kzdxUQFEULZLNU+EI/rPDch6lCD+7vVJ/QI1kM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TAZWfzDl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TAZWfzDl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E3A8C4CEE3; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=Vh4wzubR/QtoBshTTizJkq+P2DARWdEyUI69hQkMTBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAZWfzDlx9XqGP2MZAs/PVSmmSlCInk7DRFxrzRAshxvFO40l53Ga7rwM9F0+OX6L 31mtC2NTwkt1UL1clcU+TnqLLDPMJY/0RceA7wgViPP4nRFikfybxLtzdyhJb909ci bGUg8zy2uc3gl72Ufs4cZVX98rU3jxD+DOxdhj94is0dO7ItwwJ/i9OGDgxHQbEteI jgoc2c+S2eVc5QLKE3ncB7Grc2FMw6BDNpqCNrFMaUdlvM05nsRhk5dI5+kE1AwM3n Xi4WE1TkFBFFsvWb9aujLmeKP1B07E73Y2E263oIHmHUaABiZJHfhq84GMNm8Cf35X AxYLSveNLiAoQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 274BECE09EE; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 02/12] rcutorture: Make srcu_lockdep.sh check reader-conflict handling Date: Mon, 31 Mar 2025 14:03:04 -0700 Message-Id: <20250331210314.590622-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" Mixing different flavors of RCU readers is forbidden, for example, you should not use srcu_read_lock() and srcu_read_lock_nmisafe() on the same srcu_struct structure. There are checks for this, but these checks are not tested on a regular basis. This commit therefore adds such tests to srcu_lockdep.sh. Signed-off-by: Paul E. McKenney --- .../selftests/rcutorture/bin/srcu_lockdep.sh | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh b/tools= /testing/selftests/rcutorture/bin/srcu_lockdep.sh index b94f6d3445c6c..208be7d09a612 100755 --- a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh +++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh @@ -79,6 +79,37 @@ do done done =20 +# Test lockdep-enabled testing of mixed SRCU readers. +for val in 0x1 0xf +do + err=3D + tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --c= onfigs "SRCU-P" --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=3Dy" --bootargs = "rcutorture.reader_flavor=3D$val" --trust-make --datestamp "$ds/$val" > "$T= /kvm.sh.out" 2>&1 + ret=3D$? + mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val" + if ! grep -q '^CONFIG_PROVE_LOCKING=3Dy' .config + then + echo "rcu_torture_init_srcu_lockdep:Error: CONFIG_PROVE_LOCKING disabled= in rcutorture SRCU-P scenario" + nerrs=3D$((nerrs+1)) + err=3D1 + fi + if test "$val" -eq 0xf && test "$ret" -eq 0 + then + err=3D1 + echo -n Unexpected success for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err" + fi + if test "$val" -eq 0x1 && test "$ret" -ne 0 + then + err=3D1 + echo -n Unexpected failure for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err" + fi + if test -n "$err" + then + grep "rcu_torture_init_srcu_lockdep: test_srcu_lockdep =3D " "$RCUTORTUR= E/res/$ds/$val/SRCU-P/console.log" | sed -e 's/^.*rcu_torture_init_srcu_loc= kdep://' >> "$RCUTORTURE/res/$ds/$val/kvm.sh.err" + cat "$RCUTORTURE/res/$ds/$val/kvm.sh.err" + nerrs=3D$((nerrs+1)) + fi +done + # Set up exit code. if test "$nerrs" -ne 0 then --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E9EE31D5CFB; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=DlRwSCbItt/O1ioeJX4YeCuie5DoNxbq6tZvW+kYeXkOaBISo6RzZRMoXOtcjJ2nE3VPndwVExSiqZWBVROYjsttDBgUWqDmBfDJq/ZXwy9FQyzZBAV4sznURQ7L5S6gEBnyhRABhzhzxBy+IAPjsI6VNGGIAy3q05WM2bOovvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=4Ai2javJFGPUL16QmZ1bVGq4ISa/G87CeO9P6yL8XAA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lCxrtaSMmN5Afro81rPAdR7AteArENbm7nUHdbT7137Z0eOWzpuNYd5Wa/gsttVp9z+NUOX+17BvL7cttcdrgDeitEtXnhkWReY8swpnjga6PSCB+QXAqZk0FrKZh/sVBuB/HObD8cPyGc0Pc4rW3bi1XcF7jiUstObeYAW+aUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YV9b36cO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YV9b36cO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 897F4C4CEEA; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=4Ai2javJFGPUL16QmZ1bVGq4ISa/G87CeO9P6yL8XAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YV9b36cO49mM/0VAHMqlxhpmGJWcD3STXodtYDzid8TLRghtTeTMP6dgec/7z5djZ zzu0spFEnQVaP1ltwVcMSDdTlJjlDEFEMFhvExBEI5/unD3FTrpenvzFUUdUw+3mhN 1cRHSt8Dpa5gun5GcXx1LxTcDAfFwql2VnZpQQ4t50ZDhDHPoKKynu9VwQEElRPDjy uM5KPRHyZQm7cJiNQjuTWteWDTvbzCYZ/nsnLc51dBGoux7fj3ijiOBudF05uduXRV OqgrAGk0zkAgxHpQ2cxpuFKXIJGd1hIqzNMTPcKvwzRNe2QmMEwPW909xdVjEVbWlh YHrEQS2POqxbQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 292EACE0C96; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 03/12] rcutorture: Split out beginning and end from rcu_torture_one_read() Date: Mon, 31 Mar 2025 14:03:05 -0700 Message-Id: <20250331210314.590622-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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 rcu_torture_one_read() function is designed for RCU readers that are confined to a task, such that a single thread of control extends from the beginning of a given RCU read-side critical section to its end. This does not suffice for things like srcu_down_read() and srcu_up_read(), where the critical section might start at task level and end in a timer handler. This commit therefore creates separate init_rcu_torture_one_read_state(), rcu_torture_one_read_start(), and rcu_torture_one_read_end() functions, along with a rcu_torture_one_read_state structure to coordinate their actions. These will be used to create tests for srcu_down_read() and friends. One caution: The caller to rcu_torture_one_read_start() must enter the initial read-side critical section prior to the call. This enables use of non-standard primitives such as srcu_down_read() while still using the same validation code. --- kernel/rcu/rcutorture.c | 124 ++++++++++++++++++++++++++-------------- 1 file changed, 81 insertions(+), 43 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 65095664f5c5b..b0e96df636226 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2164,53 +2164,70 @@ rcutorture_loop_extend(int *readstate, bool insofti= rq, struct torture_random_sta return &rtrsp[j]; } =20 -/* - * Do one read-side critical section, returning false if there was - * no data to read. Can be invoked both from process context and - * from a timer handler. - */ -static bool rcu_torture_one_read(struct torture_random_state *trsp, long m= yid) -{ - bool checkpolling =3D !(torture_random(trsp) & 0xfff); +struct rcu_torture_one_read_state { + bool checkpolling; unsigned long cookie; struct rcu_gp_oldstate cookie_full; - int i; unsigned long started; - unsigned long completed; - int newstate; struct rcu_torture *p; - int pipe_count; - bool preempted =3D false; - int readstate =3D 0; - struct rt_read_seg rtseg[RCUTORTURE_RDR_MAX_SEGS] =3D { { 0 } }; - struct rt_read_seg *rtrsp =3D &rtseg[0]; - struct rt_read_seg *rtrsp1; + int readstate; + struct rt_read_seg rtseg[RCUTORTURE_RDR_MAX_SEGS]; + struct rt_read_seg *rtrsp; unsigned long long ts; +}; =20 - WARN_ON_ONCE(!rcu_is_watching()); - newstate =3D rcutorture_extend_mask(readstate, trsp); - rcutorture_one_extend(&readstate, newstate, myid < 0, trsp, rtrsp++); - if (checkpolling) { +static void init_rcu_torture_one_read_state(struct rcu_torture_one_read_st= ate *rtorsp, + struct torture_random_state *trsp) +{ + memset(rtorsp, 0, sizeof(*rtorsp)); + rtorsp->checkpolling =3D !(torture_random(trsp) & 0xfff); + rtorsp->rtrsp =3D &rtorsp->rtseg[0]; +} + +/* + * Set up the first segment of a series of overlapping read-side + * critical sections. The caller must have actually initiated the + * outermost read-side critical section. + */ +static bool rcu_torture_one_read_start(struct rcu_torture_one_read_state *= rtorsp, + struct torture_random_state *trsp, long myid) +{ + if (rtorsp->checkpolling) { if (cur_ops->get_gp_state && cur_ops->poll_gp_state) - cookie =3D cur_ops->get_gp_state(); + rtorsp->cookie =3D cur_ops->get_gp_state(); if (cur_ops->get_gp_state_full && cur_ops->poll_gp_state_full) - cur_ops->get_gp_state_full(&cookie_full); + cur_ops->get_gp_state_full(&rtorsp->cookie_full); } - started =3D cur_ops->get_gp_seq(); - ts =3D rcu_trace_clock_local(); - p =3D rcu_dereference_check(rcu_torture_current, + rtorsp->started =3D cur_ops->get_gp_seq(); + rtorsp->ts =3D rcu_trace_clock_local(); + rtorsp->p =3D rcu_dereference_check(rcu_torture_current, !cur_ops->readlock_held || cur_ops->readlock_held()); - if (p =3D=3D NULL) { + if (rtorsp->p =3D=3D NULL) { /* Wait for rcu_torture_writer to get underway */ - rcutorture_one_extend(&readstate, 0, myid < 0, trsp, rtrsp); + rcutorture_one_extend(&rtorsp->readstate, 0, myid < 0, trsp, rtorsp->rtr= sp); return false; } - if (p->rtort_mbtest =3D=3D 0) + if (rtorsp->p->rtort_mbtest =3D=3D 0) atomic_inc(&n_rcu_torture_mberror); - rcu_torture_reader_do_mbchk(myid, p, trsp); - rtrsp =3D rcutorture_loop_extend(&readstate, myid < 0, trsp, rtrsp); + rcu_torture_reader_do_mbchk(myid, rtorsp->p, trsp); + return true; +} + +/* + * Complete the last segment of a series of overlapping read-side + * critical sections and check for errors. + */ +static void rcu_torture_one_read_end(struct rcu_torture_one_read_state *rt= orsp, + struct torture_random_state *trsp, long myid) +{ + int i; + unsigned long completed; + int pipe_count; + bool preempted =3D false; + struct rt_read_seg *rtrsp1; + preempt_disable(); - pipe_count =3D READ_ONCE(p->rtort_pipe_count); + pipe_count =3D READ_ONCE(rtorsp->p->rtort_pipe_count); if (pipe_count > RCU_TORTURE_PIPE_LEN) { // Should not happen in a correct RCU implementation, // happens quite often for torture_type=3Dbusted. @@ -2218,28 +2235,28 @@ static bool rcu_torture_one_read(struct torture_ran= dom_state *trsp, long myid) } completed =3D cur_ops->get_gp_seq(); if (pipe_count > 1) { - do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu, - ts, started, completed); + do_trace_rcu_torture_read(cur_ops->name, &rtorsp->p->rtort_rcu, + rtorsp->ts, rtorsp->started, completed); rcu_ftrace_dump(DUMP_ALL); } __this_cpu_inc(rcu_torture_count[pipe_count]); - completed =3D rcutorture_seq_diff(completed, started); + completed =3D rcutorture_seq_diff(completed, rtorsp->started); if (completed > RCU_TORTURE_PIPE_LEN) { /* Should not happen, but... */ completed =3D RCU_TORTURE_PIPE_LEN; } __this_cpu_inc(rcu_torture_batch[completed]); preempt_enable(); - if (checkpolling) { + if (rtorsp->checkpolling) { if (cur_ops->get_gp_state && cur_ops->poll_gp_state) - WARN_ONCE(cur_ops->poll_gp_state(cookie), + WARN_ONCE(cur_ops->poll_gp_state(rtorsp->cookie), "%s: Cookie check 2 failed %s(%d) %lu->%lu\n", __func__, rcu_torture_writer_state_getname(), rcu_torture_writer_state, - cookie, cur_ops->get_gp_state()); + rtorsp->cookie, cur_ops->get_gp_state()); if (cur_ops->get_gp_state_full && cur_ops->poll_gp_state_full) - WARN_ONCE(cur_ops->poll_gp_state_full(&cookie_full), + WARN_ONCE(cur_ops->poll_gp_state_full(&rtorsp->cookie_full), "%s: Cookie check 6 failed %s(%d) online %*pbl\n", __func__, rcu_torture_writer_state_getname(), @@ -2248,21 +2265,42 @@ static bool rcu_torture_one_read(struct torture_ran= dom_state *trsp, long myid) } if (cur_ops->reader_blocked) preempted =3D cur_ops->reader_blocked(); - rcutorture_one_extend(&readstate, 0, myid < 0, trsp, rtrsp); - WARN_ON_ONCE(readstate); + rcutorture_one_extend(&rtorsp->readstate, 0, myid < 0, trsp, rtorsp->rtrs= p); + WARN_ON_ONCE(rtorsp->readstate); // This next splat is expected behavior if leakpointer, especially // for CONFIG_RCU_STRICT_GRACE_PERIOD=3Dy kernels. - WARN_ON_ONCE(leakpointer && READ_ONCE(p->rtort_pipe_count) > 1); + WARN_ON_ONCE(leakpointer && READ_ONCE(rtorsp->p->rtort_pipe_count) > 1); =20 /* If error or close call, record the sequence of reader protections. */ if ((pipe_count > 1 || completed > 1) && !xchg(&err_segs_recorded, 1)) { i =3D 0; - for (rtrsp1 =3D &rtseg[0]; rtrsp1 < rtrsp; rtrsp1++) + for (rtrsp1 =3D &rtorsp->rtseg[0]; rtrsp1 < rtorsp->rtrsp; rtrsp1++) err_segs[i++] =3D *rtrsp1; rt_read_nsegs =3D i; rt_read_preempted =3D preempted; } +} =20 +/* + * Do one read-side critical section, returning false if there was + * no data to read. Can be invoked both from process context and + * from a timer handler. + */ +static bool rcu_torture_one_read(struct torture_random_state *trsp, long m= yid) +{ + int newstate; + struct rcu_torture_one_read_state rtors; + + WARN_ON_ONCE(!rcu_is_watching()); + init_rcu_torture_one_read_state(&rtors, trsp); + newstate =3D rcutorture_extend_mask(rtors.readstate, trsp); + rcutorture_one_extend(&rtors.readstate, newstate, myid < 0, trsp, rtors.r= trsp++); + if (!rcu_torture_one_read_start(&rtors, trsp, myid)) { + rcutorture_one_extend(&rtors.readstate, 0, myid < 0, trsp, rtors.rtrsp); + return false; + } + rtors.rtrsp =3D rcutorture_loop_extend(&rtors.readstate, myid < 0, trsp, = rtors.rtrsp); + rcu_torture_one_read_end(&rtors, trsp, myid); return true; } =20 --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E9FEA2153CE; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=gVuL3AHXEFuo+ICL0VoqDZOYCD7LgV/LOwqmmeXWxmya0AU5i0YL8wACxknDCUjMojLKKkz+liZlAA7mYKQYTo7he+WbCdOKzLBibNx9VUj6a8DUtMU364k/j/cmn1egCeyffy9fykulyjR1WAiWVP5FBxeTUOIARmSuTS3GiZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=9sDMN4XZIcJRgoHQjxyZQce37ueUrgjbAHGywNbSEVo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H/MOD8SrMLDSgJX3A2XXCLdQ5C017xDTF4nNi1FDs9EGZiGTTtzI28ZLmb71+bRvYrdXmbeXyoBjroB0xfM+flcGG3Wflf9Irgb3zS7j3Vn4ZvKWH6MpWXkuf67dar0dtJ1qHkCvtr0qiixwOzwxb8ixzsLAp1oCdxHXBEu0XUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HAX4KNmP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HAX4KNmP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D7D9C4CEED; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=9sDMN4XZIcJRgoHQjxyZQce37ueUrgjbAHGywNbSEVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HAX4KNmPJGdPwHk2VJZZl5ykOgI4J4w8XqZu27hWQhKh0XNesjbap3l/lVej8PS96 3i6/ieNyjBTmFKhGJ/vxvcvvRuSZRN7z9nwYZHyKptC7CbzjKgob5y/R909CmNYAQq juDAEp8DZNg6i9U2Qs1UzIw8txwOfjlIdu2ku+u7N/sqnBsp8fV3g+pPHH4piNikJB CeUb4TTcb0Qv7QRdOpC/QvRnFMwLymkrEHX8TofCzKbJ4x7reyT1Nx0evrurogRaDB 6BZg4eDa99wA2HYlCm8wZdrgbydUlXt5owiAK9JrCmzyTwNA2zhRTekRKJkEyWFum/ l01v6/ZUpRolA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2BD61CE10D8; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Sebastian Andrzej Siewior Subject: [PATCH v2 04/12] rcutorture: Make torture.sh --do-rt use CONFIG_PREEMPT_RT Date: Mon, 31 Mar 2025 14:03:06 -0700 Message-Id: <20250331210314.590622-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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 torture.sh --do-rt command-line parameter is intended to mimic -rt kernels. Now that CONFIG_PREEMPT_RT is upstream, this commit makes this mimicking more precise. Note that testing of RCU priority boosting is disabled in favor of forward-progress testing of RCU callbacks. If it turns out to be possible to make kernels built with CONFIG_PREEMPT_RT=3Dy to tolerate testing of both, both will be enabled. Signed-off-by: Paul E. McKenney Cc: Sebastian Andrzej Siewior --- tools/testing/selftests/rcutorture/bin/torture.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/test= ing/selftests/rcutorture/bin/torture.sh index 0447c4a00cc4d..9cabe505585ea 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -448,13 +448,17 @@ fi =20 if test "$do_rt" =3D "yes" then + # In both runs, disable testing of RCU priority boosting because + # -rt doesn't like its interaction with testing of callback + # flooding. + # 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 + torture_bootargs=3D"rcupdate.rcu_cpu_stall_suppress_at_boot=3D1 torture.d= isable_onoff_at_boot rcupdate.rcu_task_stall_timeout=3D30000 rcutorture.tes= t_boost=3D0 rcupdate.rcu_normal=3D1" + torture_set "rcurttorture" tools/testing/selftests/rcutorture/bin/kvm.sh = --allcpus --duration "$duration_rcutorture" --configs "TREE03" --kconfig "C= ONFIG_PREEMPT_LAZY=3Dn CONFIG_PREEMPT_RT=3Dy CONFIG_EXPERT=3Dy" --trust-make =20 # 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 + torture_bootargs=3D"rcupdate.rcu_cpu_stall_suppress_at_boot=3D1 torture.d= isable_onoff_at_boot rcupdate.rcu_task_stall_timeout=3D30000 rcutorture.tes= t_boost=3D0 rcupdate.rcu_expedited=3D1" + torture_set "rcurttorture-exp" tools/testing/selftests/rcutorture/bin/kvm= .sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --kconfi= g "CONFIG_PREEMPT_LAZY=3Dn CONFIG_PREEMPT_RT=3Dy CONFIG_EXPERT=3Dy" --trust= -make fi =20 if test "$do_srcu_lockdep" =3D "yes" --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E9E861C3C08; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=T76PTk5LDuaneZI108/FF5KpCXLlP5ovAvpQI8giY5K8SGBvSvOpKms8Nlw0X8hmWnnM8XrygugJqNPB1O3aDs1JuHab9iSlQyPxNe3kCR6D2EDaYuE5QSdf0Ph283GSj14mrBBVsy7qaTYageZvaru4VlFrtphw0ACOYgowJo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=KFz74vcxOh6XuGax620Mvk5ra08FT22rTLysXGIJAdE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DX4it4QA0uJJv2K936PvOGEcnuJtwDZxeZhS7bsTQ6Tpva4gA203slQ4snZWAzDMyxqijHMb7o4SYJwWjioNfpLTvMh1nIfc8jkHls20COAoE3GZxpZ/1de1S7w2wOqVVHBEC6LqCuU/SLAzJ/k+JGJBixs2zkJTbRl0tTqXIDA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y0XVvdyD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y0XVvdyD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98C5DC4CEEF; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=KFz74vcxOh6XuGax620Mvk5ra08FT22rTLysXGIJAdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y0XVvdyD8P2O9XAG7RAmEgBgjMu+pz55JqfjQCiuCPwbyE2d1rQZQtJBcLaNDVYgh gs+KV81CYwvDmn9cFF+X0d7lT6hJI67FaaBlIQwWS8kdhuD9yr9Cp+kzU6LM8ipy6E GoInG0NLEcgdknvKkllUecDExCnk2RPX0ZwAhlJAlJ5qmmQDWOQYpHntb6aIFMVEuD uQBUKdXahTrwLvxulSW2t+vZ2eRNjhd/QBHxNG527jUgdkJtJ5MtrWX3MhQSRwu86k h/WbGDTNuAbf/9+rBl7h5Dd9y7kvh4mGNG+0tAfmhEFd8xhFl3AmP0qJcYBXZbGMcf hhklVhjDRZj/w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2ECF5CE117D; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 05/12] rcutorture: Add tests for SRCU up/down reader primitives Date: Mon, 31 Mar 2025 14:03:07 -0700 Message-Id: <20250331210314.590622-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" This commit adds a new rcutorture.n_up_down kernel boot parameter that specifies the number of outstanding SRCU up/down readers, which begin in kthread context and end in an hrtimer handler. There is a new kthread ("rcu_torture_updown") that scans an per-reader array looking for elements whose readers have ended. This kthread sleeps between one and two milliseconds between consecutive scans. [ paulmck: Apply kernel test robot feedback. ] [ paulmck: Apply Z qiang feedback. ] Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 227 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 208 insertions(+), 19 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index b0e96df636226..e7f0521c56d08 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -55,22 +55,24 @@ MODULE_DESCRIPTION("Read-Copy Update module-based tortu= re test facility"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Paul E. McKenney and Josh Triplett = "); =20 -/* Bits for ->extendables field, extendables param, and related definition= s. */ -#define RCUTORTURE_RDR_SHIFT_1 8 /* Put SRCU index in upper bits. */ -#define RCUTORTURE_RDR_MASK_1 (0xff << RCUTORTURE_RDR_SHIFT_1) -#define RCUTORTURE_RDR_SHIFT_2 16 /* Put SRCU index in upper bits. */ -#define RCUTORTURE_RDR_MASK_2 (0xff << RCUTORTURE_RDR_SHIFT_2) -#define RCUTORTURE_RDR_BH 0x01 /* Extend readers by disabling bh. */ -#define RCUTORTURE_RDR_IRQ 0x02 /* ... disabling interrupts. */ -#define RCUTORTURE_RDR_PREEMPT 0x04 /* ... disabling preemption. */ -#define RCUTORTURE_RDR_RBH 0x08 /* ... rcu_read_lock_bh(). */ -#define RCUTORTURE_RDR_SCHED 0x10 /* ... rcu_read_lock_sched(). */ -#define RCUTORTURE_RDR_RCU_1 0x20 /* ... entering another RCU reader. */ -#define RCUTORTURE_RDR_RCU_2 0x40 /* ... entering another RCU reader. */ -#define RCUTORTURE_RDR_NBITS 7 /* Number of bits defined above. */ -#define RCUTORTURE_MAX_EXTEND \ +// Bits for ->extendables field, extendables param, and related definition= s. +#define RCUTORTURE_RDR_SHIFT_1 8 // Put SRCU index in upper bits. +#define RCUTORTURE_RDR_MASK_1 (0xff << RCUTORTURE_RDR_SHIFT_1) +#define RCUTORTURE_RDR_SHIFT_2 16 // Put SRCU index in upper bits. +#define RCUTORTURE_RDR_MASK_2 (0xff << RCUTORTURE_RDR_SHIFT_2) +#define RCUTORTURE_RDR_BH 0x01 // Extend readers by disabling bh. +#define RCUTORTURE_RDR_IRQ 0x02 // ... disabling interrupts. +#define RCUTORTURE_RDR_PREEMPT 0x04 // ... disabling preemption. +#define RCUTORTURE_RDR_RBH 0x08 // ... rcu_read_lock_bh(). +#define RCUTORTURE_RDR_SCHED 0x10 // ... rcu_read_lock_sched(). +#define RCUTORTURE_RDR_RCU_1 0x20 // ... entering another RCU reader. +#define RCUTORTURE_RDR_RCU_2 0x40 // ... entering another RCU reader. +#define RCUTORTURE_RDR_UPDOWN 0x80 // ... up-read from task, down-read fr= om timer. + // Note: Manual start, automatic end. +#define RCUTORTURE_RDR_NBITS 8 // Number of bits defined above. +#define RCUTORTURE_MAX_EXTEND \ (RCUTORTURE_RDR_BH | RCUTORTURE_RDR_IRQ | RCUTORTURE_RDR_PREEMPT | \ - RCUTORTURE_RDR_RBH | RCUTORTURE_RDR_SCHED) + RCUTORTURE_RDR_RBH | RCUTORTURE_RDR_SCHED) // Intentionally omit RCUTOR= TURE_RDR_UPDOWN. #define RCUTORTURE_RDR_ALLBITS \ (RCUTORTURE_MAX_EXTEND | RCUTORTURE_RDR_RCU_1 | RCUTORTURE_RDR_RCU_2 | \ RCUTORTURE_RDR_MASK_1 | RCUTORTURE_RDR_MASK_2) @@ -110,6 +112,7 @@ torture_param(bool, gp_sync, false, "Use synchronous GP= wait primitives"); torture_param(int, irqreader, 1, "Allow RCU readers from irq handlers"); torture_param(int, leakpointer, 0, "Leak pointer dereferences from readers= "); torture_param(int, n_barrier_cbs, 0, "# of callbacks/kthreads for barrier = testing"); +torture_param(int, n_up_down, 32, "# of concurrent up/down hrtimer-based R= CU readers"); torture_param(int, nfakewriters, 4, "Number of RCU fake writer threads"); torture_param(int, nreaders, -1, "Number of RCU reader threads"); torture_param(int, object_debug, 0, "Enable debug-object double call_rcu()= testing"); @@ -152,6 +155,7 @@ static int nrealfakewriters; static struct task_struct *writer_task; static struct task_struct **fakewriter_tasks; static struct task_struct **reader_tasks; +static struct task_struct *updown_task; static struct task_struct **nocb_tasks; static struct task_struct *stats_task; static struct task_struct *fqs_task; @@ -374,6 +378,8 @@ struct rcu_torture_ops { void (*readunlock)(int idx); int (*readlock_held)(void); // lockdep. int (*readlock_nesting)(void); // actual nesting, if available, -1 if not. + int (*down_read)(void); + void (*up_read)(int idx); unsigned long (*get_gp_seq)(void); unsigned long (*gp_diff)(unsigned long new, unsigned long old); void (*deferred_free)(struct rcu_torture *p); @@ -421,6 +427,7 @@ struct rcu_torture_ops { int no_pi_lock; int debug_objects; int start_poll_irqsoff; + int have_up_down; const char *name; }; =20 @@ -754,6 +761,50 @@ static int torture_srcu_read_lock_held(void) return srcu_read_lock_held(srcu_ctlp); } =20 +static bool srcu_torture_have_up_down(void) +{ + int rf =3D reader_flavor; + + if (!rf) + rf =3D SRCU_READ_FLAVOR_NORMAL; + return !!(cur_ops->have_up_down & rf); +} + +static int srcu_torture_down_read(void) +{ + int idx; + struct srcu_ctr __percpu *scp; + + WARN_ON_ONCE(reader_flavor & ~SRCU_READ_FLAVOR_ALL); + WARN_ON_ONCE(reader_flavor & (reader_flavor - 1)); + + if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || !(reader_flavor & SRCU_R= EAD_FLAVOR_ALL)) { + idx =3D srcu_down_read(srcu_ctlp); + WARN_ON_ONCE(idx & ~0x1); + return idx; + } + if (reader_flavor & SRCU_READ_FLAVOR_FAST) { + scp =3D srcu_down_read_fast(srcu_ctlp); + idx =3D __srcu_ptr_to_ctr(srcu_ctlp, scp); + WARN_ON_ONCE(idx & ~0x1); + return idx << 3; + } + WARN_ON_ONCE(1); + return 0; +} + +static void srcu_torture_up_read(int idx) +{ + WARN_ON_ONCE((reader_flavor && (idx & ~reader_flavor)) || (!reader_flavor= && (idx & ~0x1))); + if (reader_flavor & SRCU_READ_FLAVOR_FAST) + srcu_up_read_fast(srcu_ctlp, __srcu_ctr_to_ptr(srcu_ctlp, (idx & 0x8) >>= 3)); + else if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || + !(reader_flavor & SRCU_READ_FLAVOR_ALL)) + srcu_up_read(srcu_ctlp, idx & 0x1); + else + WARN_ON_ONCE(1); +} + static unsigned long srcu_torture_completed(void) { return srcu_batches_completed(srcu_ctlp); @@ -811,6 +862,8 @@ static struct rcu_torture_ops srcu_ops =3D { .readlock =3D srcu_torture_read_lock, .read_delay =3D srcu_read_delay, .readunlock =3D srcu_torture_read_unlock, + .down_read =3D srcu_torture_down_read, + .up_read =3D srcu_torture_up_read, .readlock_held =3D torture_srcu_read_lock_held, .get_gp_seq =3D srcu_torture_completed, .gp_diff =3D rcu_seq_diff, @@ -831,6 +884,8 @@ static struct rcu_torture_ops srcu_ops =3D { .irq_capable =3D 1, .no_pi_lock =3D IS_ENABLED(CONFIG_TINY_SRCU), .debug_objects =3D 1, + .have_up_down =3D IS_ENABLED(CONFIG_TINY_SRCU) + ? 0 : SRCU_READ_FLAVOR_NORMAL | SRCU_READ_FLAVOR_FAST, .name =3D "srcu" }; =20 @@ -856,6 +911,8 @@ static struct rcu_torture_ops srcud_ops =3D { .read_delay =3D srcu_read_delay, .readunlock =3D srcu_torture_read_unlock, .readlock_held =3D torture_srcu_read_lock_held, + .down_read =3D srcu_torture_down_read, + .up_read =3D srcu_torture_up_read, .get_gp_seq =3D srcu_torture_completed, .gp_diff =3D rcu_seq_diff, .deferred_free =3D srcu_torture_deferred_free, @@ -875,6 +932,8 @@ static struct rcu_torture_ops srcud_ops =3D { .irq_capable =3D 1, .no_pi_lock =3D IS_ENABLED(CONFIG_TINY_SRCU), .debug_objects =3D 1, + .have_up_down =3D IS_ENABLED(CONFIG_TINY_SRCU) + ? 0 : SRCU_READ_FLAVOR_NORMAL | SRCU_READ_FLAVOR_FAST, .name =3D "srcud" }; =20 @@ -1985,7 +2044,7 @@ static void rcutorture_one_extend(int *readstate, int= newstate, bool insoftirq, =20 first =3D idxold1 =3D=3D 0; WARN_ON_ONCE(idxold2 < 0); - WARN_ON_ONCE(idxold2 & ~RCUTORTURE_RDR_ALLBITS); + WARN_ON_ONCE(idxold2 & ~(RCUTORTURE_RDR_ALLBITS | RCUTORTURE_RDR_UPDOWN)); rcutorture_one_extend_check("before change", idxold1, statesnew, statesol= d, insoftirq); rtrsp->rt_readstate =3D newstate; =20 @@ -2061,6 +2120,11 @@ static void rcutorture_one_extend(int *readstate, in= t newstate, bool insoftirq, if (lockit) raw_spin_unlock_irqrestore(¤t->pi_lock, flags); } + if (statesold & RCUTORTURE_RDR_UPDOWN) { + cur_ops->up_read((idxold1 & RCUTORTURE_RDR_MASK_1) >> RCUTORTURE_RDR_SHI= FT_1); + WARN_ON_ONCE(idxnew1 !=3D -1); + idxold1 =3D 0; + } =20 /* Delay if neither beginning nor end and there was a change. */ if ((statesnew || statesold) && *readstate && newstate) @@ -2201,7 +2265,8 @@ static bool rcu_torture_one_read_start(struct rcu_tor= ture_one_read_state *rtorsp rtorsp->started =3D cur_ops->get_gp_seq(); rtorsp->ts =3D rcu_trace_clock_local(); rtorsp->p =3D rcu_dereference_check(rcu_torture_current, - !cur_ops->readlock_held || cur_ops->readlock_held()); + !cur_ops->readlock_held || cur_ops->readlock_held() || + (rtorsp->readstate & RCUTORTURE_RDR_UPDOWN)); if (rtorsp->p =3D=3D NULL) { /* Wait for rcu_torture_writer to get underway */ rcutorture_one_extend(&rtorsp->readstate, 0, myid < 0, trsp, rtorsp->rtr= sp); @@ -2370,6 +2435,123 @@ rcu_torture_reader(void *arg) return 0; } =20 +struct rcu_torture_one_read_state_updown { + struct hrtimer rtorsu_hrt; + bool rtorsu_inuse; + struct torture_random_state rtorsu_trs; + struct rcu_torture_one_read_state rtorsu_rtors; +}; + +static struct rcu_torture_one_read_state_updown *updownreaders; +static DEFINE_TORTURE_RANDOM(rcu_torture_updown_rand); +static int rcu_torture_updown(void *arg); + +static enum hrtimer_restart rcu_torture_updown_hrt(struct hrtimer *hrtp) +{ + struct rcu_torture_one_read_state_updown *rtorsup; + + rtorsup =3D container_of(hrtp, struct rcu_torture_one_read_state_updown, = rtorsu_hrt); + rcu_torture_one_read_end(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_trs, -1= ); + smp_store_release(&rtorsup->rtorsu_inuse, false); + return HRTIMER_NORESTART; +} + +static int rcu_torture_updown_init(void) +{ + int i; + struct torture_random_state *rand =3D &rcu_torture_updown_rand; + int ret; + + if (n_up_down < 0) + return 0; + if (!srcu_torture_have_up_down()) { + VERBOSE_TOROUT_STRING("rcu_torture_updown_init: Disabling up/down reader= tests due to lack of primitives"); + return 0; + } + updownreaders =3D kcalloc(n_up_down, sizeof(*updownreaders), GFP_KERNEL); + if (!updownreaders) { + VERBOSE_TOROUT_STRING("rcu_torture_updown_init: Out of memory, disabling= up/down reader tests"); + return -ENOMEM; + } + for (i =3D 0; i < n_up_down; i++) { + init_rcu_torture_one_read_state(&updownreaders[i].rtorsu_rtors, rand); + hrtimer_init(&updownreaders[i].rtorsu_hrt, CLOCK_MONOTONIC, + HRTIMER_MODE_REL | HRTIMER_MODE_SOFT); + updownreaders[i].rtorsu_hrt.function =3D rcu_torture_updown_hrt; + torture_random_init(&updownreaders[i].rtorsu_trs); + init_rcu_torture_one_read_state(&updownreaders[i].rtorsu_rtors, + &updownreaders[i].rtorsu_trs); + } + ret =3D torture_create_kthread(rcu_torture_updown, rand, updown_task); + if (ret) { + kfree(updownreaders); + updownreaders =3D NULL; + } + return ret; +} + +static void rcu_torture_updown_cleanup(void) +{ + struct rcu_torture_one_read_state_updown *rtorsup; + + for (rtorsup =3D updownreaders; rtorsup < &updownreaders[n_up_down]; rtor= sup++) { + if (!smp_load_acquire(&rtorsup->rtorsu_inuse)) + continue; + if (!hrtimer_cancel(&rtorsup->rtorsu_hrt)) + WARN_ON_ONCE(rtorsup->rtorsu_inuse); + + } + kfree(updownreaders); + updownreaders =3D NULL; +} + +/* + * RCU torture up/down reader kthread, starting RCU readers in kthread + * context and ending them in hrtimer handlers. Otherwise similar to + * rcu_torture_reader(). + */ +static int +rcu_torture_updown(void *arg) +{ + int idx; + int rawidx; + struct rcu_torture_one_read_state_updown *rtorsup; + ktime_t t; + + VERBOSE_TOROUT_STRING("rcu_torture_updown task started"); + do { + for (rtorsup =3D updownreaders; rtorsup < &updownreaders[n_up_down]; rto= rsup++) { + if (torture_must_stop()) + break; + if (smp_load_acquire(&rtorsup->rtorsu_inuse)) + continue; + init_rcu_torture_one_read_state(&rtorsup->rtorsu_rtors, + &rtorsup->rtorsu_trs); + rawidx =3D cur_ops->down_read(); + idx =3D (rawidx << RCUTORTURE_RDR_SHIFT_1) & RCUTORTURE_RDR_MASK_1; + rtorsup->rtorsu_rtors.readstate =3D idx | RCUTORTURE_RDR_UPDOWN; + rtorsup->rtorsu_rtors.rtrsp++; + if (!rcu_torture_one_read_start(&rtorsup->rtorsu_rtors, + &rtorsup->rtorsu_trs, -1)) { + cur_ops->up_read(rawidx); + schedule_timeout_idle(HZ); + continue; + } + smp_store_release(&rtorsup->rtorsu_inuse, true); + t =3D torture_random(&rtorsup->rtorsu_trs) & 0xfffff; // One per millio= n. + if (t < 10 * 1000) + t =3D 200 * 1000 * 1000; + hrtimer_start(&rtorsup->rtorsu_hrt, t, + HRTIMER_MODE_REL | HRTIMER_MODE_SOFT); + } + torture_hrtimeout_ms(1, 1000, &rcu_torture_updown_rand); + stutter_wait("rcu_torture_updown"); + } while (!torture_must_stop()); + rcu_torture_updown_cleanup(); + torture_kthread_stopping("rcu_torture_updown"); + return 0; +} + /* * Randomly Toggle CPUs' callback-offload state. This uses hrtimers to * increase race probabilities and fuzzes the interval between toggling. @@ -2620,7 +2802,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops= *cur_ops, const char *tag) "reader_flavor=3D%x " "nocbs_nthreads=3D%d nocbs_toggle=3D%d " "test_nmis=3D%d " - "preempt_duration=3D%d preempt_interval=3D%d\n", + "preempt_duration=3D%d preempt_interval=3D%d n_up_down=3D%d\n", torture_type, tag, nrealreaders, nrealfakewriters, stat_interval, verbose, test_no_idle_hz, shuffle_interval, stutter, irqreader, fqs_duration, fqs_holdoff, fqs_stutter, @@ -2634,7 +2816,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops= *cur_ops, const char *tag) reader_flavor, nocbs_nthreads, nocbs_toggle, test_nmis, - preempt_duration, preempt_interval); + preempt_duration, preempt_interval, n_up_down); } =20 static int rcutorture_booster_cleanup(unsigned int cpu) @@ -3686,6 +3868,10 @@ rcu_torture_cleanup(void) nocb_tasks =3D NULL; } =20 + if (updown_task) { + torture_stop_kthread(rcu_torture_updown, updown_task); + updown_task =3D NULL; + } if (reader_tasks) { for (i =3D 0; i < nrealreaders; i++) torture_stop_kthread(rcu_torture_reader, @@ -4216,6 +4402,9 @@ rcu_torture_init(void) if (torture_init_error(firsterr)) goto unwind; } + firsterr =3D rcu_torture_updown_init(); + if (torture_init_error(firsterr)) + goto unwind; nrealnocbers =3D nocbs_nthreads; if (WARN_ON(nrealnocbers < 0)) nrealnocbers =3D 1; --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C2FF21C9E1; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=WOv50rt25k9KvgGPcHxcE/2Z7wi/vL2uBvVPZIkB2iuvz07//2MCN1662Of2naOpTZJIWG2Vp8q7TfNGvOxPxkbbVCHKXgn6k1tUStBcrhMLwXfcLI7J1dEvPXJ/hm1hiavIP6rIygyYzewTxBd/aqfPTx/DheJy7CvzftFDi0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=1zu+tiXtv9EHc5tmGSDi0qMNWo1wCGu6vx+Yk4qI7Lg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GXXhbHl+Jrudl+4rxYz3192cSazRRDOCxNKwOgEbGN+TiC8mjv7wsN+WAK/woTNLLZ+O1ALcDpNbyWs9zXULymtt87u6Xq0aH1ISqHKPbJySs0cCLFfU/h0VjECqtluyPxokoFtG9vzHUWRyBYB4Ejeju4AVOQ7WntnoxkTvnYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qeb1Pgqt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qeb1Pgqt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C831DC4CEF2; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=1zu+tiXtv9EHc5tmGSDi0qMNWo1wCGu6vx+Yk4qI7Lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qeb1PgqtgYDJnKofypo6RoakDGGU01cieJkh2ZB8Oy1EsawhGSb4RtcUAQE3KlF/i azwhWgIaewmGVOJAN3zHeJgpyW/Z90oH1VFbpj13dRmPFexCOO9CFzPX7lM4SmoVz+ lbVu+w0fN2IuK/ig9Q3ZDRS3/Hhf9IsVj+bK5B0zzXtBnZE7iU6bKF9tWq3OBu2of/ 6M4QO0jjJ7aCL57/DjoXvu6AJmTdIFOPeT1ukYICifvoJJGTlF111ORLRBlJwh553Z ty33igFClrr2TLeUzlCCoZQgRnFA5JOPnQiSIDRLtIPNOu0y9/Qb6CSN5/2UXCNbu7 z1jq9EYl9eb1Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3125ECE11EE; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 06/12] rcutorture: Pull rcu_torture_updown() loop body into new function Date: Mon, 31 Mar 2025 14:03:08 -0700 Message-Id: <20250331210314.590622-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" This is strictly a code-movement commit, pulling that part of the rcu_torture_updown() function's loop body that processes one rcu_torture_one_read_state_updown structure into a new rcu_torture_updown_one() function. The checks for the end of the torture test and the current structure being in use remain in the rcu_torture_updown() function. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 46 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index e7f0521c56d08..7eccc74e60a7f 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2505,6 +2505,30 @@ static void rcu_torture_updown_cleanup(void) updownreaders =3D NULL; } =20 +// Do one reader for rcu_torture_updown(). +static void rcu_torture_updown_one(struct rcu_torture_one_read_state_updow= n *rtorsup) +{ + int idx; + int rawidx; + ktime_t t; + + init_rcu_torture_one_read_state(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_= trs); + rawidx =3D cur_ops->down_read(); + idx =3D (rawidx << RCUTORTURE_RDR_SHIFT_1) & RCUTORTURE_RDR_MASK_1; + rtorsup->rtorsu_rtors.readstate =3D idx | RCUTORTURE_RDR_UPDOWN; + rtorsup->rtorsu_rtors.rtrsp++; + if (!rcu_torture_one_read_start(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_= trs, -1)) { + cur_ops->up_read(rawidx); + schedule_timeout_idle(HZ); + return; + } + smp_store_release(&rtorsup->rtorsu_inuse, true); + t =3D torture_random(&rtorsup->rtorsu_trs) & 0xfffff; // One per million. + if (t < 10 * 1000) + t =3D 200 * 1000 * 1000; + hrtimer_start(&rtorsup->rtorsu_hrt, t, HRTIMER_MODE_REL | HRTIMER_MODE_SO= FT); +} + /* * RCU torture up/down reader kthread, starting RCU readers in kthread * context and ending them in hrtimer handlers. Otherwise similar to @@ -2513,10 +2537,7 @@ static void rcu_torture_updown_cleanup(void) static int rcu_torture_updown(void *arg) { - int idx; - int rawidx; struct rcu_torture_one_read_state_updown *rtorsup; - ktime_t t; =20 VERBOSE_TOROUT_STRING("rcu_torture_updown task started"); do { @@ -2525,24 +2546,7 @@ rcu_torture_updown(void *arg) break; if (smp_load_acquire(&rtorsup->rtorsu_inuse)) continue; - init_rcu_torture_one_read_state(&rtorsup->rtorsu_rtors, - &rtorsup->rtorsu_trs); - rawidx =3D cur_ops->down_read(); - idx =3D (rawidx << RCUTORTURE_RDR_SHIFT_1) & RCUTORTURE_RDR_MASK_1; - rtorsup->rtorsu_rtors.readstate =3D idx | RCUTORTURE_RDR_UPDOWN; - rtorsup->rtorsu_rtors.rtrsp++; - if (!rcu_torture_one_read_start(&rtorsup->rtorsu_rtors, - &rtorsup->rtorsu_trs, -1)) { - cur_ops->up_read(rawidx); - schedule_timeout_idle(HZ); - continue; - } - smp_store_release(&rtorsup->rtorsu_inuse, true); - t =3D torture_random(&rtorsup->rtorsu_trs) & 0xfffff; // One per millio= n. - if (t < 10 * 1000) - t =3D 200 * 1000 * 1000; - hrtimer_start(&rtorsup->rtorsu_hrt, t, - HRTIMER_MODE_REL | HRTIMER_MODE_SOFT); + rcu_torture_updown_one(rtorsup); } torture_hrtimeout_ms(1, 1000, &rcu_torture_updown_rand); stutter_wait("rcu_torture_updown"); --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 230BA21B9FC; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=OCp6EDwQVkML5PI+ag+PDiJyJsDGHAbctq3fRQNCjovqarfy23MkZ0jBtdEDcm3rtGMhSWVJ/oGh55OLrPaSj/5WWnlXR6Pd6V3zfx4fwbopf2dAgIMGG8gpG8WIKVxoYmkoQSwcqfv35G3CjzSdmUom2IPJOXKrHmWX0TnBX3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=95yGZppaZZxoJNnNv8N0HfRV+XlPNqEDRvJVFtromRk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SxRjtwNjsgM44MI4Lb0JWdPJj2L7gvwKAWzXsAGsM8aGH0hxIoMBc3jkbnUPss9sitGuqG9AXAqgpmMT7A3kpfSC4VMWpDcJVC39P3hmZbO/X7i8MDM+9JMA1Ykm7J7GbOdMEOMBxGwAIp0Flc3H9lVZzP0O4vPfHlnBDgX3Aiw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CRea347K; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CRea347K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C933EC4CEF3; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=95yGZppaZZxoJNnNv8N0HfRV+XlPNqEDRvJVFtromRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CRea347KjhdlzVfvJEH/NfNFmqmypO9mjv04ULyxp16D/aiF7o4KlYzrWay6hNJdZ jpdbRR1AtDFj2qqwRovT6wSW31XsJMGepmtkfid5UH8MiKx3zUN5nsgUnJNkZmJI9G bzH47j/Nz2fygb6yfpCoG0UyT2j7ICKW2//EZ/E9l0Yk4iBcZ7hsLzWH/zVv0zKPoL CslapDzVz4v5jvRUBsWV7rEkjqIJ9X2hSkx13451GmEzaXOF+4gJ6N4r8A1ZU671mz vbzho6kqCznqC5ueMrrtJUJTib7cnw22VmzgMMnbwm2scvalaTiB13/UXX6U8srzzU eB0twgqBHIoWg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 33F59CE12A6; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 07/12] rcutorture: Comment invocations of tick_dep_set_task() Date: Mon, 31 Mar 2025 14:03:09 -0700 Message-Id: <20250331210314.590622-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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 rcu_torture_reader() and rcu_torture_fwd_prog_cr() functions run CPU-bound for extended periods of time (tens or even hundreds of milliseconds), so they invoke tick_dep_set_task() and tick_dep_clear_task() to ensure that the scheduling-clock tick helps move grace periods forward. So why doesn't rcu_torture_fwd_prog_nr() also invoke tick_dep_set_task() and tick_dep_clear_task()? Because the point of this function is to test RCU's ability to (eventually) force grace periods forward even when the tick has been disabled during long CPU-bound kernel execution. 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 7eccc74e60a7f..ea40f3ad32dc2 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2410,7 +2410,7 @@ rcu_torture_reader(void *arg) set_user_nice(current, MAX_NICE); if (irqreader && cur_ops->irq_capable) timer_setup_on_stack(&t, rcu_torture_timer, 0); - tick_dep_set_task(current, TICK_DEP_BIT_RCU); + tick_dep_set_task(current, TICK_DEP_BIT_RCU); // CPU bound, so need tick. do { if (irqreader && cur_ops->irq_capable) { if (!timer_pending(&t)) @@ -3260,7 +3260,7 @@ static void rcu_torture_fwd_prog_cr(struct rcu_fwd *r= fp) cver =3D READ_ONCE(rcu_torture_current_version); gps =3D cur_ops->get_gp_seq(); rfp->rcu_launder_gp_seq_start =3D gps; - tick_dep_set_task(current, TICK_DEP_BIT_RCU); + tick_dep_set_task(current, TICK_DEP_BIT_RCU); // CPU bound, so need tick. while (time_before(jiffies, stopat) && !shutdown_time_arrived() && !READ_ONCE(rcu_fwd_emergency_stop) && !torture_must_stop()) { --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C2A521C9E0; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=lr+0nvSlcQAmqMMHfkqFuiaE5ccbc3CjCteasoXEc5698FLFlFCvfwW1o+nmg5Sew6cxF4Av1sbruljmuMK645msHohzikkRknh0PJD69czXYvX4D5vEToKXjsGV9IDkgl2cJQlBBzHO/rjrl0jpSTduT7OwdNNGKqRjd6hLkww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=zAxLHrj5ynpEb7swglRSR0yWaTaNYTdq/FpancJFEO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=maFAIP7BUNMligJ46BgvWhUcubTgEZJMRSzjNP4HMrT7mApfhcC9If7HZfiRIoBgh1admk5mye4J8we5NrDuHDrACc+TqKwMSt6xsnqW7WnHAs6M0bmOeYl/iWOWbi0w5V1w2cYJJjFOm3EPhG2ym7h8ZqQ2e1/hABCfJ6D7BCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q0lS0Kw8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q0lS0Kw8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D63C3C4CEF4; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=zAxLHrj5ynpEb7swglRSR0yWaTaNYTdq/FpancJFEO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q0lS0Kw8hYcJamCQawQXyarCiLNmu+tBQKRSQ+aVO5Kml6jRfmIniSuawnIi6n+N6 81kVSJKtm3VS8lvkhTOqa+BstEpC0UY4ZQ3kTriYxslpq9I2rF9hKN/CJiHMpTAH2x n1nCdTmbxGMDZO7Vxsa+JSGu+YAyoUyHuYoxj26anxkmwQlh9aOhyWOst6xfkYosbJ et038JDBLe5BYkdbxp8w8Y9ZX8jbyddy11hoMf2SL95HjDEUPxGPBTu4QAejAhtuef lxdvEBuvijj/HH3Y+1ZCEirbDJRmqwHNLD0w59oi07eFGtKzO6qcl6yg1V7jBTnW8W 09cunOc3bWuAQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 36562CE130F; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 08/12] rcutorture: Complain if an ->up_read() is delayed more than 10 seconds Date: Mon, 31 Mar 2025 14:03:10 -0700 Message-Id: <20250331210314.590622-8-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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 down/up SRCU reader testing uses an hrtimer handler to exit the SRCU read-side critical section. This might be delayed, and if delayed for too long, it can prevent the rcutorture run from completing. This commit therefore complains if the hrtimer handler is delayed for more than ten seconds. Signed-off-by: Paul E. McKenney --- kernel/rcu/rcutorture.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index ea40f3ad32dc2..d2728e95a69b1 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2438,6 +2438,7 @@ rcu_torture_reader(void *arg) struct rcu_torture_one_read_state_updown { struct hrtimer rtorsu_hrt; bool rtorsu_inuse; + unsigned long rtorsu_j; struct torture_random_state rtorsu_trs; struct rcu_torture_one_read_state rtorsu_rtors; }; @@ -2522,6 +2523,7 @@ static void rcu_torture_updown_one(struct rcu_torture= _one_read_state_updown *rto schedule_timeout_idle(HZ); return; } + rtorsup->rtorsu_j =3D jiffies; smp_store_release(&rtorsup->rtorsu_inuse, true); t =3D torture_random(&rtorsup->rtorsu_trs) & 0xfffff; // One per million. if (t < 10 * 1000) @@ -2544,8 +2546,10 @@ rcu_torture_updown(void *arg) for (rtorsup =3D updownreaders; rtorsup < &updownreaders[n_up_down]; rto= rsup++) { if (torture_must_stop()) break; - if (smp_load_acquire(&rtorsup->rtorsu_inuse)) + if (smp_load_acquire(&rtorsup->rtorsu_inuse)) { + WARN_ON_ONCE(time_after(jiffies, rtorsup->rtorsu_j + 10 * HZ)); continue; + } rcu_torture_updown_one(rtorsup); } torture_hrtimeout_ms(1, 1000, &rcu_torture_updown_rand); --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2301B21B9E3; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=jqbVas16FwIisvWjMapbCymR7keWbJn9tSpMaeWvrl+s4k4fzCxto1psxoNZpML40cypc3EVA9wrSIIxHc7a54ZvD+JiRij9lTb11enem5D/YLdOy9LDSDxszraw9xlb98nJYNJ7MDUNaM5v4rxKMom0DAtIl/npp2BgN1QRJo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=gTAZic+ReLagLKWgSKVMUdp+ApS8LL65gzQ81QuWoXQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bfpMryg8jSXp/4PtW10uxLNAf3sF/7dRJwpA7Wv9HgSOz0YtjhB2Cv/8A+VT0ZcdErtz5W3xyOCK9K4wlxVwOjgZZRdQrebK2CFz7UYDUaOwCKEX/V8/EWn2CqyS0iQ9Wv/tjeEsV1H5waBLi5VkQz4metXM2iuVPqWsJO6k88I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oe/Mi4ST; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oe/Mi4ST" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E265CC4CEEB; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=gTAZic+ReLagLKWgSKVMUdp+ApS8LL65gzQ81QuWoXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oe/Mi4STr6zlGzc12tva8g859DU2hH75JR2FS6nI+p2xSox3/n0P9CLGEfQtBuv8Z 8v7Ys/1/htvRnrD8l9jsKWtMYT8+ua4PhBCU7e0lhmO0vTaWbnbi1zwbabjjmweBj6 z1Q/xjH+KFSI7hpE/DktXoM5DPCn+p8sEjzHihTtciQ18nzzIk7dKyHbwT6sKkXLHj ErBZvZBpXqgRP0XecEkrdvpl84sHGna79Hx2q8eoHxbC0PyZZSMUYyIHVzlkzHfZoh FpUdTrhdav17o8pi9B7NEUYVn9TOzhHeF24hK1gM5JW3ivt3zm80VvRaZmU9/jclmJ 4LGCg1AcHwdRA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 390A4CE1311; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , kernel test robot Subject: [PATCH v2 09/12] rcutorture: Check for ->up_read() without matching ->down_read() Date: Mon, 31 Mar 2025 14:03:11 -0700 Message-Id: <20250331210314.590622-9-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" This commit creates counters in the rcu_torture_one_read_state_updown structure that check for a call to ->up_read() that lacks a matching call to ->down_read(). While in the area, add end-of-run cleanup code that prevents calls to rcu_torture_updown_hrt() from happening after the test has moved on. Yes, the srcu_barrier() at the end of the test will wait for them, but this could result in confusing states, statistics, and diagnostic information. So explicitly wait for them before we get to the end-of-test output. [ paulmck: Apply kernel test robot feedback. ] Signed-off-by: Paul E. McKenney Tested-by: kernel test robot --- kernel/rcu/rcutorture.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index d2728e95a69b1..079e164c85a16 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2439,6 +2439,8 @@ struct rcu_torture_one_read_state_updown { struct hrtimer rtorsu_hrt; bool rtorsu_inuse; unsigned long rtorsu_j; + unsigned long rtorsu_ndowns; + unsigned long rtorsu_nups; struct torture_random_state rtorsu_trs; struct rcu_torture_one_read_state rtorsu_rtors; }; @@ -2453,6 +2455,8 @@ static enum hrtimer_restart rcu_torture_updown_hrt(st= ruct hrtimer *hrtp) =20 rtorsup =3D container_of(hrtp, struct rcu_torture_one_read_state_updown, = rtorsu_hrt); rcu_torture_one_read_end(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_trs, -1= ); + WARN_ONCE(rtorsup->rtorsu_nups >=3D rtorsup->rtorsu_ndowns, "%s: Up witho= ut matching down #%zu.\n", __func__, rtorsup - updownreaders); + rtorsup->rtorsu_nups++; smp_store_release(&rtorsup->rtorsu_inuse, false); return HRTIMER_NORESTART; } @@ -2498,8 +2502,12 @@ static void rcu_torture_updown_cleanup(void) for (rtorsup =3D updownreaders; rtorsup < &updownreaders[n_up_down]; rtor= sup++) { if (!smp_load_acquire(&rtorsup->rtorsu_inuse)) continue; - if (!hrtimer_cancel(&rtorsup->rtorsu_hrt)) - WARN_ON_ONCE(rtorsup->rtorsu_inuse); + if (hrtimer_cancel(&rtorsup->rtorsu_hrt) || WARN_ON_ONCE(rtorsup->rtorsu= _inuse)) { + rcu_torture_one_read_end(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_trs, = -1); + WARN_ONCE(rtorsup->rtorsu_nups >=3D rtorsup->rtorsu_ndowns, "%s: Up wit= hout matching down #%zu.\n", __func__, rtorsup - updownreaders); + rtorsup->rtorsu_nups++; + smp_store_release(&rtorsup->rtorsu_inuse, false); + } =20 } kfree(updownreaders); @@ -2515,11 +2523,14 @@ static void rcu_torture_updown_one(struct rcu_tortu= re_one_read_state_updown *rto =20 init_rcu_torture_one_read_state(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_= trs); rawidx =3D cur_ops->down_read(); + rtorsup->rtorsu_ndowns++; idx =3D (rawidx << RCUTORTURE_RDR_SHIFT_1) & RCUTORTURE_RDR_MASK_1; rtorsup->rtorsu_rtors.readstate =3D idx | RCUTORTURE_RDR_UPDOWN; rtorsup->rtorsu_rtors.rtrsp++; if (!rcu_torture_one_read_start(&rtorsup->rtorsu_rtors, &rtorsup->rtorsu_= trs, -1)) { cur_ops->up_read(rawidx); + rtorsup->rtorsu_nups++; + WARN_ONCE(rtorsup->rtorsu_nups >=3D rtorsup->rtorsu_ndowns, "%s: Up with= out matching down #%zu.\n", __func__, rtorsup - updownreaders); schedule_timeout_idle(HZ); return; } --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C23621C19F; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=MZnYOvg24xFRXbKqwg0xE5VX8MvFZIAG4iy0iKn4pC4Ze7TgGtjzHzbzkgQhLMOuNetpaf1yuGCjas+Uinpc7J9quP5B04e+CTPL6AfyMiBqQdptm2NObui4vEX8AC1JAqQOYMNJrL/5pJ2gAXfq68pCWc3mbT5HJ7VIEuTPzdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=8uZuS6tsNAX55iuq0PN/d5fRZHlLZUjcbgoA89CQHKk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PrKM2tM1bpV74izFbwQVlOPy9n4nRTU8F/0myCesEUU1DMWWrUPr4rkS+gkhmM7Gt/kk6NODkVjfBl1wP2AeUz2sFcWeHq7aIhAwsYsdZMtk4PainfG4i2Q46BSqwlKM7eqapdSlw88gTd5c2OokqYbEsTDVBIT1o6krUxAgdag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e9cMM6ds; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e9cMM6ds" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3823C4CEF5; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454995; bh=8uZuS6tsNAX55iuq0PN/d5fRZHlLZUjcbgoA89CQHKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e9cMM6dsQA+Q0zWXNZAWnwD/moIcd6Z14QmtwiqqWK5ncFJUSSoRAvkABMrDcRbQO kQURli3dFuuawAnJND/FSiDxMbKIBHqZXWtlz/lVMX1rxApgE89YVbA+xR6hsHHUaR AdjiPZw1IVMNHHfPZMlPW5y/Dt+7vARI6bl+sJL3mcPgEfNYYR/rwusSTys0m65gTV qUXu9EkXXEIdm+Lre1iDbaDS6JGD1Nk9q3nJPJnDwc2iqcrLwIR64GpQKjazNpsEEm W+bCXmktK8qCtCdy1AxjUQlR1yX3L1q6Vvzt7P8rh4lfx5FPepDQDIjYhH9lS8z334 9xGj34mc8fjCw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3B6EFCE1312; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 10/12] checkpatch: Deprecate srcu_read_lock_lite() and srcu_read_unlock_lite() Date: Mon, 31 Mar 2025 14:03:12 -0700 Message-Id: <20250331210314.590622-10-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" Uses of srcu_read_lock_lite() and srcu_read_unlock_lite() are better served by the new srcu_read_lock_fast() and srcu_read_unlock_fast() APIs. As in srcu_read_lock_lite() and srcu_read_unlock_lite() would never have happened had I thought a bit harder a few months ago. Therefore, mark them deprecated. Signed-off-by: Paul E. McKenney --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7b28ad3317427..de8ed5efc5b16 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -838,6 +838,8 @@ our %deprecated_apis =3D ( "kunmap" =3D> "kunmap_local", "kmap_atomic" =3D> "kmap_local_page", "kunmap_atomic" =3D> "kunmap_local", + "srcu_read_lock_lite" =3D> "srcu_read_lock_fast", + "srcu_read_unlock_lite" =3D> "srcu_read_unlock_fast", ); =20 #Create a search pattern for all these strings to speed up a loop below --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2FF8F21C179; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=Y/fsasU6NWpd1GxKFoUihagChCfVKOyb8IjskcaWhVKsDCTgmwr3ygDjzylL1YbMZZHVUxM461T7NFez24RLom2sy8f6bHfxdJXhrlqMMmwFFHk81j8Y125atolnhXDPdyiD+fSZqWV/mWD1+T4hvlQYoqDIDE83k7lLT+R/V38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=j8gNiTe021vKXl/HqR9kVLbh4GpEoFmmH1JdHrOrQgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kwPjhbapWsztNldBiULTDwb+/LL0/y+dweENCJnk7tp9/xwSwcGAq7vyGzmAGx1BkIufSigoLceutYkAWGFdfDU1Ez8uB3wTixJEHqrbfPJDfeXU4pZRFq7ojef9TMMAAkM8ouLOE44ouyzq7GMTc2kWqy8CEMQyx8vP/UTPdfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mNop9wgd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mNop9wgd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEFC3C4CEFA; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454996; bh=j8gNiTe021vKXl/HqR9kVLbh4GpEoFmmH1JdHrOrQgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNop9wgd5JHvLkW3FO+PZk5MQmmoANAKsSUKzaRx4sgRBAdJSVXqYQTopwmpGuQz4 j6IFU46vHjmnc1lofPodiZNt30hnMXOEqEO4uSnwB5uxiZjqgbO62JJ8bUTrwYKvhL s5hLYpvOO9eUvOLG48Douvgb+t4LnTDjBh5CdXdklT/sZwjrufFSQXwF56/kQUuXw3 o9EqrdG6EOThza+6PNpdBpc72yL3zxRdVLdFw6tfCtzj4/RLxkeBepo/um9oHe7x+8 iNZFYmEq9I2YmIpYXfOawZRUlJqGgOOKbwk3TnY7uvBkezMuWYvwX60cVCWPQns+S0 +g7dcD4O17hMQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 3DD8BCE13B4; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH v2 11/12] torture: Add --do-{,no-}normal to torture.sh Date: Mon, 31 Mar 2025 14:03:13 -0700 Message-Id: <20250331210314.590622-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" Right now, torture.sh runs normal runs unconditionally, which can be slow and thus annoying when you only want to test --kcsan or --kasan runs. This commit therefore adds a --do-normal argument so that "--kcsan --do-no-kasan --do-no-normal" runs only KCSAN runs. Note that specifying "--do-no-kasan --do-no-kcsan --do-no-normal" gets normal runs, so you should not try to use this as a synonym for --do-none. Signed-off-by: Paul E. McKenney --- .../selftests/rcutorture/bin/torture.sh | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/test= ing/selftests/rcutorture/bin/torture.sh index 9cabe505585ea..751ce770e5462 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -51,6 +51,8 @@ do_scftorture=3Dyes do_rcuscale=3Dyes do_refscale=3Dyes do_kvfree=3Dyes +do_normal=3Dyes +explicit_normal=3Dno do_kasan=3Dyes do_kcsan=3Dno do_clocksourcewd=3Dyes @@ -128,6 +130,8 @@ do do_refscale=3Dyes do_rt=3Dyes do_kvfree=3Dyes + do_normal=3Dyes + explicit_normal=3Dno do_kasan=3Dyes do_kcsan=3Dyes do_clocksourcewd=3Dyes @@ -161,11 +165,17 @@ do do_refscale=3Dno do_rt=3Dno do_kvfree=3Dno + do_normal=3Dno + explicit_normal=3Dno do_kasan=3Dno do_kcsan=3Dno do_clocksourcewd=3Dno do_srcu_lockdep=3Dno ;; + --do-normal|--do-no-normal|--no-normal) + do_normal=3D`doyesno "$1" --do-normal` + explicit_normal=3Dyes + ;; --do-rcuscale|--do-no-rcuscale|--no-rcuscale) do_rcuscale=3D`doyesno "$1" --do-rcuscale` ;; @@ -242,6 +252,17 @@ trap 'rm -rf $T' 0 2 echo " --- " $scriptname $args | tee -a $T/log echo " --- Results directory: " $ds | tee -a $T/log =20 +if test "$do_normal" =3D "no" && test "$do_kasan" =3D "no" && test "$do_kc= san" =3D "no" +then + # Match old scripts so that "--do-none --do-rcutorture" does + # normal rcutorture testing, but no KASAN or KCSAN testing. + if test $explicit_normal =3D yes + then + echo " --- Everything disabled, so explicit --do-normal overridden" | te= e -a $T/log + fi + do_normal=3Dyes +fi + # Calculate rcutorture defaults and apportion time if test -z "$configs_rcutorture" then @@ -332,9 +353,12 @@ function torture_set { local kcsan_kmake_tag=3D local flavor=3D$1 shift - curflavor=3D$flavor - torture_one "$@" - mv $T/last-resdir $T/last-resdir-nodebug || : + if test "$do_normal" =3D "yes" + then + curflavor=3D$flavor + torture_one "$@" + mv $T/last-resdir $T/last-resdir-nodebug || : + fi if test "$do_kasan" =3D "yes" then curflavor=3D${flavor}-kasan --=20 2.40.1 From nobody Fri Dec 19 21:36:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 22FC021B9DF; Mon, 31 Mar 2025 21:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; cv=none; b=lgFuBHn+h/h0I8jOn+FPas/Q0fl+zRhDAhAyQHSVnt6NGGlgimXs/+sdfrY10gI0lSGjxeHGoHfD+N3mmGwBl4tkC/mQTqH33XnsuEOAzfYpjOnLVnclFKgr2sihYbUaOg41I59MiFAPytm0Qh4YHx2RxQk1A6BhhwFlqZ2SegA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743454996; c=relaxed/simple; bh=JcZBJabSTeR6VVDLh2M4X/uJWHu8jyYG489yVTC87Es=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fVNrcLBOFtBvHIj8HdUHiYr2TpBZyccyUKKNj8Y04w14yMOyB+LRBLd17LVuifu0YE1oL3UqG6alrBDsuu5cvjFgAxLClD5zDPjFzlFNei0ww1jly4UNnO0OLxLGXDcNk+pISRwjxrQrnpd03Vd2Cj6MvTS5YxW1zomvBWY9Thg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cAWpBFaz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cAWpBFaz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECC82C4CEF6; Mon, 31 Mar 2025 21:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743454996; bh=JcZBJabSTeR6VVDLh2M4X/uJWHu8jyYG489yVTC87Es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAWpBFazJ48gfsXr3Y1ES97nMJjvbDPTRsQTPV6OimREWecQUjGxYe5tM92XmTwy4 S3IG9FH+xIifob8DBr3hVu1EmFZk63XBCrbqnFBg3FhjJsUvfti+my81TpX+fLDnZG zsCokxkZiQO/2ckFGaqR62NlE2DscVA/go9oy/MYaCpNAluUXTF87uhohWEWCqRsb5 3mUR8plPObXTanTazmuh59kh1V6gEYWEDnYGFA8otlbNNeROo4ORH9bBrmRRZztwHJ 8XTiCL0FTcD7g12MJ23Sw6zuqGd2DkwnoStoaxh6SeWl9kUxXyFEYknGexiVz/Fso3 NfXKaGdOVyEvw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 40A61CE13DF; Mon, 31 Mar 2025 14:03:15 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org, Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Boqun Feng Subject: [PATCH v2 12/12] torture: Add testing of RCU's Rust bindings to torture.sh Date: Mon, 31 Mar 2025 14:03:14 -0700 Message-Id: <20250331210314.590622-12-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: 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" This commit adds a --do-rcu-rust parameter to torture.sh, which invokes a rust_doctests_kernel kunit run. Note that kunit wants a clean source tree, so this runs "make mrproper", which might come as a surprise to some users. Should there be a --mrproper parameter to torture.sh to make the user explicitly ask for it? Co-developed-by: Boqun Feng Signed-off-by: Boqun Feng Signed-off-by: Paul E. McKenney --- .../selftests/rcutorture/bin/torture.sh | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tools/testing/selftests/rcutorture/bin/torture.sh b/tools/test= ing/selftests/rcutorture/bin/torture.sh index 751ce770e5462..2c3e86fe8c0a2 100755 --- a/tools/testing/selftests/rcutorture/bin/torture.sh +++ b/tools/testing/selftests/rcutorture/bin/torture.sh @@ -59,6 +59,7 @@ do_clocksourcewd=3Dyes do_rt=3Dyes do_rcutasksflavors=3Dyes do_srcu_lockdep=3Dyes +do_rcu_rust=3Dno =20 # doyesno - Helper function for yes/no arguments function doyesno () { @@ -89,6 +90,7 @@ usage () { echo " --do-rcutorture / --do-no-rcutorture / --no-rcutorture" echo " --do-refscale / --do-no-refscale / --no-refscale" echo " --do-rt / --do-no-rt / --no-rt" + echo " --do-rcu-rust / --do-no-rcu-rust / --no-rcu-rust" echo " --do-scftorture / --do-no-scftorture / --no-scftorture" echo " --do-srcu-lockdep / --do-no-srcu-lockdep / --no-srcu-lockdep" echo " --duration [ | h | d ]" @@ -191,6 +193,9 @@ do --do-rt|--do-no-rt|--no-rt) do_rt=3D`doyesno "$1" --do-rt` ;; + --do-rcu-rust|--do-no-rcu-rust|--no-rcu-rust) + do_rcu_rust=3D`doyesno "$1" --do-rcu-rust` + ;; --do-scftorture|--do-no-scftorture|--no-scftorture) do_scftorture=3D`doyesno "$1" --do-scftorture` ;; @@ -485,6 +490,46 @@ then torture_set "rcurttorture-exp" tools/testing/selftests/rcutorture/bin/kvm= .sh --allcpus --duration "$duration_rcutorture" --configs "TREE03" --kconfi= g "CONFIG_PREEMPT_LAZY=3Dn CONFIG_PREEMPT_RT=3Dy CONFIG_EXPERT=3Dy" --trust= -make fi =20 +if test "$do_rcu_rust" =3D "yes" +then + echo " --- do-rcu-rust:" Start `date` | tee -a $T/log + rrdir=3D"tools/testing/selftests/rcutorture/res/$ds/results-rcu-rust" + mkdir -p "$rrdir" + echo " --- make LLVM=3D1 rustavailable " | tee -a $rrdir/log > $rrdir/rus= tavailable.out + make LLVM=3D1 rustavailable > $T/rustavailable.out 2>&1 + retcode=3D$? + echo $retcode > $rrdir/rustavailable.exitcode + cat $T/rustavailable.out | tee -a $rrdir/log >> $rrdir/rustavailable.out = 2>&1 + buildphase=3Drustavailable + if test "$retcode" -eq 0 + then + echo " --- Running 'make mrproper' in order to run kunit." | tee -a $rrd= ir/log > $rrdir/mrproper.out + make mrproper > $rrdir/mrproper.out 2>&1 + retcode =3D $? + echo $retcode > $rrdir/mrproper.exitcode + buildphase=3Dmrproper + fi + if test "$retcode" -eq 0 + then + echo " --- Running rust_doctests_kernel." | tee -a $rrdir/log > $rrdir/r= ust_doctests_kernel.out + ./tools/testing/kunit/kunit.py run --make_options LLVM=3D1 --make_option= s CLIPPY=3D1 --arch arm64 --kconfig_add CONFIG_SMP=3Dy --kconfig_add CONFIG= _WERROR=3Dy --kconfig_add CONFIG_RUST=3Dy rust_doctests_kernel >> $rrdir/ru= st_doctests_kernel.out 2>&1 + # @@@ Remove "--arch arm64" in order to test on native architecture? + # @@@ Analyze $rrdir/rust_doctests_kernel.out contents? + retcode=3D$? + echo $retcode > $rrdir/rust_doctests_kernel.exitcode + buildphase=3Drust_doctests_kernel + fi + if test "$retcode" -eq 0 + then + echo "rcu-rust($retcode)" $rrdir >> $T/successes + echo Success >> $rrdir/log + else + echo "rcu-rust($retcode)" $rrdir >> $T/failures + echo " --- rcu-rust Test summary:" >> $rrdir/log + echo " --- Summary: Exit code $retcode from $buildphase, see $rrdir/$bui= ldphase.out" >> $rrdir/log + fi +fi + if test "$do_srcu_lockdep" =3D "yes" then echo " --- do-srcu-lockdep:" Start `date` | tee -a $T/log --=20 2.40.1