From: sashiko-bot@kernel.org
To: "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>
Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org,
hannes@cmpxchg.org, mkoutny@suse.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v14 33/39] selftests/sched: Test parameter changes in deadline_bw_test
Date: Thu, 03 Dec 2026 17:56:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-248315@kernel.org> (raw)
In-Reply-To: <79fec47f037759dc9473351f7f718bb6f570a6a0.1796296313.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 9 potential
issues to consider:
- [Medium] selftests/sched: run_p_cases() skips debt wait without
debugfs
- [Low] selftests/sched: reenter_runnable_in_gap() 2ms window races with
SCHED_OTHER
- [Low] selftests/sched: reenter_pi_blocked_in_gap() fails instead of
skipping ENOSYS
- [Low] selftests/sched: constrained_after_job() fails instead of
skipping on EBUSY
- [Low] selftests/sched: params_swap_overload() uses unchecked zero t0
on stall
- [Low] selftests/sched: timeout checked before syscall error in
params_return_full()
- [Low] selftests/sched: ignored negative error from probe() in
params_return_full()
- [Low] selftests/sched: stale exited TID used on admission error in
deadline_bw_test
- [Low] selftests/sched: redundant sched/debug scans and 40s waits in
run_p_cases()
--
commit 35a6d94959219214223fe0bdf45f6150f74deca4
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
selftests/sched: Test parameter changes in deadline_bw_test
This commit adds 25 test cases to deadline_bw_test covering SCHED_DEADLINE
parameter changes, constrained-deadline gap re-entry, and bandwidth
retention, and adds post-case bandwidth drain waits in run_p_cases().
> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> index dbe0de739e476..58ec444cf1bbf 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
[ ... ]
> @@ -1455,6 +1477,82 @@ static int params_refused(void)
[ ... ]
> + err = set_other(t_tid);
> + if (!err)
> + err = set_deadline(t_tid, 60 * NSEC_PER_MSEC, PERIOD);
> + slept = now_ns() - rt_t_slept;
> + if (slept > 15 * NSEC_PER_MSEC) {
> + /* Too late: the 0-lag time may have passed. */
> + ksft_print_msg("T switched back %llums after it slept\n",
> + (unsigned long long)(slept / NSEC_PER_MSEC));
> + ret = KSFT_SKIP;
> + } else if (err) {
> + ksft_print_msg("T refused back as a deadline task: %s\n", strerror(-err));
> + ret = KSFT_FAIL;
> + }
[Severity: Low]
Should err be checked before slept > 15 * NSEC_PER_MSEC here?
Passing T's 0-lag time releases its old 60% bandwidth, so a late switch can
only make a zero err inconclusive. A non-zero err (such as -EBUSY on a
kernel without the fix) is still a real failure, but checking slept first
downgrades it to KSFT_SKIP whenever jitter pushes slept past 15ms.
> + if (ret == KSFT_PASS && probe(NULL) >= 6) {
> + ksft_print_msg("P has room for two tasks of 60%%\n");
> + ret = KSFT_SKIP;
> + }
[Severity: Low]
What happens if probe(NULL) fails and returns -1 here?
-1 >= 6 is false, so a probe() error falls through as KSFT_PASS without
verifying that P lacks room for two 60% tasks. Capturing the return value
and handling < 0 (as measured() does) would avoid masking probe failures.
[ ... ]
> @@ -1867,169 +1966,1833 @@ static void *refill_owner(void *arg)
[ ... ]
> + shrink_tid = gettid_();
> + err = set_deadline(0, 10 * NSEC_PER_MSEC, PERIOD);
> + t0 = now_ns();
> + shrink_t0 = t0;
> + sem_post(&shrink_ready);
> + if (err) {
> + ksft_print_msg("T refused as a deadline task: %s\n", strerror(-err));
> + return (void *)1;
> + }
[Severity: Low]
Can wake_after_deadline_shrunk() operate on a stale TID when set_deadline()
fails in shrink_t()?
shrink_t() posts shrink_ready and exits immediately on error without
recording an error flag, which autoreaps the thread and releases shrink_tid
before pthread_join(). wake_after_deadline_shrunk() then sleeps until
105ms and calls proc_state_of(shrink_tid) and
set_constrained(shrink_tid, ...) on the exited TID. The same pattern
appears in widen_t()/deadline_widened_asleep(), shorten_t()/shorten_case(),
and flip_t()/params_flip_no_gain(); storing err before sem_post() and
aborting early (as pr_h() and vic_b() do) would avoid it.
[ ... ]
> +static void *cmix_a(void *arg)
> +{
> + int err = set_deadline(0, 15 * NSEC_PER_MSEC, PERIOD);
> +
> + if (err) {
> + ksft_print_msg("A refused as a deadline task: %s\n", strerror(-err));
> + cmix_stop = 1;
> + sem_post(&cmix_go);
> + return (void *)1;
> + }
[Severity: Low]
Should constrained_after_job() return KSFT_SKIP instead of KSFT_FAIL when
cmix_a() or cmix_b() gets -EBUSY?
Together with the 5% fair server, B (75%) and A (15%) require the full 95%
default admission limit. On systems where sched_rt_runtime_us is lower or
the fair/ext server reserves more than 5%, set_deadline() returns -EBUSY,
which currently fails the test rather than skipping as
params_swap_overload() does.
[ ... ]
> + 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;
> + }
[Severity: Low]
Should reenter_pi_blocked_in_gap() skip on ENOSYS and wake the main thread
immediately if FUTEX_LOCK_PI fails?
Unlike the other PI cases, this one bypasses pi_init() and invokes
FUTEX_LOCK_PI directly, which returns -ENOSYS when CONFIG_FUTEX_PI is
disabled. Because rb2_t() returns without setting rb2_t_locking negative,
the main thread stalls for the full 1s wait_for() timeout and returns
KSFT_FAIL instead of KSFT_SKIP.
[ ... ]
> + while (!rr_stop) {
> + uint64_t t = now_ns(), b = rr_back_at;
> +
> + if (b && !rr_t_ran && t > b + 2 * NSEC_PER_MSEC)
> + rr_t_ran = t;
> + }
[ ... ]
> + /* Store it before the switch back. A T given a new period runs at once. */
> + rr_back_at = now_ns();
> + err = set_constrained(rr_t_tid, 10 * NSEC_PER_MSEC, 20 * NSEC_PER_MSEC, 5 * PERIOD);
[Severity: Low]
Can the 2ms grace window in rr_t() expire while T is still running as
SCHED_OTHER, causing a false failure in reenter_runnable_in_gap()?
Both threads share P's single CPU, and T is already runnable as SCHED_OTHER
when rr_back_at is published:
reenter_runnable_in_gap()
set_other(rr_t_tid)
rr_back_at = now_ns()
<preempted by rr_t as SCHED_OTHER>
spins for > 2ms (e.g. EEVDF slice or HZ=250/HZ=100 tick)
rr_t_ran = t <-- recorded while SCHED_OTHER
set_constrained(rr_t_tid, ...)
On systems with 4+ CPUs (where the EEVDF base slice exceeds 2ms) or
HZ=250/HZ=100 kernels, T can run past b + 2ms before set_constrained()
takes effect. Checking sched_getscheduler(0) == SCHED_DEADLINE before
recording rr_t_ran would avoid the race.
[ ... ]
> @@ -5937,6 +7832,144 @@ static int params_waking(void)
[ ... ]
> + while (!err && (t = now_ns()) < start + SW_SETTLE + SW_WINDOW) {
> + if (!t0 && t >= start + SW_SETTLE) {
> + t0 = t;
> + cpu0[0] = sw_state[2];
> + cpu0[1] = sw_state[3];
> + }
[ ... ]
> + t1 = now_ns();
> + used[0] = sw_state[2] - cpu0[0];
> + used[1] = sw_state[3] - cpu0[1];
> + if (err) {
> + ksft_print_msg("a change refused: %s\n", strerror(-err));
> + goto out;
> + }
> + if (100000 * (used[0] + used[1]) >= SW_MAX_SHARE * (long long)(t1 - t0)) {
[Severity: Low]
What if the main process stalls past start + SW_SETTLE + SW_WINDOW before
any loop iteration sets t0?
The loop exits with t0 still 0, so t1 - t0 becomes total monotonic uptime
since boot. That inflates the denominator and lets the test silently pass
without measuring the window (and can overflow signed long long if uptime
exceeds ~3.4 years). Checking !t0 || t1 <= t0 and skipping or failing
would catch this.
[ ... ]
> @@ -11250,6 +13319,12 @@ static void run_p_cases(void)
> }
> for (i = 0; i < N_P_CASES; i++) {
> const struct p_case *c = &p_cases[i];
> + long long bw0 = total_bw_of(top_cpu(1));
> + long this0[3];
> + int k;
> +
> + for (k = 0; k < 3; k++)
> + this0[k] = this_bw_of(top_cpu(k + 1));
>
> if (ok && make_p()) {
> remove_p();
[ ... ]
> @@ -11269,6 +13344,34 @@ static void run_p_cases(void)
> ret = c->fn();
> remove_p();
> server_restore();
> + /*
> + * A task of the case can keep its bandwidth counted after it
> + * exits: until its 0-lag time, or until its debt is repaid. Wait
> + * for that, so that the next case starts from the same total_bw.
> + * A lower total_bw also ends the wait. Bandwidth lost by a case
> + * would never come back, and the wait would then cost the whole
> + * 10s.
> + */
> + if (bw0 >= 0 &&
> + wait_for_step(10000, 10 * NSEC_PER_MSEC,
> + total_bw_of(top_cpu(1)) <= bw0))
> + ksft_print_msg("%s: total_bw %lld after the case, %lld before\n",
> + c->name, total_bw_of(top_cpu(1)), bw0);
> + /*
> + * this_bw can stay higher than total_bw shows. A task moved to
> + * another cpuset while it sleeps leaves its bandwidth in the
> + * this_bw of its old CPU until it wakes up or dies. Wait for
> + * the three CPUs that random_mix() checks.
> + */
> + for (k = 0; k < 3; k++) {
> + int cpu = top_cpu(k + 1);
> +
> + if (this0[k] >= 0 &&
> + wait_for_step(10000, 10 * NSEC_PER_MSEC,
> + this_bw_of(cpu) <= this0[k]))
> + ksft_print_msg("%s: this_bw of CPU %d %ld after the case, %ld before\n",
> + c->name, cpu, this_bw_of(cpu), this0[k]);
> + }
> report(c->name, ret);
> }
[Severity: Medium]
Does skipping these post-case waits when debugfs is unavailable still leave
random_mix() failing after params_swap_overload()?
total_bw_of() and this_bw_of() both return -1 without
/sys/kernel/debug/sched/debug, so both wait loops are bypassed completely.
params_swap_overload() runs right before random_mix() and exits while its
reaped children still carry multi-second 0-lag debt on P's CPU; when
random_mix() falls back to admission-only checks without debugfs,
probe(cg_p) measures a depressed base_p before the debt drains, and
admits_in() fails once the debt expires mid-test.
[Severity: Low]
Can these pre- and post-case sched/debug reads be combined into a single
pass and guarded by ok?
Right now run_p_cases() does four separate full scans of
/sys/kernel/debug/sched/debug per case even when !ok causes all cases to
skip, and each scan walks every thread on every CPU up to top_cpu(1..3).
After each case, the four sequential 10s wait loops can also stall up to
40s (4,000 full scans) on a leaking case, risking the 600s kselftest
timeout; polling all four values in one pass inside a single wait loop
would avoid both.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796296313.git.mathieu.desnoyers@efficios.com?part=33
next prev parent reply other threads:[~2026-12-03 17:56 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:58 [PATCH v14 00/39] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 01/39] sched/deadline: Hold a reference on the deadline donor of a boosted task Mathieu Desnoyers
2026-12-03 15:44 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 02/39] sched/deadline: Replenish a throttled task boosted while asleep Mathieu Desnoyers
2026-12-03 15:29 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 03/39] sched/deadline: Do not truncate a bandwidth to 32 bits in __dl_add/sub() Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 04/39] sched/deadline: Count the 0-lag time from the next period Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 05/39] sched/deadline: Clear dl_overrun under the rq lock Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 06/39] sched/deadline: Admit a returning task without the bandwidth it holds Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 07/39] sched/deadline: Leave an active task alone in the inactive timer Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 08/39] sched/deadline: Keep the deadline of a departed constrained task Mathieu Desnoyers
2026-12-03 15:45 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 09/39] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-12-03 15:49 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 10/39] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-12-03 15:57 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 11/39] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 12/39] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-12-03 16:20 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 13/39] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-12-03 16:10 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 14/39] selftests/sched: Test the root domain rebuild in deadline_bw_test Mathieu Desnoyers
2026-12-03 16:10 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 15/39] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 16/39] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-12-03 16:22 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 17/39] sched: Make deadline policy and affinity changes wait for a cpuset attach Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 18/39] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 19/39] cgroup/cpuset: Reserve the bandwidth in the root domain a task moves to Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 20/39] selftests/sched: Test cpuset moves in deadline_bw_test Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 21/39] sched/deadline: Make a rebuild count a task in the root domain it runs in Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 22/39] sched/deadline: Move a task's bandwidth to " Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 23/39] sched/deadline: Keep a task in the root domain that counts its bandwidth Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 24/39] sched/deadline: Keep the last CPU a task has in its root domain Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 25/39] cgroup/cpuset: Refuse to take a deadline task out of " Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 26/39] selftests/sched: Test the root domain of a task in deadline_bw_test Mathieu Desnoyers
2026-12-03 17:25 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 27/39] sched/deadline: Count only active CPUs when spreading extra_bw Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 28/39] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-12-03 17:39 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 29/39] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 30/39] sched/deadline: Check the runtime of a task that comes back runnable Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 31/39] sched/deadline: Record the start of the period Mathieu Desnoyers
2026-12-03 17:42 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 32/39] sched/deadline: Keep the debt of a task across a change of parameters Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 33/39] selftests/sched: Test parameter changes in deadline_bw_test Mathieu Desnoyers
2026-12-03 17:56 ` sashiko-bot [this message]
2026-12-03 14:58 ` [PATCH v14 34/39] sched/deadline: Count a task that departs while a rebuild walks the tasks Mathieu Desnoyers
2026-12-03 14:58 ` [PATCH v14 35/39] sched/deadline: Count again a departed task that a boost brings back Mathieu Desnoyers
2026-12-03 18:01 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 36/39] sched/deadline: Keep a reaped deadline task in a rebuild Mathieu Desnoyers
2026-12-03 18:14 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 37/39] sched/deadline: Warn when a runqueue keeps the bandwidth of a task Mathieu Desnoyers
2026-12-03 18:05 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 38/39] selftests/sched: Test PI against hotplug and rebuilds in deadline_bw_test Mathieu Desnoyers
2026-12-03 18:07 ` sashiko-bot
2026-12-03 14:58 ` [PATCH v14 39/39] selftests/sched: Share the helpers of the deadline tests Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-248315@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox