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>
This commit is contained in:
Paul E. McKenney 2025-08-06 16:35:26 -07:00
parent 1b0f583843
commit 9a316fe3ad
1 changed files with 14 additions and 4 deletions

View File

@ -1528,7 +1528,7 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
static int static int
rcu_torture_writer(void *arg) rcu_torture_writer(void *arg)
{ {
bool boot_ended; bool booting_still = false;
bool can_expedite = !rcu_gp_is_expedited() && !rcu_gp_is_normal(); bool can_expedite = !rcu_gp_is_expedited() && !rcu_gp_is_normal();
unsigned long cookie; unsigned long cookie;
struct rcu_gp_oldstate cookie_full; struct rcu_gp_oldstate cookie_full;
@ -1539,6 +1539,7 @@ rcu_torture_writer(void *arg)
struct rcu_gp_oldstate gp_snap1_full; struct rcu_gp_oldstate gp_snap1_full;
int i; int i;
int idx; int idx;
unsigned long j;
int oldnice = task_nice(current); int oldnice = task_nice(current);
struct rcu_gp_oldstate *rgo = NULL; struct rcu_gp_oldstate *rgo = NULL;
int rgo_size = 0; int rgo_size = 0;
@ -1581,6 +1582,16 @@ rcu_torture_writer(void *arg)
rgo_size = cur_ops->poll_active_full; rgo_size = cur_ops->poll_active_full;
} }
// If the system is still booting, let it finish.
j = jiffies;
while (!torture_must_stop() && !rcu_inkernel_boot_has_ended()) {
booting_still = true;
schedule_timeout_interruptible(HZ);
}
if (booting_still)
pr_alert("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n",
torture_type, jiffies - j);
do { do {
rcu_torture_writer_state = RTWS_FIXED_DELAY; rcu_torture_writer_state = RTWS_FIXED_DELAY;
torture_hrtimeout_us(500, 1000, &rand); torture_hrtimeout_us(500, 1000, &rand);
@ -1769,13 +1780,11 @@ rcu_torture_writer(void *arg)
!rcu_gp_is_normal(); !rcu_gp_is_normal();
} }
rcu_torture_writer_state = RTWS_STUTTER; rcu_torture_writer_state = RTWS_STUTTER;
boot_ended = rcu_inkernel_boot_has_ended();
stutter_waited = stutter_wait("rcu_torture_writer"); stutter_waited = stutter_wait("rcu_torture_writer");
if (stutter_waited && if (stutter_waited &&
!atomic_read(&rcu_fwd_cb_nodelay) && !atomic_read(&rcu_fwd_cb_nodelay) &&
!cur_ops->slow_gps && !cur_ops->slow_gps &&
!torture_must_stop() && !torture_must_stop() &&
boot_ended &&
time_after(jiffies, stallsdone)) time_after(jiffies, stallsdone))
for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++) for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
if (list_empty(&rcu_tortures[i].rtort_free) && if (list_empty(&rcu_tortures[i].rtort_free) &&
@ -2437,7 +2446,8 @@ rcu_torture_reader(void *arg)
torture_hrtimeout_us(500, 1000, &rand); torture_hrtimeout_us(500, 1000, &rand);
lastsleep = jiffies + 10; lastsleep = jiffies + 10;
} }
while (torture_num_online_cpus() < mynumonline && !torture_must_stop()) while (!torture_must_stop() &&
(torture_num_online_cpus() < mynumonline || !rcu_inkernel_boot_has_ended()))
schedule_timeout_interruptible(HZ / 5); schedule_timeout_interruptible(HZ / 5);
stutter_wait("rcu_torture_reader"); stutter_wait("rcu_torture_reader");
} while (!torture_must_stop()); } while (!torture_must_stop());