mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rcutorture: Fix operator precedence bug in exp_current() invocation
@ 2025-12-23  0:44 Joel Fernandes
  2025-12-23  1:12 ` Paul E. McKenney
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Fernandes @ 2025-12-23  0:44 UTC (permalink / raw)
  To: linux-kernel, Davidlohr Bueso, Paul E. McKenney, Josh Triplett,
	Frederic Weisbecker, Neeraj Upadhyay, Joel Fernandes, Boqun Feng,
	Uladzislau Rezki, Steven Rostedt, Mathieu Desnoyers,
	Lai Jiangshan, Zqiang
  Cc: rcu

Fix incorrect operator precedence in the conditional that determines
when to call exp_current() during torture testing. The modulo
by 0xff appears to do nothing.

Fix by adding parentheses:

    !(torture_random(&rand) % 0xff)

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
 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 82588ceed9da..9873a1d54c46 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1749,7 +1749,7 @@ rcu_torture_writer(void *arg)
 					ulo[i] = cur_ops->get_comp_state();
 				gp_snap = cur_ops->start_gp_poll();
 				rcu_torture_writer_state = RTWS_POLL_WAIT;
-				if (cur_ops->exp_current && !torture_random(&rand) % 0xff)
+				if (cur_ops->exp_current && !(torture_random(&rand) % 0xff))
 					cur_ops->exp_current();
 				while (!cur_ops->poll_gp_state(gp_snap)) {
 					gp_snap1 = cur_ops->get_gp_state();
@@ -1771,7 +1771,7 @@ rcu_torture_writer(void *arg)
 					cur_ops->get_comp_state_full(&rgo[i]);
 				cur_ops->start_gp_poll_full(&gp_snap_full);
 				rcu_torture_writer_state = RTWS_POLL_WAIT_FULL;
-				if (cur_ops->exp_current && !torture_random(&rand) % 0xff)
+				if (cur_ops->exp_current && !(torture_random(&rand) % 0xff))
 					cur_ops->exp_current();
 				while (!cur_ops->poll_gp_state_full(&gp_snap_full)) {
 					cur_ops->get_gp_state_full(&gp_snap1_full);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-12-25 18:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-23  0:44 [PATCH] rcutorture: Fix operator precedence bug in exp_current() invocation Joel Fernandes
2025-12-23  1:12 ` Paul E. McKenney
2025-12-23  1:24   ` Joel Fernandes
2025-12-23 16:37   ` Steven Rostedt
2025-12-23 17:22     ` Joel Fernandes
2025-12-23 17:28       ` Paul E. McKenney
2025-12-23 17:30         ` Joel Fernandes
2025-12-23 17:51           ` Paul E. McKenney
2025-12-23 20:54             ` Steven Rostedt
2025-12-23 23:50               ` Paul E. McKenney
2025-12-24 14:14                 ` Steven Rostedt
2025-12-25 18:43                   ` Paul E. McKenney
2025-12-24  0:50               ` Chris Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®