Skip to content

Commit d38e6dc

Browse files
committed
rcutorture: Force on tick for readers and callback flooders
Readers and callback flooders in the rcutorture stress-test suite run for extended time periods by design. They do take pains to relinquish the CPU from time to time, but in some cases this relies on the scheduler being active, which in turn relies on the scheduler-clock interrupt firing from time to time. This commit therefore forces scheduling-clock interrupts within these loops. While in the area, this commit also prevents rcu_torture_reader()'s occasional timed sleeps from delaying shutdown. [ paulmck: Apply Joel Fernandes TICK_DEP_MASK_RCU->TICK_DEP_BIT_RCU fix. ] Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 6a949b7 commit d38e6dc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

kernel/rcu/rcutorture.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/sched/debug.h>
4545
#include <linux/sched/sysctl.h>
4646
#include <linux/oom.h>
47+
#include <linux/tick.h>
4748

4849
#include "rcu.h"
4950

@@ -1363,15 +1364,15 @@ rcu_torture_reader(void *arg)
13631364
set_user_nice(current, MAX_NICE);
13641365
if (irqreader && cur_ops->irq_capable)
13651366
timer_setup_on_stack(&t, rcu_torture_timer, 0);
1366-
1367+
tick_dep_set_task(current, TICK_DEP_BIT_RCU);
13671368
do {
13681369
if (irqreader && cur_ops->irq_capable) {
13691370
if (!timer_pending(&t))
13701371
mod_timer(&t, jiffies + 1);
13711372
}
1372-
if (!rcu_torture_one_read(&rand))
1373+
if (!rcu_torture_one_read(&rand) && !torture_must_stop())
13731374
schedule_timeout_interruptible(HZ);
1374-
if (time_after(jiffies, lastsleep)) {
1375+
if (time_after(jiffies, lastsleep) && !torture_must_stop()) {
13751376
schedule_timeout_interruptible(1);
13761377
lastsleep = jiffies + 10;
13771378
}
@@ -1383,6 +1384,7 @@ rcu_torture_reader(void *arg)
13831384
del_timer_sync(&t);
13841385
destroy_timer_on_stack(&t);
13851386
}
1387+
tick_dep_clear_task(current, TICK_DEP_BIT_RCU);
13861388
torture_kthread_stopping("rcu_torture_reader");
13871389
return 0;
13881390
}
@@ -1729,10 +1731,10 @@ static void rcu_torture_fwd_prog_cond_resched(unsigned long iter)
17291731
// Real call_rcu() floods hit userspace, so emulate that.
17301732
if (need_resched() || (iter & 0xfff))
17311733
schedule();
1732-
} else {
1733-
// No userspace emulation: CB invocation throttles call_rcu()
1734-
cond_resched();
1734+
return;
17351735
}
1736+
// No userspace emulation: CB invocation throttles call_rcu()
1737+
cond_resched();
17361738
}
17371739

17381740
/*
@@ -1865,6 +1867,7 @@ static void rcu_torture_fwd_prog_cr(void)
18651867
cver = READ_ONCE(rcu_torture_current_version);
18661868
gps = cur_ops->get_gp_seq();
18671869
rcu_launder_gp_seq_start = gps;
1870+
tick_dep_set_task(current, TICK_DEP_BIT_RCU);
18681871
while (time_before(jiffies, stopat) &&
18691872
!shutdown_time_arrived() &&
18701873
!READ_ONCE(rcu_fwd_emergency_stop) && !torture_must_stop()) {
@@ -1911,6 +1914,7 @@ static void rcu_torture_fwd_prog_cr(void)
19111914
rcu_torture_fwd_cb_hist();
19121915
}
19131916
schedule_timeout_uninterruptible(HZ); /* Let CBs drain. */
1917+
tick_dep_clear_task(current, TICK_DEP_BIT_RCU);
19141918
WRITE_ONCE(rcu_fwd_cb_nodelay, false);
19151919
}
19161920

0 commit comments

Comments
 (0)