Re: [PATCH v12 42/43] selftests/sched: Test parameter changes in deadline_bw_test

From: sashiko-bot

Date: Fri Nov 27 2026 - 13:57:46 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/sched: premature probe in measured() after
constrained task exit
--

commit 55867328ab1ab4f59bba08a621ac5a4d89b5c264
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

selftests/sched: Test parameter changes in deadline_bw_test

This commit adds 39 test cases to deadline_bw_test covering parameter
changes, priority inheritance boosts of throttled or constrained owners,
and constrained tasks re-entering SCHED_DEADLINE during their gap.

> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> index 83dd8b4e79a3d..66955952901ff 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c

[ ... ]

> @@ -2749,93 +2923,3194 @@ static int requeue_pi_new_period(void)
> return ret;
> }
>

[ ... ]

> +static void *rb2_t(void *arg)
> +{
> + uint32_t tid = gettid_();
> + int err;
> +
> + rb2_t_tid = tid;
> + err = set_constrained(0, 10 * NSEC_PER_MSEC, 20 * NSEC_PER_MSEC, 5 * PERIOD);
> + rb2_t_start = now_ns();
> + if (err) {
> + ksft_print_msg("T refused as a deadline task: %s\n", strerror(-err));
> + rb2_t_locking = -1;
> + return (void *)1;
> + }
> + spin_ns(2 * NSEC_PER_MSEC);
> + rb2_t_locking = 1;
> + if (syscall(SYS_futex, &rb2_pi, FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG,
> + 0, NULL, NULL, 0)) {
> + ksft_print_msg("FUTEX_LOCK_PI: %s\n", strerror(errno));
> + set_other(0);
> + return (void *)1;
> + }
> + rb2_t_got = now_ns();
> + if (!atomic_compare_exchange_strong(&rb2_pi, &tid, 0))
> + syscall(SYS_futex, &rb2_pi, FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG,
> + 0, NULL, NULL, 0);
> + if (set_other(0))
> + ksft_print_msg("T cannot leave SCHED_DEADLINE\n");
> + return NULL;
> +}

[Severity: Medium]
Does calling set_other(0) at the start of T's second 500ms constrained
period cause measured() to probe before T's bandwidth is released?

T is throttled in its constrained gap until t = 500ms, when dl_task_timer()
replenishes it for [500ms, 1000ms]. When T immediately calls set_other(0)
while still alive, task_non_contending() keeps the departing constrained
task's 2% bandwidth until the end of that period at t = 1000ms, and
do_exit() does not cancel inactive_timer after T has left SCHED_DEADLINE.

Because reenter_pi_blocked_in_gap() returns right after pthread_join() at
t = 500ms and measured() only waits 3 * PERIOD (300ms):

tools/testing/selftests/sched/deadline/deadline_bw_test.c:measured() {
...
ret = run_in(cg, fn);
sleep_ns(3 * PERIOD);
after = probe(cg);
...
}

probe(cg) runs at t = 800ms while T's 2% bandwidth is still counted in
total_bw, admitting 8 probe tasks of 10% instead of 9 and failing the test.
The same happens in ra_t() (for reenter_asleep_in_gap() and
reenter_asleep_late_in_gap()) and in ob_owner() (for
pi_owner_asleep_in_gap() and pi_owner_wakes_in_gap_later(), where
drop_pi_lock() deboosts and throttles O in its gap until t = 500ms before
set_other(0)). Waiting for the next period before returning (as
reenter_runnable_in_gap() does) or letting the thread exit without calling
set_other(0) first would avoid the premature probe.

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