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 v7 11/40] sched/deadline: Reset the donor's runtime at a deboost in the class
Date: Tue, 17 Nov 2026 14:55:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-219000@kernel.org> (raw)
In-Reply-To: <299aaf536a1a63c7b496eebe7a6ca20e8f06ad5f.1794922146.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] sched/deadline: rt_mutex_setprio() skips dl_deboost() on
donor change
- [Medium] sched/deadline: donor runtime kept when leaving
dl_sched_class
- [Low] sched/deadline: missing dl_note_donor_refill() on cleared donor
in replenish_dl_entity()
--
commit bb738227d35bdf5cba0afaf4e41cb6707e38d0c4
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Reset the donor's runtime at a deboost in the class
This commit adds a dl_donor_refill flag to record when a boosted task has its
runtime replenished from a donor's reservation, and starts a new period from
the task's own parameters when the boost ends in the deadline class.
[ ... ]
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 5ed660f099a55..a22df8b43a1a7 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7834,16 +7834,26 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
> p->dl.pi_se = pi_task->dl.pi_se;
> scope->flags |= ENQUEUE_REPLENISH;
> } else {
> - p->dl.pi_se = &p->dl;
> + dl_deboost(&p->dl);
> + /*
> + * dl_deboost() can start a new period. Its
> + * deadline can then be after the top waiter's.
> + * Boost the task again then.
> + */
> + if (pi_task && dl_prio(pi_task->prio) &&
> + dl_entity_preempt(&pi_task->dl, &p->dl)) {
> + p->dl.pi_se = pi_task->dl.pi_se;
> + scope->flags |= ENQUEUE_REPLENISH;
> + }
> }
[Severity: Medium]
Can a SCHED_DEADLINE task skip dl_deboost(&p->dl) here when switching from
one deadline donor to another?
In rt_mutex_setprio(), the outer if statement tests
dl_entity_preempt(&pi_task->dl, &p->dl) before calling dl_deboost(&p->dl).
When p was refilled from a previous donor W1, p->dl.deadline holds W1's
postponed deadline rather than p's own reservation deadline. If p unlocks
W1's lock while another deadline waiter W2 is queued on a lock held by p, and
W2->dl.deadline is earlier than W1's postponed deadline, the outer check
takes the first branch and skips dl_deboost(&p->dl).
Because p->dl.dl_deadline is non-zero and p->dl.runtime is still positive
from W1's refill, ENQUEUE_REPLENISH in replenish_dl_entity() does not reset
p->dl.runtime or p->dl.deadline either. p then keeps W1's leftover runtime
and postponed deadline, even if p's own new-period deadline would have been
earlier than W2->dl.deadline.
Calling dl_deboost(&p->dl) unconditionally when dl_prio(p->normal_prio)
before testing whether pi_task preempts &p->dl would compare pi_task against
p's own reservation.
> } else if (rt_prio(prio)) {
> if (dl_prio(oldprio))
> - p->dl.pi_se = &p->dl;
> + dl_drop_boost(&p->dl);
> if (oldprio < prio)
> scope->flags |= ENQUEUE_HEAD;
> } else {
> if (dl_prio(oldprio))
> - p->dl.pi_se = &p->dl;
> + dl_drop_boost(&p->dl);
> if (rt_prio(oldprio))
> p->rt.timeout = 0;
> }
[Severity: Medium]
Does a task that still has SCHED_DEADLINE parameters (p->dl.dl_runtime != 0)
keep the donor's refilled runtime and deadline when leaving the deadline
class at deboost?
A task can have p->dl.dl_runtime != 0 and p->dl.dl_donor_refill == 1 while
leaving dl_sched_class (for example, if it changed its policy away from
SCHED_DEADLINE while boosted and then unlocks, or if it left SCHED_DEADLINE
before its 0-lag time and was boosted and refilled before inactive_timer
fired). When it leaves dl_sched_class, sched_change_begin() runs
switched_from_dl() before dl_drop_boost(&p->dl) clears dl_donor_refill:
kernel/sched/deadline.c:switched_from_dl() {
if (task_on_rq_queued(p) && p->dl.dl_runtime)
task_non_contending(&p->dl, false);
...
if (!p->dl.dl_runtime) {
p->dl.deadline = 0;
p->dl.runtime = 0;
}
}
Because p->dl.dl_runtime is non-zero, switched_from_dl() passes the donor's
refilled runtime and deadline to task_non_contending(), which mixes them with
p's own dl_period and dl_runtime to compute zerolag_time. If the donor's
remaining runtime makes zerolag_time negative, task_non_contending() clears
p's parameters immediately and lets p re-enter SCHED_DEADLINE with a fresh
budget in the same period; otherwise, p retains the donor's runtime and
deadline if it returns to SCHED_DEADLINE before inactive_timer fires.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index d6d2657dcddd6..989e7e7d3f8f1 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -832,6 +869,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)
> if (!dl_se->dl_deadline) {
> dl_se->deadline = rq_clock(rq);
> dl_se->runtime = 0;
> + dl_note_donor_refill(dl_se);
> }
> if (dl_se->runtime < 0 || dl_se->dl_yielded)
> dl_se->runtime = 0;
[Severity: Low]
In this cleared-donor fallback (!runtime || !deadline || !period), should
dl_note_donor_refill(dl_se) also be called when dl_se->dl_deadline is
non-zero?
If a boosted SCHED_DEADLINE task hits this path when its runtime is exhausted
or after sched_yield(), replenish_dl_entity() zeroes dl_se->runtime and
clears dl_se->dl_throttled without setting dl_donor_refill. A subsequent
dl_deboost() then leaves the task in the class with runtime == 0,
dl_throttled == 0, and its old deadline.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794922146.git.mathieu.desnoyers@efficios.com?part=11
next prev parent reply other threads:[~2026-11-17 14:55 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:10 [PATCH v7 00/40] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 01/40] sched: Refuse SCHED_FLAG_KEEP_PARAMS that would change the policy or the class Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 02/40] sched/deadline: Do not admit bandwidth for parameters that are kept Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 03/40] sched: Let a task boosted by a deadline waiter change its policy Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 04/40] sched/deadline: Do not divide by zero active CPUs of a root domain Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 05/40] sched/deadline: Refuse dl_server debugfs writes while the rq is offline Mathieu Desnoyers
2026-11-17 14:38 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 06/40] sched: Take cpuset_mutex for a deadline policy change only with pi Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 07/40] sched/deadline: Do not lose a throttled task switched out and back Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 08/40] sched/deadline: Do not replenish a boost from cleared parameters Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 09/40] rtmutex: Continue the chain walk when a waiter's deadline donor changes Mathieu Desnoyers
2026-11-17 14:50 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 10/40] sched/deadline: Reset the deadline and the runtime with the parameters Mathieu Desnoyers
2026-11-17 14:55 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 11/40] sched/deadline: Reset the donor's runtime at a deboost in the class Mathieu Desnoyers
2026-11-17 14:55 ` sashiko-bot [this message]
2026-11-17 14:10 ` [PATCH v7 12/40] sched/deadline: Replenish a throttled task boosted while asleep Mathieu Desnoyers
2026-11-17 14:55 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 13/40] sched/deadline: Release the bandwidth of a task that leaves the class asleep Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 14/40] sched/deadline: Reject SCHED_DEADLINE on exited tasks Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 15/40] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 16/40] sched/deadline: Fix this_bw when a task is changed during a remote wakeup Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 17/40] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 18/40] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-11-17 15:14 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 19/40] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 20/40] sched/deadline: Check SCHED_DEADLINE affinity under the rq lock Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 21/40] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 22/40] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 23/40] sched: Make deadline policy and affinity changes wait for a cpuset attach Mathieu Desnoyers
2026-11-17 15:18 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 24/40] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 25/40] cgroup/cpuset: Reserve the bandwidth in the root domain a task moves to Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 26/40] sched/deadline: Make a rebuild count a task in the root domain it runs in Mathieu Desnoyers
2026-11-17 15:31 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 27/40] sched/deadline: Move a task's bandwidth to " Mathieu Desnoyers
2026-11-17 15:29 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 28/40] sched/deadline: Keep a task in the root domain that counts its bandwidth Mathieu Desnoyers
2026-11-17 15:32 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 29/40] sched/deadline: Keep the last CPU a task has in its root domain Mathieu Desnoyers
2026-11-17 15:41 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 30/40] cgroup/cpuset: Refuse to take a deadline task out of " Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 31/40] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 32/40] sched/deadline: Count the bandwidth a boosted task is given Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 33/40] sched/deadline: Start a period for a task that enters the class blocked Mathieu Desnoyers
2026-11-17 15:46 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 34/40] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 35/40] sched/deadline: Check the runtime of a task that comes back runnable Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 36/40] sched/deadline: Check the runtime of a task whose parameters change Mathieu Desnoyers
2026-11-17 15:45 ` sashiko-bot
2026-11-17 14:10 ` [PATCH v7 37/40] sched/debug: Show the deadline bandwidth of each runqueue Mathieu Desnoyers
2026-11-17 14:10 ` [PATCH v7 38/40] selftests/sched: Add a test of SCHED_DEADLINE policy round trips Mathieu Desnoyers
2026-11-17 15:23 ` sashiko-bot
2026-11-17 14:11 ` [PATCH v7 39/40] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-17 14:11 ` [PATCH v7 40/40] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting 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-219000@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