Re: [PATCH v14 14/39] selftests/sched: Test the root domain rebuild in deadline_bw_test

From: sashiko-bot

Date: Thu Dec 03 2026 - 11:10:16 EST


Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] selftests/sched: new hotplug cases skip ext_switched_all()
guard
- [Medium] selftests/sched: unchecked probe(NULL) errors and headroom in
new cases
- [Medium] selftests/sched: hotplug_no_admission_pinned() lacks sysctl
restore retry
- [Low] selftests/sched: open-coded bandwidth ratio instead of bw_of()
--

commit 4704c1b4ece058292b4a960cd1fa4ee1620d2f70
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

selftests/sched: Test the root domain rebuild in deadline_bw_test

This commit adds seven test cases to deadline_bw_test covering root domain
accounting rebuilds during CPU hotplug, zombie deadline tasks, departed
priority-inheritance owners, and sched_setaffinity() racing with
sched_setattr().

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
> index 6ff9da9644030..ba2a18f354d44 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c

[ ... ]

> +static int hotplug_sleeper_switched(void)
> +{
> + int base = probe(NULL), base_off, after, cpu, ret = KSFT_PASS;
> + pid_t pid;
> +
> + if (cpu_online(hp_cpu, 0)) {
> + ksft_print_msg("CPU %d cannot go offline\n", hp_cpu);
> + cpu_up(hp_cpu);
> + return KSFT_SKIP;
> + }
> + base_off = probe(NULL);

[Severity: Medium]
Can unchecked probe(NULL) errors cause false passes or wrong skips here?

probe(NULL) returns -1 on internal failure, such as disabled admission
control hitting the thread limit. Because hotplug_sleeper_switched(),
hotplug_no_admission_pinned(), and affinity_vs_setattr() never check for
< 0, repeated -1 returns compare equal and report KSFT_PASS.

In hotplug_sleepers() and hotplug_departed(), a -1 return falls into the
insufficient-room check and reports KSFT_SKIP instead of KSFT_FAIL.

Separately, hotplug_sleeper_switched() omits a base_off < 3 check for its
30% sleeper, and hotplug_departed() checks base_off <= 0 instead of
base_off < 4 for its 40% task. On a tight sched_rt_runtime_us,
cpu_online(..., 0) can return -EBUSY and fail instead of skipping.

[ ... ]

> +out:
> + cpu_up(hp_cpu);
> + 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: Medium]
What happens if restoring sched_rt_runtime_us fails with -EBUSY before
the killed 50% task reaches its 0-lag time?

When free headroom is under 50% (or cpu_up(hp_cpu) fails),
sched_dl_global_validate() rejects the write because dl_b->total_bw
still counts the departing task, and sched_rt_handler() rolls
sched_rt_runtime_us back to -1.

Because hotplug_no_admission_pinned() returns immediately without
sleeping 3 * PERIOD or polling with wait_for() as server_restore() does,
admission control stays permanently at -1 for the rest of hp_cases[] and
on the host after the test exits.

[ ... ]

> + bw = (ZOMBIE_RUNTIME << 20) / ZOMBIE_PERIOD; /* as to_ratio() */

[Severity: Low]
This isn't a bug, but both death_zombie_hotplug() and pi_departed_moved()
open-code this ratio instead of reusing the existing
bw_of(ZOMBIE_RUNTIME, ZOMBIE_PERIOD) helper.

[ ... ]

> @@ -4790,6 +5429,7 @@ static const struct p_case {
> { "death_pi_deadline_owner", death_pi_deadline_owner, MEASURED_IN_P },
> { "death_group", death_group, MEASURED_IN_P },
> { "death_zombie_switched", death_zombie_switched, FROM_OUTSIDE },
> + { "death_zombie_hotplug", death_zombie_hotplug, FROM_OUTSIDE },
> { "yield_switched_out", yield_switched_out, IN_P },
> { "yield_killed", yield_killed, MEASURED_IN_P },
> { "overrun_caught", overrun_caught, IN_P },
> @@ -4808,9 +5448,15 @@ static const struct p_case {
> static const struct hp_case {
> const char *name;
> int (*fn)(void);
> + int no_hp; /* takes no CPU offline */
> } hp_cases[] = {
> + { "hotplug_sleepers", hotplug_sleepers },
> + { "hotplug_sleeper_switched", hotplug_sleeper_switched },
> + { "hotplug_no_admission_pinned", hotplug_no_admission_pinned },
> { "hotplug_refused", hotplug_refused },
> + { "hotplug_departed", hotplug_departed },
> { "hotplug_server", hotplug_server },
> + { "affinity_vs_setattr", affinity_vs_setattr, 1 },
> };

[Severity: Medium]
Should death_zombie_hotplug() and the four new hotplug cases in
hp_cases[] skip when ext_switched_all() is true, as hotplug_server()
does?

With a full-mode sched_ext scheduler lacking ops.cpu_offline, offlining a
CPU exits the scheduler in handle_hotplug() and detaches ext_server in
favor of fair_server.

Because server_init() latches server_dir to ext_server once at startup,
the later server_* cases in p_cases[] (and hotplug_server(), whose own
ext_switched_all() guard then returns 0) write to the detached ext_server
and fail.

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