Re: [PATCH v3 17/17] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting

From: sashiko-bot

Date: Thu Nov 19 2026 - 09:22:58 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/sched: dead code and unused variables in
deadline_bw_test
--

commit 6221c4626318f0c62cd5eec65b1e903934d1d349
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting

This commit adds the deadline_bw_test kselftest to verify SCHED_DEADLINE
bandwidth accounting across priority inheritance, parameter changes,
cpuset moves, task deaths, deadline servers, and CPU hotplug.

Link: https://github.com/jlelli/sched-deadline-tests

> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> new file mode 100644
> index 0000000000000..f91eeddceba18
> --- /dev/null
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
[ ... ]
> +/* The same, for a task that leaves and comes back while it sleeps. */
> +static int return_asleep_new_params(void)
> +{
> + return return_case(1);
> +}
> +
> +static pthread_mutex_t pi_lock2;
> +static sem_t holder_go;
> +static atomic_int holder_holds, chain_waits, donor_done, x_waits, l2_takes;
> +static atomic_int chain_rank, x_rank;
> +static _Atomic pid_t x_tid, fair_tid;
[ ... ]
> + ncpus = read_online(&online, 0);
> + nisol = read_online(&isol, 1);
> + if (ncpus < 0 || nisol < 0)
> + ksft_exit_fail_msg("the online CPUs cannot be read\n");

[Severity: Low]
Several test modes and static variables in deadline_bw_test.c are never
used:

- return_case() and returner() implement modes 0 through 5 (including
calls to set_constrained() in modes 4 and 5), but return_case() is only
called with mode 1 in return_asleep_new_params().
- deboost_case() and deboosted_owner() implement modes 1 and 2, but
deboost_case() is only called with mode 0 in deboost_resets_period().
- refill_case() checks for spin_ms == 8, but is only called with 1 in
deboost_keeps_own_runtime().
- pi_asleep() and sleeping_owner() implement was_dl != 0 branches, but all
callers pass 0.
- fair_tid is only assigned 0 in pi_init_lock2(), sleeper_cpu stays at -1
(making the sleeper_cpu >= 0 block in dl_sleeper_tid() unreachable), and
isol and nisol are populated in main() via read_online(&isol, 1) and
never used or freed.
- MV_YIELDED in mover(), struct hp_case::no_hp, and the forward
declarations of wait_spinner(), hold(), and release_held() are unused.

Were these extra modes meant to be wired into p_cases[], or should the
unused code be dropped?

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795092090.git.mathieu.desnoyers@xxxxxxxxxxxx?part=17