Re: [PATCH v11 25/43] sched/deadline: Count the 0-lag time from the next period

From: sashiko-bot

Date: Wed Nov 25 2026 - 20:35:51 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: dl_time_to_zerolag() miscomputes 0-lag when
deadline is 0
--

commit 03d5dc8d2f6d0b382a7bed954bd1379667e09042
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

sched/deadline: Count the 0-lag time from the next period

This commit computes a deadline entity's 0-lag time relative to
dl_next_period(dl_se) rather than dl_se->deadline so that tasks with
constrained deadlines do not reach their 0-lag time prematurely.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 74b3c6b967eee..1d2dcf478f95d 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -633,12 +637,12 @@ static unsigned int dl_task_root_domain_cpu(struct task_struct *p);
> */
> static s64 dl_time_to_zerolag(struct sched_dl_entity *dl_se, struct rq *rq)
> {
> - /* Time to the deadline. Negative if the deadline has passed. */
> - s64 left = dl_se->deadline - rq_clock(rq);
> + /* Time to the next period. Negative if it has started. */
> + s64 left = dl_next_period(dl_se) - rq_clock(rq);

[Severity: Medium]
Can dl_time_to_zerolag() return a positive delay when dl_se->deadline is 0?

If a sleeping task with no active period (dl_se->deadline == 0 and
dl_se->runtime == 0) is switched into SCHED_DEADLINE with a constrained
deadline (dl_deadline < dl_period) and then switched back out while still
asleep, switched_from_dl() -> task_non_contending() calls
dl_time_to_zerolag(). Previously, dl_se->deadline - rq_clock(rq) was
negative and the bandwidth was released immediately. With dl_next_period(),
0 - dl_deadline + dl_period evaluates to dl_period - dl_deadline; whenever
rq_clock(rq) is smaller than that difference, left is non-negative and
inactive_timer is armed, holding the task's bandwidth in root-domain
total_bw and causing subsequent admission checks to fail with -EBUSY.

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795646914.git.mathieu.desnoyers@xxxxxxxxxxxx?part=25