rcu: Allow rcutorture to starve grace-period kthread
This commit provides an rcutorture.stall_gp_kthread module parameter to allow rcutorture to starve the grace-period kthread. This allows testing the code that detects such starvation. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
@@ -115,6 +115,8 @@ torture_param(int, stall_cpu_holdoff, 10,
|
||||
"Time to wait before starting stall (s).");
|
||||
torture_param(int, stall_cpu_irqsoff, 0, "Disable interrupts while stalling.");
|
||||
torture_param(int, stall_cpu_block, 0, "Sleep while stalling.");
|
||||
torture_param(int, stall_gp_kthread, 0,
|
||||
"Grace-period kthread stall duration (s).");
|
||||
torture_param(int, stat_interval, 60,
|
||||
"Number of seconds between stats printk()s");
|
||||
torture_param(int, stutter, 5, "Number of seconds to run/halt test");
|
||||
@@ -1623,7 +1625,17 @@ static int rcu_torture_stall(void *args)
|
||||
schedule_timeout_interruptible(stall_cpu_holdoff * HZ);
|
||||
VERBOSE_TOROUT_STRING("rcu_torture_stall end holdoff");
|
||||
}
|
||||
if (!kthread_should_stop()) {
|
||||
if (!kthread_should_stop() && stall_gp_kthread > 0) {
|
||||
VERBOSE_TOROUT_STRING("rcu_torture_stall begin GP stall");
|
||||
rcu_gp_set_torture_wait(stall_gp_kthread * HZ);
|
||||
for (idx = 0; idx < stall_gp_kthread + 2; idx++) {
|
||||
if (kthread_should_stop())
|
||||
break;
|
||||
schedule_timeout_uninterruptible(HZ);
|
||||
}
|
||||
}
|
||||
if (!kthread_should_stop() && stall_cpu > 0) {
|
||||
VERBOSE_TOROUT_STRING("rcu_torture_stall begin CPU stall");
|
||||
stop_at = ktime_get_seconds() + stall_cpu;
|
||||
/* RCU CPU stall is expected behavior in following code. */
|
||||
idx = cur_ops->readlock();
|
||||
@@ -1642,8 +1654,8 @@ static int rcu_torture_stall(void *args)
|
||||
else if (!stall_cpu_block)
|
||||
preempt_enable();
|
||||
cur_ops->readunlock(idx);
|
||||
pr_alert("rcu_torture_stall end.\n");
|
||||
}
|
||||
pr_alert("rcu_torture_stall end.\n");
|
||||
torture_shutdown_absorb("rcu_torture_stall");
|
||||
while (!kthread_should_stop())
|
||||
schedule_timeout_interruptible(10 * HZ);
|
||||
@@ -1653,7 +1665,7 @@ static int rcu_torture_stall(void *args)
|
||||
/* Spawn CPU-stall kthread, if stall_cpu specified. */
|
||||
static int __init rcu_torture_stall_init(void)
|
||||
{
|
||||
if (stall_cpu <= 0)
|
||||
if (stall_cpu <= 0 && stall_gp_kthread <= 0)
|
||||
return 0;
|
||||
return torture_create_kthread(rcu_torture_stall, NULL, stall_task);
|
||||
}
|
||||
|
Reference in New Issue
Block a user