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

From: Mathieu Desnoyers

Date: Tue Dec 01 2026 - 10:12:19 EST


On 2026-11-30 11:47, Juri Lelli wrote:
> Nit: the patch also makes dl_check_constrained_dl() skip a task with no
> period yet (deadline of 0), which could otherwise be taken for one in
> its constrained gap right after boot. That isn't obvious from the code,
> so maybe a comment before the check, something like
[...]
> and a sentence in the changelog?

Yes, I added both. The comment is yours, with one change. The task is
throttled only while rq_clock is below dl_period - dl_deadline, not
below dl_period. That is where dl_next_period() puts the next period
for a deadline of 0. The comment now reads:

/*
* A deadline of 0 means the task has no period yet: this enqueue
* starts one. Skip it, or the check below would see a deadline in
* the past. While rq_clock is still below dl_period - dl_deadline
* (right after boot), it would then throttle the task until a next
* period computed from that 0.
*/

The changelog now has these two paragraphs:

A task with no period yet has a deadline of 0. dl_next_period() then
returns dl_period - dl_deadline, which is above 0 for a constrained
deadline. Right after boot, rq_clock can still be below that value.
Counted from that next period, the 0-lag time would be ahead. Make
dl_time_to_zerolag() return no 0-lag time for such a task.

dl_check_constrained_dl() has the same problem since
commit df8eac8cafce ("sched/deadline: Throttle a constrained deadline
task activated after the deadline"). It sees a deadline of 0 as passed,
and the next period as ahead. So a task that enters the class with a
constrained deadline right after boot would be throttled until rq_clock
reaches dl_period - dl_deadline. Make dl_check_constrained_dl() skip a
deadline of 0 too.

That hunk fixes an older bug, so the patch now has a second Fixes: tag,
for df8eac8cafce.

> Apart from that, this fix maybe should go at the top of the series so
> that it can be picked up more easily?

Done. It is now v13 patch 4, after 23, 27 and 20. It does not need
them: it applies with plain git am on the first series alone.

> Reviewed-by: Juri Lelli <juri.lelli@xxxxxxxxxx>

Added.

Thanks!

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com