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 36/40] sched/deadline: Check the runtime of a task whose parameters change
Date: Tue, 17 Nov 2026 15:45:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-219102@kernel.org> (raw)
In-Reply-To: <a7e0d6e42bb46c9304699dbfc63dd24efe842ead.1794922146.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] sched/deadline: boosted task with !dl_donor_refill runs on
old runtime
- [Medium] sched/deadline: dl_new_params deferred past dl_deboost()
breaks PI re-boost
- [Medium] sched/deadline: update_dl_entity() on dl_new_params mixes old
and new params
--
commit 707d1303811b0425863d63e123b53368955b72a6
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Check the runtime of a task whose parameters change
This commit adds a dl_new_params flag to struct sched_dl_entity so that
when sched_setattr() modifies a deadline task's runtime, deadline, or
period, the next non-boosted enqueue calls update_dl_entity() to check the
remaining runtime against the new parameters.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index b650c37ae5615..f1d259df8f2a0 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -2785,7 +2785,16 @@ static void __dequeue_dl_entity(struct sched_dl_entity *dl_se)
> static void
> enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> {
> + bool new_params = dl_se->dl_new_params;
> +
> WARN_ON_ONCE(on_dl_rq(dl_se));
> + /*
> + * A boosted task runs on the parameters of its donor. Keep the mark
> + * until an enqueue checks the runtime against its own: the one at
> + * the deboost, or at a wakeup.
> + */
> + if (!is_dl_boosted(dl_se))
> + dl_se->dl_new_params = 0;
[Severity: Medium]
Can a boosted SCHED_DEADLINE task with !dl_se->dl_donor_refill keep
running on its old reservation's remaining runtime after sched_setattr()
shrinks its parameters?
When a SCHED_DEADLINE task with dl_se->runtime > 0 is boosted by an
earlier-deadline waiter, replenish_dl_entity() does not refill it from the
donor and leaves dl_se->dl_donor_refill at 0:
kernel/sched/deadline.c:replenish_dl_entity() {
...
if (dl_se->runtime <= 0)
dl_note_donor_refill(dl_se);
while (dl_se->runtime <= 0) {
dl_se->deadline += period;
dl_se->runtime += runtime;
}
...
}
Because the task is still consuming its own remaining runtime rather than
the donor's, deferring dl_new_params whenever is_dl_boosted(dl_se) is true
lets the task consume the old larger runtime while holding the lock, even
though sched_dl_overflow() has already released the old bandwidth in the
root domain for other deadline tasks to use.
> @@ -2834,12 +2843,13 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> update_dl_entity(dl_se);
> } else if (flags & ENQUEUE_REPLENISH) {
> replenish_dl_entity(dl_se);
> - } else if ((flags & ENQUEUE_CLASS) && !is_dl_boosted(dl_se)) {
> + } else if (((flags & ENQUEUE_CLASS) || new_params) &&
> + !is_dl_boosted(dl_se)) {
> /*
> - * The task enters the class runnable. It may come back before
> - * its deadline, with the runtime left from older parameters.
> - * Check that runtime against the new parameters, as a wakeup
> - * does.
> + * The task enters the class, or its parameters change, while
> + * it is runnable. It may have runtime left from older
> + * parameters. Check that runtime against the new parameters,
> + * as a wakeup does.
> */
> update_dl_entity(dl_se);
> } else if ((flags & ENQUEUE_MOVE) &&
[Severity: Medium]
When a boosted task with dl_new_params set and !dl_se->dl_donor_refill is
deboosted in rt_mutex_setprio(), does deferring update_dl_entity() until
enqueue_dl_entity() miss the post-deboost re-boost check?
In rt_mutex_setprio(), dl_deboost(&p->dl) only updates p->dl.deadline when
dl_se->dl_donor_refill is set, and immediately checks whether the task
must be boosted again by the remaining top waiter:
kernel/sched/core.c:rt_mutex_setprio() {
...
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;
}
...
}
Because update_dl_entity() only runs later in sched_change_end() ->
enqueue_task_dl() -> enqueue_dl_entity(), dl_entity_preempt() compares
pi_task->dl against p->dl.deadline before update_dl_entity() advances
p->dl.deadline to a new period, leaving p unboosted with a deadline later
than its top waiter. If p is blocked on another rt_mutex (!scope->queued)
when deboosted, enqueue_dl_entity() does not run at all, so the priority
inheritance chain walk propagates p's stale deadline.
[Severity: Medium]
Can calling update_dl_entity() on dl_new_params mix the previous period's
dynamic state with the newly written static parameters when switching
between constrained and implicit deadlines?
If a running task started its current period with a constrained deadline
(dl_deadline < dl_period) and calls sched_setattr() to switch to an
implicit deadline (dl_deadline == dl_period), __setparam_dl() overwrites
dl_se->dl_deadline and dl_se->dl_period before enqueue_dl_entity() runs.
When dl_entity_overflow() then triggers in update_dl_entity(),
!dl_is_implicit(dl_se) is now false:
kernel/sched/deadline.c:update_dl_entity() {
...
if (unlikely((!dl_is_implicit(dl_se) ||
(dl_se->dl_defer && dl_se->dl_defer_running)) &&
!dl_time_before(dl_se->deadline, rq_clock(rq)) &&
!is_dl_boosted(dl_se))) {
update_dl_revised_wakeup(dl_se, rq);
return;
}
dl_se->dl_defer_running = 0;
replenish_dl_new_period(dl_se, rq);
...
}
Instead of capping the runtime via update_dl_revised_wakeup(),
update_dl_entity() calls replenish_dl_new_period() and grants a full fresh
runtime before the constrained reservation's period or 0-lag time has
elapsed. Conversely, if a runnable task whose old deadline has already
passed switches to a constrained deadline, dl_check_constrained_dl() at
the top of enqueue_dl_entity() computes dl_next_period() from the old
dl_se->deadline and the new dl_deadline/dl_period, throttles the task, and
returns before update_dl_entity() can start a new period.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794922146.git.mathieu.desnoyers@efficios.com?part=36
next prev parent reply other threads:[~2026-11-17 15:45 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
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 [this message]
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-219102@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