2023-11-21 01:03:18

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [RFC PATCH 60/86] treewide: torture: remove cond_resched()

On Tue, Nov 07, 2023 at 03:07:56PM -0800, Ankur Arora wrote:
> Some cases changed to cond_resched_stall() to avoid changing
> the behaviour of the test too drastically.
>
> Cc: Davidlohr Bueso <[email protected]>
> Cc: "Paul E. McKenney" <[email protected]>
> Cc: Josh Triplett <[email protected]>
> Cc: Frederic Weisbecker <[email protected]>
> Signed-off-by: Ankur Arora <[email protected]>

Given lazy preemption, I am OK with dropping the cond_resched()
invocations from the various torture tests.

Reviewed-by: Paul E. McKenney <[email protected]>

> ---
> kernel/rcu/rcuscale.c | 2 --
> kernel/rcu/rcutorture.c | 8 ++++----
> kernel/scftorture.c | 1 -
> kernel/torture.c | 1 -
> 4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
> index ffdb30495e3c..737620bbec83 100644
> --- a/kernel/rcu/rcuscale.c
> +++ b/kernel/rcu/rcuscale.c
> @@ -672,8 +672,6 @@ kfree_scale_thread(void *arg)
> else
> kfree_rcu(alloc_ptr, rh);
> }
> -
> - cond_resched();
> } while (!torture_must_stop() && ++loop < kfree_loops);
>
> if (atomic_inc_return(&n_kfree_scale_thread_ended) >= kfree_nrealthreads) {
> diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> index ade42d6a9d9b..158d58710b51 100644
> --- a/kernel/rcu/rcutorture.c
> +++ b/kernel/rcu/rcutorture.c
> @@ -81,7 +81,7 @@ torture_param(int, fqs_stutter, 3, "Wait time between fqs bursts (s)");
> torture_param(int, fwd_progress, 1, "Number of grace-period forward progress tasks (0 to disable)");
> torture_param(int, fwd_progress_div, 4, "Fraction of CPU stall to wait");
> torture_param(int, fwd_progress_holdoff, 60, "Time between forward-progress tests (s)");
> -torture_param(bool, fwd_progress_need_resched, 1, "Hide cond_resched() behind need_resched()");
> +torture_param(bool, fwd_progress_need_resched, 1, "Hide cond_resched_stall() behind need_resched()");
> torture_param(bool, gp_cond, false, "Use conditional/async GP wait primitives");
> torture_param(bool, gp_cond_exp, false, "Use conditional/async expedited GP wait primitives");
> torture_param(bool, gp_cond_full, false, "Use conditional/async full-state GP wait primitives");
> @@ -2611,7 +2611,7 @@ static void rcu_torture_fwd_prog_cond_resched(unsigned long iter)
> return;
> }
> // No userspace emulation: CB invocation throttles call_rcu()
> - cond_resched();
> + cond_resched_stall();
> }
>
> /*
> @@ -2691,7 +2691,7 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *rfp,
> udelay(10);
> cur_ops->readunlock(idx);
> if (!fwd_progress_need_resched || need_resched())
> - cond_resched();
> + cond_resched_stall();
> }
> (*tested_tries)++;
> if (!time_before(jiffies, stopat) &&
> @@ -3232,7 +3232,7 @@ static int rcu_torture_read_exit(void *unused)
> errexit = true;
> break;
> }
> - cond_resched();
> + cond_resched_stall();
> kthread_stop(tsp);
> n_read_exits++;
> }
> diff --git a/kernel/scftorture.c b/kernel/scftorture.c
> index 59032aaccd18..24192fe01125 100644
> --- a/kernel/scftorture.c
> +++ b/kernel/scftorture.c
> @@ -487,7 +487,6 @@ static int scftorture_invoker(void *arg)
> set_cpus_allowed_ptr(current, cpumask_of(cpu));
> was_offline = false;
> }
> - cond_resched();
> stutter_wait("scftorture_invoker");
> } while (!torture_must_stop());
>
> diff --git a/kernel/torture.c b/kernel/torture.c
> index b28b05bbef02..0c0224c76275 100644
> --- a/kernel/torture.c
> +++ b/kernel/torture.c
> @@ -747,7 +747,6 @@ bool stutter_wait(const char *title)
> while (READ_ONCE(stutter_pause_test)) {
> if (!(i++ & 0xffff))
> torture_hrtimeout_us(10, 0, NULL);
> - cond_resched();
> }
> } else {
> torture_hrtimeout_jiffies(round_jiffies_relative(HZ), NULL);
> --
> 2.31.1
>