Skip to content

Commit 9a316fe

Browse files
committed
rcutorture: Delay rcutorture readers and writers until boot completes
The rcutorture writers and (especially) readers are the biggest CPU hogs of the bunch, so this commit therefore makes them wait until boot has completed. This makes the current setting of the boot_ended local variable dead code, so while in the area, this commit removes that as well. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 1b0f583 commit 9a316fe

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

kernel/rcu/rcutorture.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
15281528
static int
15291529
rcu_torture_writer(void *arg)
15301530
{
1531-
bool boot_ended;
1531+
bool booting_still = false;
15321532
bool can_expedite = !rcu_gp_is_expedited() && !rcu_gp_is_normal();
15331533
unsigned long cookie;
15341534
struct rcu_gp_oldstate cookie_full;
@@ -1539,6 +1539,7 @@ rcu_torture_writer(void *arg)
15391539
struct rcu_gp_oldstate gp_snap1_full;
15401540
int i;
15411541
int idx;
1542+
unsigned long j;
15421543
int oldnice = task_nice(current);
15431544
struct rcu_gp_oldstate *rgo = NULL;
15441545
int rgo_size = 0;
@@ -1581,6 +1582,16 @@ rcu_torture_writer(void *arg)
15811582
rgo_size = cur_ops->poll_active_full;
15821583
}
15831584

1585+
// If the system is still booting, let it finish.
1586+
j = jiffies;
1587+
while (!torture_must_stop() && !rcu_inkernel_boot_has_ended()) {
1588+
booting_still = true;
1589+
schedule_timeout_interruptible(HZ);
1590+
}
1591+
if (booting_still)
1592+
pr_alert("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n",
1593+
torture_type, jiffies - j);
1594+
15841595
do {
15851596
rcu_torture_writer_state = RTWS_FIXED_DELAY;
15861597
torture_hrtimeout_us(500, 1000, &rand);
@@ -1769,13 +1780,11 @@ rcu_torture_writer(void *arg)
17691780
!rcu_gp_is_normal();
17701781
}
17711782
rcu_torture_writer_state = RTWS_STUTTER;
1772-
boot_ended = rcu_inkernel_boot_has_ended();
17731783
stutter_waited = stutter_wait("rcu_torture_writer");
17741784
if (stutter_waited &&
17751785
!atomic_read(&rcu_fwd_cb_nodelay) &&
17761786
!cur_ops->slow_gps &&
17771787
!torture_must_stop() &&
1778-
boot_ended &&
17791788
time_after(jiffies, stallsdone))
17801789
for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
17811790
if (list_empty(&rcu_tortures[i].rtort_free) &&
@@ -2437,7 +2446,8 @@ rcu_torture_reader(void *arg)
24372446
torture_hrtimeout_us(500, 1000, &rand);
24382447
lastsleep = jiffies + 10;
24392448
}
2440-
while (torture_num_online_cpus() < mynumonline && !torture_must_stop())
2449+
while (!torture_must_stop() &&
2450+
(torture_num_online_cpus() < mynumonline || !rcu_inkernel_boot_has_ended()))
24412451
schedule_timeout_interruptible(HZ / 5);
24422452
stutter_wait("rcu_torture_reader");
24432453
} while (!torture_must_stop());

0 commit comments

Comments
 (0)