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 v2 10/16] sched/deadline: Release the bandwidth of a task that leaves the class asleep
Date: Wed, 18 Nov 2026 21:51:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-222041@kernel.org> (raw)
In-Reply-To: <413baa5f50669ae464f504dbafeb504dd9b6ef6c.1795037078.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: stale params and s64 overflow in
task_non_contending()
--
commit f6b619684c21aa7de4c182929a5157b957fed874
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Release the bandwidth of a task that leaves the class asleep
This commit calls task_non_contending() in switched_from_dl() when an
unqueued task leaves SCHED_DEADLINE without an armed inactive timer, so
that its total_bw contribution is released immediately or at the 0-lag
time.
Link: https://lore.kernel.org/all/20261103-b4-sched-dl-bw-fixes-v1-2-dd761fe005b4@redhat.com/
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index d6d2657dcddd6..f0e03f97fd82f 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -3595,6 +3595,14 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
> if (p->dl.dl_non_contending)
> sub_running_bw(&p->dl, &rq->dl);
> sub_rq_bw(&p->dl, &rq->dl);
> + /*
> + * Without an armed timer, nothing releases total_bw. Do as for
> + * a queued task: arm the timer if the 0-lag time is ahead, or
> + * release the bandwidth and clear the parameters now. Call
> + * task_non_contending() after sub_rq_bw(), which needs dl_bw.
> + */
> + if (!p->dl.dl_non_contending)
> + task_non_contending(&p->dl, false);
[Severity: Medium]
Can task_non_contending() compute a bogus zerolag_time here when a
sleeping task had its deadline parameters updated before leaving the
class?
When a sleeping task re-enters SCHED_DEADLINE before its 0-lag time (or
updates its SCHED_DEADLINE parameters in place while asleep),
switched_to_dl() or dl_rq_change_utilization() cancels inactive_timer and
__setparam_dl() overwrites dl_runtime, dl_deadline and dl_period while
leaving the dynamic runtime and deadline from the previous reservation to
be updated at the next wakeup. If the task then leaves SCHED_DEADLINE
while still asleep, task_non_contending() mixes the old runtime and
deadline with the new dl_period and dl_runtime:
kernel/sched/deadline.c:task_non_contending() {
...
zerolag_time = dl_se->deadline -
div64_long((dl_se->runtime * dl_se->dl_period),
dl_se->dl_runtime);
...
}
If the task had negative runtime under the old reservation and was given
a smaller dl_runtime / dl_period ratio, (-runtime * dl_period) /
dl_runtime is scaled up by the new ratio and can arm inactive_timer days
in the future, pinning total_bw and the task_struct reference; if runtime
was positive and dl_runtime was lowered below runtime, zerolag_time
becomes negative before the true 0-lag time and releases total_bw early.
Also, in the same calculation, dl_se->runtime * dl_se->dl_period is
evaluated in unscaled 64-bit arithmetic (unlike dl_entity_overflow(),
which shifts by DL_SCALE), so valid parameters within the default
sysctl_sched_dl_period_max (~4.19s, e.g. dl_period = 4s and remaining
runtime = 2.4s) overflow S64_MAX and wrap the dividend negative, pushing
zerolag_time past the deadline.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795037078.git.mathieu.desnoyers@efficios.com?part=10
next prev parent reply other threads:[~2026-11-18 21:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 21:24 [PATCH v2 00/16] sched/deadline: first bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-18 21:24 ` [PATCH v2 01/16] sched: Refuse SCHED_FLAG_KEEP_PARAMS that would change the policy or the class Mathieu Desnoyers
2026-11-18 21:24 ` [PATCH v2 02/16] sched/deadline: Do not admit bandwidth for parameters that are kept Mathieu Desnoyers
2026-11-18 21:24 ` [PATCH v2 03/16] sched: Let a task boosted by a deadline waiter change its policy Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 04/16] sched/deadline: Do not divide by zero active CPUs of a root domain Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 05/16] sched/deadline: Refuse dl_server debugfs writes while the rq is offline Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 06/16] sched: Take cpuset_mutex for a deadline policy change only with pi Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 07/16] sched/deadline: Do not lose a throttled task switched out and back Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 08/16] sched/deadline: Do not replenish a boost from cleared parameters Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 09/16] sched/deadline: Reset the deadline and the runtime with the parameters Mathieu Desnoyers
2026-11-18 21:44 ` sashiko-bot
2026-11-19 13:39 ` Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 10/16] sched/deadline: Release the bandwidth of a task that leaves the class asleep Mathieu Desnoyers
2026-11-18 21:51 ` sashiko-bot [this message]
2026-11-19 13:39 ` Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 11/16] sched/deadline: Reject SCHED_DEADLINE on exited tasks Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 12/16] sched/deadline: Fix this_bw when a task is changed during a remote wakeup Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 13/16] sched/deadline: Check SCHED_DEADLINE affinity under the rq lock Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 14/16] sched/debug: Show the deadline bandwidth of each runqueue Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 15/16] selftests/sched: Add a test of SCHED_DEADLINE policy round trips Mathieu Desnoyers
2026-11-18 21:25 ` [PATCH v2 16/16] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting Mathieu Desnoyers
2026-11-18 22:07 ` sashiko-bot
2026-11-19 13:40 ` Mathieu Desnoyers
2026-11-19 10:20 ` [PATCH v2 00/16] sched/deadline: first bandwidth accounting fixes and selftests Juri Lelli
2026-11-19 13:41 ` 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-222041@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.