]> www.infradead.org Git - users/hch/misc.git/commitdiff
rcutorture: Delay rcutorture readers and writers until boot completes
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 6 Aug 2025 23:35:26 +0000 (16:35 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 14 Aug 2025 22:26:30 +0000 (15:26 -0700)
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>
kernel/rcu/rcutorture.c

index 49e048da4f6810fac324dc06ad00cea027cbc207..1578d3305657528865c3cfda715d48e13c89b2b8 100644 (file)
@@ -1528,7 +1528,7 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
 static int
 rcu_torture_writer(void *arg)
 {
-       bool boot_ended;
+       bool booting_still = false;
        bool can_expedite = !rcu_gp_is_expedited() && !rcu_gp_is_normal();
        unsigned long cookie;
        struct rcu_gp_oldstate cookie_full;
@@ -1539,6 +1539,7 @@ rcu_torture_writer(void *arg)
        struct rcu_gp_oldstate gp_snap1_full;
        int i;
        int idx;
+       unsigned long j;
        int oldnice = task_nice(current);
        struct rcu_gp_oldstate *rgo = NULL;
        int rgo_size = 0;
@@ -1581,6 +1582,16 @@ rcu_torture_writer(void *arg)
                        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 {
                rcu_torture_writer_state = RTWS_FIXED_DELAY;
                torture_hrtimeout_us(500, 1000, &rand);
@@ -1769,13 +1780,11 @@ rcu_torture_writer(void *arg)
                                       !rcu_gp_is_normal();
                }
                rcu_torture_writer_state = RTWS_STUTTER;
-               boot_ended = rcu_inkernel_boot_has_ended();
                stutter_waited = stutter_wait("rcu_torture_writer");
                if (stutter_waited &&
                    !atomic_read(&rcu_fwd_cb_nodelay) &&
                    !cur_ops->slow_gps &&
                    !torture_must_stop() &&
-                   boot_ended &&
                    time_after(jiffies, stallsdone))
                        for (i = 0; i < ARRAY_SIZE(rcu_tortures); i++)
                                if (list_empty(&rcu_tortures[i].rtort_free) &&
@@ -2437,7 +2446,8 @@ rcu_torture_reader(void *arg)
                        torture_hrtimeout_us(500, 1000, &rand);
                        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);
                stutter_wait("rcu_torture_reader");
        } while (!torture_must_stop());