Linux real-time development
 help / color / mirror / Atom feed
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 14/39] selftests/sched: Test the root domain rebuild in deadline_bw_test
Date: Thu, 03 Dec 2026 16:10:08 +0000	[thread overview]
Message-ID: <sashiko-outbox-248179@kernel.org> (raw)
In-Reply-To: <7cc515df44c4d54245ab5c3427cb3a7a3bee04b1.1796296313.git.mathieu.desnoyers@efficios.com>

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@efficios.com>

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@efficios.com?part=14

  reply	other threads:[~2026-12-03 16:10 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 [this message]
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
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-248179@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