summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorKunwu Chan <kunwu.chan@gmail.com>2026-08-20 17:42:28 +0800
committerPaul E. McKenney <paulmck@kernel.org>2026-09-18 16:15:54 -0700
commitb309290a246f34995c2e212ef51b620847722f39 (patch)
treeffb818de6d2593eadf99d0d7d24a83af3a013501 /tools/perf/scripts/python
parent89aa2d12f6d53f0f94d17582d1832d6f2ebe603f (diff)
downloadlinux-next-b309290a246f34995c2e212ef51b620847722f39.tar.gz
linux-next-b309290a246f34995c2e212ef51b620847722f39.zip
rcutorture: Fix divide-by-zero with fwd_progress_div=1
When fwd_progress_div=1, the forward-progress test computes: sd4 = (sd + div - 1) / div = sd dur = sd4 + torture_random(&trs) % (sd - sd4) = sd4 + % 0 The modulo operation with a zero divisor triggers an integer division by zero (undefined behavior at the C level, #DE trap on x86), causing a kernel Oops and panic. On x86_64, this manifests as: rcu_torture_fwd_prog_nr: Starting forward-progress test 0 Oops: divide error: 0000 [#1] SMP PTI RIP: 0010:rcu_torture_fwd_prog+0x90b/0x1160 R12: 0000000000000000 The existing guard only handles non-positive values. However, fwd_progress_div=1 also makes the random range empty because sd4 == sd. Change the guard to reject values below 2. The forward-progress test only reaches this calculation when stall_dur() is positive, so sd = stall_dur() + 1 >= 2. For fwd_progress_div >= 2, sd4 < sd, ensuring that sd - sd4 is at least 1. Keep the existing fallback to the default value of 4 for invalid values. Verified with QEMU/KVM: a 138-second run with fwd_progress_div=1 completed 81 forward-progress test cycles without a crash. Fixes: 1b27291b1ea4f ("rcutorture: Add forward-progress tests for RCU grace periods") Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions