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 v4 26/26] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting
Date: Sat, 07 Nov 2026 02:25:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-202508@kernel.org> (raw)
In-Reply-To: <20261107014451.1487825-27-mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/sched: unchecked boosting_waiter() return and boost
state
--
commit e5ace2481bd0093710ca8b43f5f8c80f64160b52
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting
This commit adds deadline_bw_test to test SCHED_DEADLINE bandwidth
accounting across priority inheritance, parameter changes, cpuset moves,
task exits, sched_yield(), runtime overruns, bandwidth reclaiming, fair
server changes, and CPU hotplug.
> diff --git a/tools/testing/selftests/sched/deadline/deadline_bw_test.c b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
> new file mode 100644
> index 0000000000000..8ede5d5a350e3
> --- /dev/null
> +++ b/tools/testing/selftests/sched/deadline/deadline_bw_test.c
[ ... ]
> +/* A deadline task that blocks on the lock: it boosts its owner. */
> +static void *boosting_waiter(void *arg)
> +{
> + return (void *)(long)wait_lock_for(300, 1);
> +}
> +
> +/*
> + * SCHED_FLAG_KEEP_PARAMS with SCHED_DEADLINE on an owner that priority
> + * inheritance has boosted into the class: the class of the request is the
> + * one the owner already has, so a class change is not what it asks for,
> + * and the policy it asks for is one the kept parameters would not give
> + * it. It is refused with EINVAL; admitted, it reserves the bandwidth of
> + * the owner's slice and nothing ever releases it.
> + */
> +static int params_keep_boosted(void)
> +{
> + struct dl_attr slice = {
> + .size = sizeof(slice),
> + .sched_policy = SCHED_OTHER,
> + .sched_runtime = 40 * NSEC_PER_MSEC, /* what the request would keep */
> + };
> + struct dl_attr keep = {
> + .size = sizeof(keep),
> + .sched_policy = SCHED_DEADLINE,
> + .sched_flags = SCHED_FLAG_KEEP_PARAMS,
> + .sched_deadline = PERIOD,
> + .sched_period = PERIOD,
> + };
> + int ret = KSFT_PASS, err;
> + pthread_t o, w;
> +
> + if (pi_init())
> + return KSFT_SKIP;
> + if (pthread_create(&o, NULL, sleeping_owner, (void *)0L)) {
> + ksft_print_msg("the owner thread could not start\n");
> + return KSFT_FAIL;
> + }
> + if (wait_for(5000, owner_holds) || owner_holds != 2) {
> + ksft_print_msg("the owner never took the lock\n");
> + join(o);
> + return KSFT_FAIL;
> + }
> + if (syscall(SYS_sched_setattr, owner_tid, &slice, 0)) {
> + ksft_print_msg("the owner cannot take a slice of its own: %s\n",
> + strerror(errno));
> + ret = KSFT_SKIP;
> + goto out;
> + }
> + if (pthread_create(&w, NULL, boosting_waiter, NULL)) {
> + ksft_print_msg("the waiter thread could not start\n");
> + ret = KSFT_FAIL;
> + goto out;
> + }
> + sleep_ns(50 * NSEC_PER_MSEC); /* it blocks, the owner is boosted */
> + err = syscall(SYS_sched_setattr, owner_tid, &keep, 0) ? -errno : 0;
> + if (err != -EINVAL) {
> + ksft_print_msg("KEEP_PARAMS to SCHED_DEADLINE on a boosted owner: %s, not EINVAL\n",
> + err ? strerror(-err) : "accepted");
> + ret = KSFT_FAIL;
> + }
> + join(w);
> +out:
> + join(o);
> + return ret;
> +}
> +
> +/* Boosted by a deadline waiter, the owner may still change its policy. */
> +static int boosted_owner_policy(void)
> +{
> + int ret = KSFT_PASS, err;
> + pthread_t o, w;
> +
> + if (pi_init())
> + return KSFT_SKIP;
> + if (pthread_create(&o, NULL, sleeping_owner, (void *)0L)) {
> + ksft_print_msg("the owner thread could not start\n");
> + return KSFT_FAIL;
> + }
> + if (wait_for(5000, owner_holds) || owner_holds != 2) {
> + ksft_print_msg("the owner never took the lock\n");
> + join(o);
> + return KSFT_FAIL;
> + }
> + if (pthread_create(&w, NULL, boosting_waiter, NULL)) {
> + ksft_print_msg("the waiter thread could not start\n");
> + join(o);
> + return KSFT_FAIL;
> + }
> + sleep_ns(50 * NSEC_PER_MSEC); /* it blocks, the owner is boosted */
> + err = set_other(owner_tid);
> + if (err) {
> + ksft_print_msg("SCHED_OTHER on a boosted owner: %s\n", strerror(-err));
> + ret = KSFT_FAIL;
> + }
> + join(w);
> + join(o);
> + return ret;
> +}
[Severity: Low]
Can params_keep_boosted() and boosted_owner_policy() report KSFT_PASS
even when owner_tid was never PI-boosted?
boosting_waiter() returns the status of wait_lock_for(), which is
non-zero if set_deadline() or pthread_mutex_timedlock() fails, but join()
calls pthread_join(t, NULL) and discards that return value. Neither test
checks prio_of(owner_tid) == DL_TASK_PRIO before calling sched_setattr()
either, so if wait_lock_for() fails or w is delayed past the 50ms sleep,
both tests exercise an unboosted SCHED_OTHER owner and still pass.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261107014451.1487825-1-mathieu.desnoyers@efficios.com?part=26
prev parent reply other threads:[~2026-11-07 2:25 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 1:44 [PATCH v4 00/26] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 01/26] sched: Fix cpuset_mutex double unlock in __sched_setscheduler() Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 02/26] sched: Refuse SCHED_FLAG_KEEP_PARAMS that would change the policy or the class Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 03/26] sched/deadline: Do not admit bandwidth for parameters that are kept Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 04/26] sched: Let a task boosted by a deadline waiter change its policy Mathieu Desnoyers
2026-11-07 2:13 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 05/26] sched/deadline: Do not divide by zero active CPUs of a root domain Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 06/26] sched: Take cpuset_mutex for a deadline policy change only with pi Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 07/26] sched/deadline: Do not lose a throttled task switched out and back Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 08/26] sched/deadline: Take a deadline boost from the waiter's rt_mutex node Mathieu Desnoyers
2026-11-07 2:25 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 09/26] sched/deadline: Reset the deadline and the runtime with the parameters Mathieu Desnoyers
2026-11-07 2:18 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 10/26] sched/deadline: Release the bandwidth of a task that leaves the class asleep Mathieu Desnoyers
2026-11-07 2:23 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 11/26] sched/deadline: Reject SCHED_DEADLINE on exited tasks Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 12/26] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 13/26] sched/deadline: Do not take a waking task's bandwidth off a runqueue it left Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 14/26] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-11-07 2:22 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 15/26] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-11-07 2:10 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 16/26] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-11-07 2:35 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 17/26] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 18/26] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 19/26] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 20/26] sched/deadline: Credit a rebuild to the CPU recorded with the task's bandwidth Mathieu Desnoyers
2026-11-07 2:48 ` sashiko-bot
2026-11-07 1:44 ` [PATCH v4 21/26] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 22/26] sched/deadline: Count the bandwidth a boosted task is given Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 23/26] sched/debug: Show the deadline bandwidth of each runqueue Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 24/26] selftests/sched: Add a test of SCHED_DEADLINE policy round trips Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 25/26] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-07 1:44 ` [PATCH v4 26/26] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting Mathieu Desnoyers
2026-11-07 2:25 ` sashiko-bot [this message]
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-202508@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
all inboxes | Powered by JetHome®