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 26/39] selftests/sched: Test the root domain of a task in deadline_bw_test
Date: Thu, 03 Dec 2026 17:25:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-248256@kernel.org> (raw)
In-Reply-To: <008cb3bfa7b0e6e390a5b96a12c95dd6be8660d1.1796296313.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 11 potential
issues to consider:
- [Low] selftests/sched: stack buffer overflow in rebuild_record_taken()
- [Low] selftests/sched: unchecked buffer truncation in
partition_invalidate_refused()
- [Low] selftests/sched: unclosed ack[1] pipe end hangs two partition
tests
- [Low] selftests/sched: inverted tell flag in partition_swap_accepted()
- [Low] selftests/sched: unpinned migration window causes flaky
deadline_bw_test cases
- [Low] selftests/sched: silent or misleading KSFT_SKIP returns in
deadline_bw_test
- [Low] selftests/sched: wrong isolcpus count comment and cs_setup()
duplication
- [Low] selftests/sched: missing ext_switched_all() check before hotplug
with server
- [Low] selftests/sched: woken_on() accepts negative task_cpu_of() error
as valid CPU
- [Low] selftests/sched: no_admission_affinity_moves() restores sysctl
before 0-lag
- [Low] selftests/sched: hotplug_no_admission_pinned() restores sysctl
before 0-lag
--
commit 771f314a11047ea4b849341ab0c81a8587315b6a
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
selftests/sched: Test the root domain of a task in deadline_bw_test
This commit adds 40 test cases to deadline_bw_test covering CPU hotplug,
cpuset partition changes, and root domain accounting for SCHED_DEADLINE
tasks with and without isolcpus=domain.
> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> index f50d45dd57994..8c2a2ccb3c600 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
[ ... ]
> @@ -45,7 +46,7 @@
> *
> * The test needs root, deadline admission control and 3 housekeeping
> * CPUs. Some cases need 4. Most also need the cgroup v2 cpuset
> - * controller. Some need debugfs or CPU hotplug. Five need
> + * controller. Some need debugfs or CPU hotplug. Twenty-nine need
> * isolcpus="domain" at boot.
> */
[Severity: Low]
Should this say thirty-one rather than twenty-nine, given the five existing
cases plus the 26 new cases that require isolcpus=domain?
Two other small cleanups in the added code: fallback_case() declares a local
cg_q that shadows the file-scope cg_q and duplicates the cgroup setup and
teardown from cs_setup()/cs_cleanup(); and hotplug_partition_invalid_refused()
leaves cs_n[0] non-zero if snprintf() truncates before jumping to out:,
unlike hotplug_sibling_partition_refused() which clears cs_d[0] = 0.
[ ... ]
> + snprintf(path, sizeof(path), "%s/cgroup.subtree_control", root);
> + if (read_file(path, buf, sizeof(buf)))
> + return KSFT_SKIP;
> + if (!strstr(buf, "cpuset")) {
> + if (write_file(root, "cgroup.subtree_control", "+cpuset"))
> + return KSFT_SKIP;
> + added = 1;
> + }
[Severity: Low]
Should these early KSFT_SKIP returns print a skip reason? cs_setup() also
returns -1 without logging, so the roughly 20 new cases calling it (as well
as partition_grows_child_valid() and hotplug_top_last_refused()) skip
silently when prerequisites are missing.
In addition, partition_shrink_moves_refused(),
partition_shrink_isolated_moves_refused(), partition_invalidate_refused(),
and partition_child_invalidate_refused() combine their CPU-count check with
cs_setup(), printing a misleading CPU-count message when cs_setup() fails.
Most new cases also initialize ret = KSFT_SKIP and only switch to KSFT_FAIL
after pipe(fd), so a pipe() error jumps to out: and silently skips instead
of failing.
[ ... ]
> +out:
> + reap(pid);
> + if (write_file("/proc/sys/kernel", "sched_rt_runtime_us", saved)) {
> + ksft_print_msg("admission control cannot be turned on again\n");
> + return KSFT_FAIL;
> + }
> + sleep_ns(3 * PERIOD);
[Severity: Low]
Can restoring /proc/sys/kernel/sched_rt_runtime_us before sleep_ns(3 * PERIOD)
fail with -EBUSY?
While the killed spinning task's 0-lag timer still holds its bandwidth in
dl_b->total_bw, sched_dl_global_validate() rejects the write if
new_bw * cpus < dl_b->total_bw. That returns KSFT_FAIL immediately and
leaves global admission control disabled (-1) for the remaining test cases
and after the test exits. Waiting 3 * PERIOD before restoring
sched_rt_runtime_us avoids this.
[Severity: Low]
In commit "selftests/sched: Test the root domain rebuild in deadline_bw_test"
earlier in this series, does hotplug_no_admission_pinned() have the same
ordering problem? Its out: path restores sched_rt_runtime_us immediately
after reaping the spinning 50% deadline task and before sleep_ns(3 * PERIOD),
which can fail with -EBUSY and leave admission control at -1 for all
subsequent cases.
[ ... ]
> + err = enter(cs_c, pid);
> + cpu = task_cpu_of(pid);
> + if (bw <= 0 || def != def0 || err || cpu != fb_h) {
> + ksft_print_msg("a deadline task adds %lld, %lld to total_bw, in C: %s, on CPU %d\n",
> + def - def0, bw, strerror(-err), cpu);
> + goto out;
> + }
[Severity: Low]
Can hotplug_nested_refused() fail spuriously if the child migrates off fb_h
before sleeping?
task_from() widens the child's affinity to all CPUs before calling
set_deadline() and blocking in read(), so preemption or load balancing can
move it to another CPU before it sleeps, and enter() does not migrate a
sleeping task's CPU. Unlike fallback_case(), which treats sleeping off fb_h
as KSFT_SKIP, hotplug_nested_refused(), hotplug_dead_accepted(),
partition_takes_fallback_refused(), partition_swap_refused(),
partition_refused_no_warn(), and hotplug_asleep_setattr() all return
KSFT_FAIL in that case.
[ ... ]
> + c = 'x';
> + if (enter(cs_b, pid) || write(go[1], &c, 1) != 1 || read(ack[0], &c, 1) != 1) {
> + ksft_print_msg("the task never ran in B\n");
> + goto out;
> + }
[Severity: Low]
Can read(ack[0], &c, 1) block forever if the child exits before writing to
ack[1]?
The parent keeps ack[1] open until out:, so if the child terminates early
(for example if read(go[0], &c, 1) fails and it calls _exit(1)), the kernel
never delivers EOF on ack[0] and the test hangs until the harness timeout.
hotplug_top_last_refused() has the same unclosed ack[1] before
read(ack[0], &c, 1). Closing ack[1] and go[0] in the parent right after
fork_child() avoids the hang.
[ ... ]
> + if (ic < 0 || x < 0 || !cpu_hotpluggable(x) || !server_found || cs_setup()) {
> + ksft_print_msg("needs isolcpus=\"domain\", 2 housekeeping CPUs, CPU hotplug, fair server files\n");
> + return KSFT_SKIP;
> + }
[Severity: Low]
Should hotplug_isolated_partition_falls_back() also skip when
ext_switched_all() is true, like hotplug_server() and
hotplug_server_refused()?
Because it reads server_get() and checks totals_check() across
cpu_online(x, 0), a CPU hotplug that terminates a sched_ext switch_all=1
scheduler switches accounting from ext_server back to fair_server and causes
a spurious failure.
[ ... ]
> + snprintf(buf, sizeof(buf), "%d", h2);
> + if (write_file(cs_q, "cpuset.cpus", buf) || partition_has(cs_q, "invalid", 1) ||
> + fallback_wake(fd[1], pid))
> + goto out;
[Severity: Low]
Is the tell flag in partition_has(cs_q, "invalid", 1) inverted?
partition_has() only prints cpuset.cpus.partition when the substring is
absent and tell is non-zero, so this logs a spurious message on every
passing run when Q is "root", stays silent if Q becomes invalid, and omits
checking that Q remains "root". Using !partition_has(cs_q, "root", 1) ||
partition_has(cs_q, "invalid", 0) matches the other valid-partition checks.
[ ... ]
> + /* Q has every housekeeping CPU but A, B and D. */
> + for (i = n = 0; i < ncpus - 3; i++)
> + n += snprintf(buf + n, sizeof(buf) - n, "%s%d", n ? "," : "",
> + online[i]);
[ ... ]
> + for (i = 1, n = 0; i < ncpus - 3; i++)
> + n += snprintf(buf + n, sizeof(buf) - n, "%d,", online[i]);
> + snprintf(buf + n, sizeof(buf) - n, "%d", d);
[Severity: Low]
Can these snprintf() loops overflow buf[4096] on the stack?
Because snprintf() returns the untruncated length, on a large-CPU system
where the formatted CPU list exceeds 4095 bytes, n grows past sizeof(buf)
and sizeof(buf) - n underflows size_t on the next iteration or the trailing
snprintf(), writing past buf on the stack. Guarding both loops with
n < (int)sizeof(buf) and skipping when n >= (int)sizeof(buf) (as
mask_grows_refused() does) prevents the overflow.
[ ... ]
> + cpu = task_cpu_of(pid);
> + if (want_isol ? !is_isol(cpu) : want >= 0 ? cpu != want : is_isol(cpu)) {
> + ksft_print_msg("woken on CPU %d\n", cpu);
> + return -1;
> + }
> + return 0;
[Severity: Low]
Does woken_on() accept a -1 error from task_cpu_of() as a valid housekeeping
CPU? When called with want_isol == 0 and want < 0 (as in
partition_shrink_isolated_moves_refused()), cpu == -1 makes is_isol(-1)
return 0, so woken_on() returns 0 instead of -1. Checking cpu < 0 first
avoids this.
[ ... ]
> + for (i = 0; i < ncpus && n < (int)sizeof(buf); i++)
> + n += snprintf(buf + n, sizeof(buf) - n, "%s%d", i ? "," : "", online[i]);
> + for (i = 0; i < nisol && n < (int)sizeof(buf); i++)
> + n += snprintf(buf + n, sizeof(buf) - n, ",%d", isol[i]);
> + err = write_file(cs_q, "cpuset.cpus", buf);
[Severity: Low]
Should partition_invalidate_refused() check n >= (int)sizeof(buf) before
calling write_file()?
On a host with roughly 540 or more online CPUs, the formatted CPU list
truncates at 2048 bytes and write_file() receives a partial or malformed
list, causing a spurious KSFT_FAIL instead of skipping.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796296313.git.mathieu.desnoyers@efficios.com?part=26
next prev parent reply other threads:[~2026-12-03 17:25 UTC|newest]
Thread overview: 50+ 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 [this message]
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 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 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 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 14:58 ` [PATCH v14 36/39] sched/deadline: Keep a reaped deadline task in a rebuild Mathieu Desnoyers
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 14:58 ` [PATCH v14 38/39] selftests/sched: Test PI against hotplug and rebuilds in deadline_bw_test Mathieu Desnoyers
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-248256@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