Re: [PATCH v8 18/33] selftests/sched: Test the root domain of a task in deadline_bw_test
From: sashiko-bot
Date: Thu Nov 19 2026 - 15:27:27 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/sched: missing 0-lag sleep on goto out in
hotplug_dead_accepted()
--
commit 18c7a84e3237184ed7ce53936729cf7fbe932760
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
selftests/sched: Test the root domain of a task in deadline_bw_test
This commit adds 24 test cases to deadline_bw_test covering how a deadline
task stays in the root domain that accounts for its bandwidth across CPU
hotplug and cpuset changes.
> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> index fa1ff62d6f42f..a290e332831d6 100644
> --- a/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
[ ... ]
> @@ -7014,6 +7562,1368 @@ static int move_back_cpu_offline(void)
[ ... ]
> +static int hotplug_dead_accepted(void)
> +{
> + int fd[2] = { -1, -1 }, err, cpu, ret = KSFT_SKIP;
> + long long def0, hk0, def, hk;
> + uint64_t t;
> + char buf[64];
> + pid_t pid = -1;
[ ... ]
> + pid = task_from(fb_h, 1, 100 * NSEC_PER_MSEC, NSEC_PER_SEC, fd[0]);
> + if (pid < 0 || child_up("hotplug_dead_accepted", 0) ||
> + wait_for(1000, proc_state_of(pid) == 'S'))
> + goto out;
> + err = enter(cs_b, pid);
> + if (err) {
> + ksft_print_msg("a move into B refused: %s\n", strerror(-err));
> + goto out;
> + }
> + if (fallback_totals(&def, &hk))
> + goto out;
> + cpu = task_cpu_of(pid);
> + if (cpu != fb_h || def != def0 || hk <= hk0) {
> + ksft_print_msg("in B on CPU %d: total_bw %lld, %lld\n", cpu, def, hk);
> + goto out;
> + }
> + if (write(fd[1], "x", 1) != 1) {
> + ksft_print_msg("write to the deadline task: %s\n", strerror(errno));
> + goto out;
> + }
> + t = now_ns();
> + if (wait_for(1000, proc_state_of(pid) == 'Z'))
> + goto out;
> + if (now_ns() - t > 500 * NSEC_PER_MSEC) {
> + ksft_print_msg("the task took over 500ms to exit\n");
> + ret = KSFT_SKIP;
> + goto out;
> + }
> + sleep_ns(10 * NSEC_PER_MSEC); /* past do_task_dead() */
> + err = cpu_online(fb_h, 0);
> + if (err) {
> + ksft_print_msg("offline of CPU %d under a dead task: %s\n", fb_h,
> + strerror(-err));
> + goto out;
> + }
> + reap(pid);
> + pid = -1;
> + cpu_up(fb_h);
> + sleep_ns(NSEC_PER_SEC); /* past the 0-lag time */
> + ret = totals_check("task gone", fb_i2, fb_h, def0, hk0);
> +out:
> + reap(pid);
> + cpu_up(fb_h);
> + if (fd[0] >= 0) {
> + close(fd[0]);
> + close(fd[1]);
> + }
> + cs_cleanup();
> + return ret;
> +}
[Severity: Low]
Does jumping to out after the 1-second-period deadline task has run (such
as on the 500ms exit-time KSFT_SKIP path or if cpu_online() fails) return
before the task's 0-lag time expires?
Because hp_cases[] run sequentially without rebuilding root domain
accounting, the dead task's bandwidth remains in the housekeeping root
domain's total_bw when the next test case reads its initial baseline hk0,
causing a false failure once the 0-lag timer fires during that test.
Moving sleep_ns(NSEC_PER_SEC) after reap(pid) and cpu_up(fb_h) in the out
block would wait out the 0-lag time on skip and error paths as well.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795116790.git.mathieu.desnoyers@xxxxxxxxxxxx?part=18