Skip to content

Commit 19a8ff9

Browse files
committed
rcutorture: Add flag to produce non-busy-wait task stalls
This commit aids testing of RCU task stall warning messages by adding an rcutorture.stall_cpu_block module parameter that results in the induced stall sleeping within the RCU read-side critical section. Spinning with interrupts disabled is still available via the rcutorture.stall_cpu_irqsoff module parameter, and specifying neither of these two module parameters will spin with preemption disabled. Note that sleeping (as opposed to preemption) results in additional complaints from RCU at context-switch time, so yet more testing. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent be44ae6 commit 19a8ff9

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4210,6 +4210,11 @@
42104210
Duration of CPU stall (s) to test RCU CPU stall
42114211
warnings, zero to disable.
42124212

4213+
rcutorture.stall_cpu_block= [KNL]
4214+
Sleep while stalling if set. This will result
4215+
in warnings from preemptible RCU in addition
4216+
to any other stall-related activity.
4217+
42134218
rcutorture.stall_cpu_holdoff= [KNL]
42144219
Time to wait (s) after boot before inducing stall.
42154220

kernel/rcu/rcutorture.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ torture_param(int, stall_cpu, 0, "Stall duration (s), zero to disable.");
114114
torture_param(int, stall_cpu_holdoff, 10,
115115
"Time to wait before starting stall (s).");
116116
torture_param(int, stall_cpu_irqsoff, 0, "Disable interrupts while stalling.");
117+
torture_param(int, stall_cpu_block, 0, "Sleep while stalling.");
117118
torture_param(int, stat_interval, 60,
118119
"Number of seconds between stats printk()s");
119120
torture_param(int, stutter, 5, "Number of seconds to run/halt test");
@@ -1548,6 +1549,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
15481549
"test_boost=%d/%d test_boost_interval=%d "
15491550
"test_boost_duration=%d shutdown_secs=%d "
15501551
"stall_cpu=%d stall_cpu_holdoff=%d stall_cpu_irqsoff=%d "
1552+
"stall_cpu_block=%d "
15511553
"n_barrier_cbs=%d "
15521554
"onoff_interval=%d onoff_holdoff=%d\n",
15531555
torture_type, tag, nrealreaders, nfakewriters,
@@ -1556,6 +1558,7 @@ rcu_torture_print_module_parms(struct rcu_torture_ops *cur_ops, const char *tag)
15561558
test_boost, cur_ops->can_boost,
15571559
test_boost_interval, test_boost_duration, shutdown_secs,
15581560
stall_cpu, stall_cpu_holdoff, stall_cpu_irqsoff,
1561+
stall_cpu_block,
15591562
n_barrier_cbs,
15601563
onoff_interval, onoff_holdoff);
15611564
}
@@ -1611,6 +1614,7 @@ static int rcutorture_booster_init(unsigned int cpu)
16111614
*/
16121615
static int rcu_torture_stall(void *args)
16131616
{
1617+
int idx;
16141618
unsigned long stop_at;
16151619

16161620
VERBOSE_TOROUT_STRING("rcu_torture_stall task started");
@@ -1622,21 +1626,22 @@ static int rcu_torture_stall(void *args)
16221626
if (!kthread_should_stop()) {
16231627
stop_at = ktime_get_seconds() + stall_cpu;
16241628
/* RCU CPU stall is expected behavior in following code. */
1625-
rcu_read_lock();
1629+
idx = cur_ops->readlock();
16261630
if (stall_cpu_irqsoff)
16271631
local_irq_disable();
1628-
else
1632+
else if (!stall_cpu_block)
16291633
preempt_disable();
16301634
pr_alert("rcu_torture_stall start on CPU %d.\n",
1631-
smp_processor_id());
1635+
raw_smp_processor_id());
16321636
while (ULONG_CMP_LT((unsigned long)ktime_get_seconds(),
16331637
stop_at))
1634-
continue; /* Induce RCU CPU stall warning. */
1638+
if (stall_cpu_block)
1639+
schedule_timeout_uninterruptible(HZ);
16351640
if (stall_cpu_irqsoff)
16361641
local_irq_enable();
1637-
else
1642+
else if (!stall_cpu_block)
16381643
preempt_enable();
1639-
rcu_read_unlock();
1644+
cur_ops->readunlock(idx);
16401645
pr_alert("rcu_torture_stall end.\n");
16411646
}
16421647
torture_shutdown_absorb("rcu_torture_stall");

0 commit comments

Comments
 (0)