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 08/39] sched/deadline: Keep the deadline of a departed constrained task
Date: Thu, 03 Dec 2026 15:45:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-248143@kernel.org> (raw)
In-Reply-To: <65864008a1fdbd111bd0612860a4ccad3f4c7a75.1796296313.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] sched/deadline: switched_from_dl() wipes preserved deadline of
queued task
- [Medium] sched/deadline: non-idempotent dl_release_params() wipes
preserved deadline
- [Medium] sched/deadline: preserved deadline breaks PI boost in
update_dl_entity()
- [Medium] sched/deadline: dl_release_params() retains stale deadline
across reentry
- [Medium] sched/deadline: dl_release_params() leaves future deadline
with zero runtime
- [Medium] sched/deadline: dl_release_params() keeps replenished
next-period deadline
--
commit 6e0cda7a366c85d079b40022ecc95931ec1d4f8d
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Keep the deadline of a departed constrained task
This patch introduces dl_release_params() and calls it from
task_non_contending() and inactive_task_timer() in place of
__dl_clear_params() so that a departed constrained SCHED_DEADLINE task
keeps its deadline after its bandwidth is released.
Link: https://lore.kernel.org/all/axAxdNEE1Q2OuxNQ@jlelli-thinkpadt14gen4.remote.csb/
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index c88cac6bc5fe7..422a8120454a3 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -2341,7 +2342,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer)
> raw_spin_lock(&dl_b->lock);
> __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p)));
> raw_spin_unlock(&dl_b->lock);
> - __dl_clear_params(dl_se);
> + dl_release_params(dl_se);
>
> goto unlock;
> }
[Severity: Medium]
Can a race between inactive_task_timer() and task_non_contending() call
dl_release_params() twice and wipe the preserved deadline?
CPU0 CPU1
inactive_task_timer()
(waits on task_rq_lock)
switched_to_dl()
cancel_inactive_timer() -> -1
switched_from_dl()
task_non_contending(&p->dl, false)
hrtimer_active() is true
dl_release_params(dl_se)
(zeroes dl_deadline/dl_period,
keeps deadline)
task_rq_unlock()
task_rq_lock()
!dl_task(p) is true
dl_release_params(dl_se) <-- wipes deadline to 0
On the second call, dl_deadline and dl_period are both 0, so
dl_is_implicit(dl_se) evaluates to true and __dl_clear_params() overwrites
the preserved deadline with 0. If the task re-enters SCHED_DEADLINE before
its next period, it bypasses dl_check_constrained_dl() throttling and can
exceed its reserved bandwidth.
Returning early when !dl_se->dl_runtime in dl_release_params() or
inactive_task_timer() would keep parameter release idempotent.
[Severity: Medium]
When a throttled constrained task leaves SCHED_DEADLINE with an overrun,
does inactive_task_timer() preserve the replenished next-period deadline
with zero runtime?
When dl_se->runtime < 0, dl_time_to_zerolag() places the 0-lag time strictly
after dl_next_period(dl_se). At dl_next_period(dl_se), dl_task_timer()
fires first and calls replenish_dl_entity(), advancing dl_se->deadline into
the next period.
When inactive_task_timer() then runs at the 0-lag time, dl_release_params()
clears dl_se->runtime to 0 while keeping that next-period deadline. If the
task re-enters SCHED_DEADLINE during that next period after already waiting
out its previous period and overrun, it has zero runtime and is throttled
for an entire extra period.
[ ... ]
> @@ -3682,7 +3683,8 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
> * the "inactive timer" fires, it can continue to consume its current
> * runtime using its current deadline. If it stays outside of
> * SCHED_DEADLINE until the 0-lag time passes, inactive_task_timer()
> - * will reset the task parameters.
> + * will reset the task parameters. A constrained task keeps its
> + * deadline: see dl_release_params().
> */
> if (task_on_rq_queued(p) && p->dl.dl_runtime)
> task_non_contending(&p->dl, false);
[Severity: High]
Does switched_from_dl() immediately wipe the deadline that
dl_release_params() just preserved for a queued constrained task?
When a queued constrained task leaves SCHED_DEADLINE after its 0-lag time
has passed, task_non_contending(&p->dl, false) calls dl_release_params(),
which zeroes p->dl.dl_runtime while keeping p->dl.deadline. The block
right below then sees !p->dl.dl_runtime and clears p->dl.deadline back to 0:
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;
}
}
Without its deadline, re-entering SCHED_DEADLINE before the next period
immediately starts a new period with full runtime, allowing the task to
exceed its reserved bandwidth. Moving the !p->dl.dl_runtime reset for
PI-boosted tasks above task_non_contending() would avoid wiping it.
[ ... ]
> @@ -4155,6 +4157,29 @@ static void __dl_clear_params(struct sched_dl_entity *dl_se)
> dl_se->dl_bw_oncpu = 0;
> }
>
> +/*
> + * Clear the parameters of a task which left the class, once its
> + * bandwidth is released. A task with a constrained deadline keeps its
> + * deadline. Leaving the class and coming back before its next period
> + * then gives it no new runtime. Back in the class, it waits for that
> + * period, as a task asleep in the class does:
> + * - between its deadline and its next period, dl_check_constrained_dl()
> + * throttles it;
> + * - before its deadline, it has no runtime left.
> + *
> + * An implicit deadline task keeps nothing. In the class too, a wakeup
> + * after its 0-lag time starts a new period.
> + */
> +static void dl_release_params(struct sched_dl_entity *dl_se)
> +{
> + u64 deadline = dl_se->deadline;
> + bool constrained = !dl_is_implicit(dl_se);
> +
> + __dl_clear_params(dl_se);
> + if (constrained)
> + dl_se->deadline = deadline;
> +}
[Severity: Medium]
Can keeping a future dl_se->deadline with runtime == 0 break priority
inheritance when the departed task is later boosted while asleep?
For a constrained task whose 0-lag time precedes its absolute deadline,
dl_release_params() leaves a non-DL task with dl_runtime == 0, runtime == 0,
and a future dl_se->deadline. If a short-deadline waiter boosts the task
while it is asleep, rt_mutex_setprio() sets pi_se and ENQUEUE_REPLENISH,
but sched_change_end() skips the enqueue because the task is not queued.
When the task wakes up before its preserved deadline, update_dl_entity()
sees dl_time_before(dl_se->deadline, rq_clock(rq)) is false and
dl_entity_overflow() is false (because runtime == 0 makes left == 0). It
skips replenish_dl_new_period() and enqueues the boosted task onto dl_rq
with its stale future deadline and zero runtime instead of the donor's
earlier deadline, causing priority inversion and deadline misses for the
donor.
[Severity: Medium]
Does retaining dl_se->deadline indefinitely without clearing it on re-entry
corrupt period calculations when the task returns with a longer dl_period?
Nothing clears the preserved deadline after the old period expires, and
__setparam_dl() installs new dl_deadline and dl_period values without
resetting it. If a task that ran a short constrained period (such as 10ms)
re-enters seconds later with a longer dl_period (such as 4000ms),
dl_next_period() combines the stale deadline with the new dl_period and
produces a timestamp still in the future.
On wakeup, dl_check_constrained_dl() then spuriously throttles the task for
up to the new dl_period even though its old period ended seconds earlier.
If the task instead re-enters asleep and switches back to SCHED_OTHER
without running, dl_time_to_zerolag() sees the future dl_next_period(),
arms inactive_timer, and pins the newly admitted bandwidth in total_bw.
[Severity: Medium]
When a departed constrained task re-enters SCHED_DEADLINE before its
preserved future deadline, does runtime == 0 let it run unbudgeted and
trigger spurious overruns?
If the task's 0-lag time passed before dl_se->deadline (for example, 10ms
runtime, 50ms deadline, 100ms period after running 1ms gives a 0-lag time
of 10ms), dl_release_params() leaves a future deadline with runtime == 0
and dl_throttled == 0. Re-entering SCHED_DEADLINE before that deadline
skips both dl_check_constrained_dl() and update_dl_entity(), so
enqueue_dl_entity() queues the task unthrottled with zero runtime.
When scheduled, the task executes unbudgeted until the next tick or hrtick,
accumulates negative runtime debt in update_curr_dl_se(), and spuriously
sets dl_overrun (delivering SIGXCPU under SCHED_FLAG_DL_OVERRUN). Even
with the zero-runtime throttling added later in commit "sched/deadline:
Keep the debt of a task across a change of parameters", re-entering with a
shorter period where dl_next_period(dl_se) <= rq_clock < dl_se->deadline
still clears dl_throttled without replenishing when start_dl_timer()
returns 0 and enqueues the task with zero runtime.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796296313.git.mathieu.desnoyers@efficios.com?part=8
next prev parent reply other threads:[~2026-12-03 15:45 UTC|newest]
Thread overview: 61+ 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-04 17:26 ` Peter Zijlstra
2026-12-04 18:03 ` Mathieu Desnoyers
2026-12-04 18:23 ` Sebastian Andrzej Siewior
2026-12-04 18:38 ` Mathieu Desnoyers
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 [this message]
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
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-248143@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.