public inbox for rcu@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: linux-kernel@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>
Cc: rcu@vger.kernel.org, Joel Fernandes <joelagnelf@nvidia.com>
Subject: [PATCH -next v1 16/16] torture: Avoid modulo-zero error in torture_hrtimeout_ns()
Date: Tue, 17 Mar 2026 17:22:17 -0400	[thread overview]
Message-ID: <20260317212217.1527644-17-joelagnelf@nvidia.com> (raw)
In-Reply-To: <20260317212217.1527644-1-joelagnelf@nvidia.com>

From: "Paul E. McKenney" <paulmck@kernel.org>

Currently, all calls to torture_hrtimeout_ns() either provide a non-zero
fuzzt_ns or a NULL trsp, either of which avoids taking the modulus of a
zero-valued fuzzt_ns.  But this code should do a better job of defending
itself, so this commit explicitly checks fuzzt_ns and avoids the modulus
when its value is zero.

Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 kernel/torture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/torture.c b/kernel/torture.c
index ec3370986976..62c1ac777694 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -93,7 +93,7 @@ int torture_hrtimeout_ns(ktime_t baset_ns, u32 fuzzt_ns, const enum hrtimer_mode
 {
 	ktime_t hto = baset_ns;
 
-	if (trsp)
+	if (trsp && fuzzt_ns)
 		hto += torture_random(trsp) % fuzzt_ns;
 	set_current_state(TASK_IDLE);
 	return schedule_hrtimeout(&hto, mode);
-- 
2.34.1


      parent reply	other threads:[~2026-03-17 21:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 21:22 [PATCH -next v1 00/16] Candidate patches for the v7.1 merge window Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 01/16] rcutorture: Add a textbook-style trivial preemptible RCU Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 02/16] kvm-check-branches.sh: Remove in favor of kvm-series.sh Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 03/16] torture: Make hangs more visible in torture.sh output Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 04/16] torture: Print informative message for test without recheck file Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 05/16] rcutorture: Fix numeric "test" comparison in srcu_lockdep.sh Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 06/16] refscale: Ditch ref_scale_shutdown in favor of torture_shutdown_init() Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 07/16] rcuscale: Ditch rcu_scale_shutdown " Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 08/16] srcu: Fix SRCU read flavor macro comments Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 09/16] srcu: Fix s/they disables/they disable/ typo in srcu_read_unlock_fast() Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 10/16] rcu-tasks: Document that RCU Tasks Trace grace periods now imply RCU grace periods Joel Fernandes
2026-03-18 11:04   ` Frederic Weisbecker
2026-03-18 12:15     ` Frederic Weisbecker
2026-03-17 21:22 ` [PATCH -next v1 11/16] rcutorture: Add NOCB01 config for RCU_LAZY torture testing Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 12/16] rcutorture: Add NOCB02 config for nocb poll mode testing Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 13/16] rcu-tasks: Remove unnecessary smp_store_release() in cblist_init_generic() Joel Fernandes
2026-03-18 10:57   ` Frederic Weisbecker
2026-03-17 21:22 ` [PATCH -next v1 14/16] rcu/nocb: Consolidate rcu_nocb_cpu_offload/deoffload functions Joel Fernandes
2026-03-17 21:22 ` [PATCH -next v1 15/16] rcu/nocb: Extract nocb_bypass_needs_flush() to reduce duplication Joel Fernandes
2026-03-17 21:22 ` Joel Fernandes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260317212217.1527644-17-joelagnelf@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=dave@stgolabs.net \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox