Re: [PATCH v10 31/40] selftests/sched: Test deadline boosts in deadline_bw_test
From: sashiko-bot
Date: Fri Nov 20 2026 - 16:09:06 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/sched: hang in requeue_pi_new_period() error path on
FUTEX_WAKE
- [Low] selftests/sched: deadlock in deboost_out_asleep_after_refill()
error path
--
commit 27cfa3f823b3f1e4dfbcad5af492394f2bdb22ea
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
selftests/sched: Test deadline boosts in deadline_bw_test
This commit adds ten test cases to deadline_bw_test covering SCHED_DEADLINE
priority inheritance boosts, deboosts, runtime refills, and lock waiter
ordering.
> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> index cf3b49cf2be28..7925623ed1da7 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
[ ... ]
> @@ -1939,6 +2066,664 @@ static int deboost_keeps_own_runtime(void)
[ ... ]
> +static void *asleep_donor(void *arg)
> +{
> + struct timespec ts;
> + int err;
> +
> + aslp_donor_tid = gettid_();
> + err = set_deadline(0, NSEC_PER_MSEC, NSEC_PER_SEC);
> + sem_post(&aslp_donor_ready);
> + if (err) {
> + ksft_print_msg("the donor refused as a deadline task: %s\n", strerror(-err));
> + sem_post(&aslp_donor_out);
> + return (void *)1;
> + }
> + if (sem_wait_for(&aslp_owner_locked, 5000)) {
> + ksft_print_msg("the owner did not take the lock\n");
> + sem_post(&aslp_donor_out);
> + return (void *)1;
> + }
> + clock_gettime(CLOCK_REALTIME, &ts);
> + ts.tv_nsec += 200 * 1000000L;
> + ts.tv_sec += ts.tv_nsec / 1000000000L;
> + ts.tv_nsec %= 1000000000L;
> + aslp_donor_locking = 1;
> + err = pthread_mutex_timedlock(&pi_lock, &ts);
> + sem_post(&aslp_donor_out);
> + sem_wait_sig(&aslp_read_done);
[ ... ]
> +static int deboost_out_asleep_after_refill(void)
> +{
[ ... ]
> + if (pthread_create(&d, NULL, asleep_donor, NULL)) {
> + ksft_print_msg("the donor thread could not start\n");
> + return KSFT_FAIL;
> + }
> + if (sem_wait_for(&aslp_donor_ready, 5000)) {
> + ksft_print_msg("the donor is not ready\n");
> + sem_post(&aslp_owner_locked);
> + join(d);
> + return KSFT_FAIL;
> + }
> + base = total_bw_of(top_cpu(1)); /* with D, without O */
> + if (pthread_create(&o, NULL, asleep_owner, NULL)) {
> + ksft_print_msg("the owner thread could not start\n");
> + sem_post(&aslp_owner_locked);
> + join(d);
> + return KSFT_FAIL;
> + }
[Severity: Low]
Will join(d) hang on these two error paths if aslp_read_done is not
posted? Posting aslp_owner_locked wakes asleep_donor(), which then takes
pi_lock and blocks in sem_wait_sig(&aslp_read_done).
[ ... ]
> +static void *rq_w(void *arg)
> +{
> + long ret;
> +
> + rq_w_tid = gettid_();
> + ret = syscall(SYS_futex, &rq_cond, FUTEX_WAIT_REQUEUE_PI | FUTEX_PRIVATE_FLAG,
> + 0, NULL, &rq_pi, 0);
> + if (ret) {
> + ksft_print_msg("FUTEX_WAIT_REQUEUE_PI: %s\n", strerror(errno));
> + return (void *)1;
> + }
> + rq_w_rank = rq_order++;
> + rq_pi_unlock();
> + if (set_other(0))
> + ksft_print_msg("W cannot leave SCHED_DEADLINE\n");
> + return NULL;
> +}
[ ... ]
> +static int requeue_pi_new_period(void)
> +{
[ ... ]
> +out:
> + rq_pi_unlock();
> + if (ret != KSFT_PASS) {
> + /* Let W go if it was not requeued. */
> + rq_cond = 1;
> + syscall(SYS_futex, &rq_cond, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
> + 1, NULL, NULL, 0);
> + }
> + if (have_x && pthread_join(x, &x_ret))
> + ret = KSFT_FAIL;
> + if (pthread_join(w, &w_ret))
> + ret = KSFT_FAIL;
[Severity: Low]
Does FUTEX_WAKE wake W when it is sleeping in FUTEX_WAIT_REQUEUE_PI on
rq_cond? In the kernel, futex_wake() rejects waiters that have
rt_waiter set with -EINVAL without waking them:
kernel/futex/waitwake.c:futex_wake() {
...
if (this->pi_state || this->rt_waiter) {
ret = -EINVAL;
break;
}
...
}
If an earlier setup step such as set_deadline() fails before W is
requeued, W stays asleep on rq_cond and pthread_join(w, &w_ret) hangs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795207232.git.mathieu.desnoyers@xxxxxxxxxxxx?part=31