Re: [PATCH v2 2/5] scftorture: Reject empty workloads before starting helpers
From: Paul E. McKenney
Date: Mon Nov 09 2026 - 19:18:42 EST
On Sun, Nov 08, 2026 at 07:02:38PM -0500, Joel Fernandes wrote:
> A module loaded with nthreads=0 starts its statistics task, but cleanup
> skips stopping that task. Unloading the module then leaves it executing
> freed module text. Reject a zero thread count before starting helpers;
> negative counts still select the online CPU count.
>
> Also, when built as a module with reschedule-only, this leaves the
> selector empty because resched_cpu() is unavailable to modules. It warns
> while selecting an operation, invokes no callbacks, and can nevertheless
> report SUCCESS. Reject an empty effective selector after filtering
> unsupported operations.
>
> Both failures were reproduced in a guest without the patches.
>
> Signed-off-by: Joel Fernandes <joelagnelf@xxxxxxxxxx>
Reviewed-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
If you wish, you could split this into two commits, but your call.
Thanx, Paul
> ---
> kernel/scftorture.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/kernel/scftorture.c b/kernel/scftorture.c
> index 603b2dba1536..ff9a8271a464 100644
> --- a/kernel/scftorture.c
> +++ b/kernel/scftorture.c
> @@ -588,6 +588,12 @@ static int __init scf_torture_init(void)
>
> scftorture_print_module_parms("Start of test");
>
> + if (!nthreads) {
> + SCFTORTOUT_ERRSTRING("nthreads must be nonzero");
> + firsterr = -EINVAL;
> + goto unwind;
> + }
> +
> if (weight_resched <= 0 &&
> weight_single <= 0 && weight_single_rpc <= 0 && weight_single_wait <= 0 &&
> weight_many <= 0 && weight_many_wait <= 0 &&
> @@ -636,6 +642,11 @@ static int __init scf_torture_init(void)
> scf_sel_add(weight_many_wait1, SCF_PRIM_MANY, true);
> scf_sel_add(weight_all1, SCF_PRIM_ALL, false);
> scf_sel_add(weight_all_wait1, SCF_PRIM_ALL, true);
> + if (!scf_sel_array_len) {
> + SCFTORTOUT_ERRSTRING("no supported operations selected");
> + firsterr = -EINVAL;
> + goto unwind;
> + }
> scf_sel_dump();
>
> if (onoff_interval > 0) {
> --
> 2.54.0
>