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:
@@ -1486,6 +1486,31 @@ static void rcu_gp_slow(int delay)
|
||||
schedule_timeout_uninterruptible(delay);
|
||||
}
|
||||
|
||||
static unsigned long sleep_duration;
|
||||
|
||||
/* Allow rcutorture to stall the grace-period kthread. */
|
||||
void rcu_gp_set_torture_wait(int duration)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST) && duration > 0)
|
||||
WRITE_ONCE(sleep_duration, duration);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rcu_gp_set_torture_wait);
|
||||
|
||||
/* Actually implement the aforementioned wait. */
|
||||
static void rcu_gp_torture_wait(void)
|
||||
{
|
||||
unsigned long duration;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_RCU_TORTURE_TEST))
|
||||
return;
|
||||
duration = xchg(&sleep_duration, 0UL);
|
||||
if (duration > 0) {
|
||||
pr_alert("%s: Waiting %lu jiffies\n", __func__, duration);
|
||||
schedule_timeout_uninterruptible(duration);
|
||||
pr_alert("%s: Wait complete\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a new grace period. Return false if no grace period required.
|
||||
*/
|
||||
@@ -1686,6 +1711,7 @@ static void rcu_gp_fqs_loop(void)
|
||||
rcu_state.gp_state = RCU_GP_WAIT_FQS;
|
||||
ret = swait_event_idle_timeout_exclusive(
|
||||
rcu_state.gp_wq, rcu_gp_fqs_check_wake(&gf), j);
|
||||
rcu_gp_torture_wait();
|
||||
rcu_state.gp_state = RCU_GP_DOING_FQS;
|
||||
/* Locking provides needed memory barriers. */
|
||||
/* If grace period done, leave loop. */
|
||||
@@ -1834,6 +1860,7 @@ static int __noreturn rcu_gp_kthread(void *unused)
|
||||
swait_event_idle_exclusive(rcu_state.gp_wq,
|
||||
READ_ONCE(rcu_state.gp_flags) &
|
||||
RCU_GP_FLAG_INIT);
|
||||
rcu_gp_torture_wait();
|
||||
rcu_state.gp_state = RCU_GP_DONE_GPS;
|
||||
/* Locking provides needed memory barrier. */
|
||||
if (rcu_gp_init())
|
||||
|
مرجع در شماره جدید
Block a user