Re: [RESEND PATCH v4 10/17] sched/deadline: Fix an overflow of the 0-lag time with long periods

From: Mathieu Desnoyers

Date: Thu Nov 19 2026 - 13:14:58 EST


> Can mul_u64_u64_div_u64() in the dl_se->runtime < 0 branch still overflow
> s64 or u64 when dl_runtime was shrunk or the overrun spans multiple
> seconds?

Yes, by reading. It needs a raised period limit and a stall of
several seconds.

The runtime goes below zero within a single update. update_curr_dl_se()
throttles the task at the first update past zero, or refills a boosted
task from its donor. So your rt_mutex case adds at most one more update.
The tick does not stop while a deadline task is queued. An overrun
therefore lasts at most about a tick. Only a stall, such as the vCPU
preemption you mention, makes it longer.

With a dl_runtime of 1024ns, the quotient exceeds 64 bits only after a
single overrun of:
- 4.4s, with sched_deadline_period_max_us at its maximum;
- 63s, with a 300s period limit;
- 4504s, with the default limit of about 4.19s.
Only then does x86-64 trap. One tick never does. The s64 wrap needs half
of each, and releases the bandwidth at once. v7.4-rc2 already wrapped
the product in all these cases, and with much shorter overruns.

> Even with the default 4s period limit, scaling a single-tick overrun of
> the old runtime by the new dl_period / dl_runtime ratio can arm
> inactive_timer for hours, locking up running_bw and total_bw.

Right about the hours: about 4.5 hours for a 4ms tick, with a 1024ns
runtime and a 4.19s period. This is the time the task needs to pay back
its overrun, at its new runtime per period. If the task stayed in the
class, replenish_dl_entity() would push its deadline as far. v7.4-rc2
arms the same timer. The timer holds only the task's own bandwidth, the
new dl_runtime / dl_period. Here, it rounds to 0.

The comment of this patch says that the overrun is short and its
quotient fits. This is too strong. The next version will cap the
quotient in this branch. Its comment will say that a stall can make
the overrun longer.

Thanks,

Mathieu

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