Skip to content

Commit 66bcb13

Browse files
joelagnelFrederic Weisbecker
authored andcommitted
rcutorture: Replace schedule_timeout*() 1-jiffy waits with HZ/20
In the past, spinning on schedule_timeout* with a wait of 1 jiffy has hung the kernel. See for example d52d3a2 ("torture: Fix hang during kthread shutdown phase"). This issue recently recurred in torture's stutter code. The result is that the function instantly returns and never goes to sleep, preempting whatever might otherwise make useful forward progress. To prevent future issues, apply the commit-d52d3a2bf408 fix throughout rcutorture, moving from a 1-jiffy wait to a 50-millisecond wait. Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 30639bf commit 66bcb13

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/rcu/rcutorture.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ static int rcu_torture_boost(void *arg)
11491149
mutex_unlock(&boost_mutex);
11501150
break;
11511151
}
1152-
schedule_timeout_uninterruptible(1);
1152+
schedule_timeout_uninterruptible(HZ / 20);
11531153
}
11541154

11551155
/* Go do the stutter. */
@@ -1160,7 +1160,7 @@ checkwait: if (stutter_wait("rcu_torture_boost"))
11601160
/* Clean up and exit. */
11611161
while (!kthread_should_stop()) {
11621162
torture_shutdown_absorb("rcu_torture_boost");
1163-
schedule_timeout_uninterruptible(1);
1163+
schedule_timeout_uninterruptible(HZ / 20);
11641164
}
11651165
torture_kthread_stopping("rcu_torture_boost");
11661166
return 0;
@@ -1183,7 +1183,7 @@ rcu_torture_fqs(void *arg)
11831183
fqs_resume_time = jiffies + fqs_stutter * HZ;
11841184
while (time_before(jiffies, fqs_resume_time) &&
11851185
!kthread_should_stop()) {
1186-
schedule_timeout_interruptible(1);
1186+
schedule_timeout_interruptible(HZ / 20);
11871187
}
11881188
fqs_burst_remaining = fqs_duration;
11891189
while (fqs_burst_remaining > 0 &&
@@ -2899,7 +2899,7 @@ static int rcu_torture_fwd_prog(void *args)
28992899
WRITE_ONCE(rcu_fwd_seq, rcu_fwd_seq + 1);
29002900
} else {
29012901
while (READ_ONCE(rcu_fwd_seq) == oldseq && !torture_must_stop())
2902-
schedule_timeout_interruptible(1);
2902+
schedule_timeout_interruptible(HZ / 20);
29032903
oldseq = READ_ONCE(rcu_fwd_seq);
29042904
}
29052905
pr_alert("%s: Starting forward-progress test %d\n", __func__, rfp->rcu_fwd_id);
@@ -3200,7 +3200,7 @@ static int rcu_torture_read_exit_child(void *trsp_in)
32003200
set_user_nice(current, MAX_NICE);
32013201
// Minimize time between reading and exiting.
32023202
while (!kthread_should_stop())
3203-
schedule_timeout_uninterruptible(1);
3203+
schedule_timeout_uninterruptible(HZ / 20);
32043204
(void)rcu_torture_one_read(trsp, -1);
32053205
return 0;
32063206
}
@@ -3248,7 +3248,7 @@ static int rcu_torture_read_exit(void *unused)
32483248
smp_mb(); // Store before wakeup.
32493249
wake_up(&read_exit_wq);
32503250
while (!torture_must_stop())
3251-
schedule_timeout_uninterruptible(1);
3251+
schedule_timeout_uninterruptible(HZ / 20);
32523252
torture_kthread_stopping("rcu_torture_read_exit");
32533253
return 0;
32543254
}

0 commit comments

Comments
 (0)