Re: [PATCH v7 13/40] sched/deadline: Release the bandwidth of a task that leaves the class asleep
From: Juri Lelli
Date: Wed Nov 18 2026 - 10:34:02 EST
Hello,
On 17/11/26 09:10, Mathieu Desnoyers wrote:
> A task that leaves SCHED_DEADLINE while it is not queued can keep its
> bandwidth in total_bw until the next rebuild of the root domains.
> Repeated, this fills total_bw up to the admission limit. Then
> sched_setattr(SCHED_DEADLINE) and CPU offlining fail with EBUSY.
>
> A task that leaves the class keeps its bandwidth until its 0-lag time.
> Releasing it earlier would allow temporary overloads. For a queued task,
> switched_from_dl() calls task_non_contending(). It releases the
> bandwidth if the 0-lag time is past. Otherwise it arms the inactive
> timer, which releases it then. For a task that is not queued,
> switched_from_dl() relies on the timer armed when the task blocked.
>
> But the timer is not always pending when the task leaves the class:
> - The task blocked after its 0-lag time. The timer was not armed.
> - The timer fired while the task was still in the class. It only
> removed running_bw.
> - The task was woken up on another CPU and is not enqueued there yet.
> The wakeup cancelled the timer.
> - The task came back to the class asleep. switched_to_dl() cancelled
> the timer.
>
> Then nothing releases total_bw.
>
> Fix this in switched_from_dl(). For a task that is not queued and has
> no timer pending, call task_non_contending(), as for a queued task. It
> arms the timer if the 0-lag time is ahead. Otherwise it releases the
> bandwidth now and clears the parameters, as inactive_task_timer() does.
>
> Clearing the parameters keeps later paths from releasing the bandwidth
> again:
> - A timer handler that already started finds a dl_bw of 0.
> - The deboost of a later priority inheritance boost finds no
> parameters.
>
> An owner that the task boosts as a waiter can find the parameters
> cleared too. "sched/deadline: Do not replenish a boost from cleared
> parameters" handles this, so a backport needs it first. Without it, the
> owner's CPU can lock up as soon as the waiter leaves the class.
>
> Juri Lelli's first fix, since dropped from tip, released the bandwidth
> here without clearing dl_bw. The bandwidth of a boosted task was then
> released twice.
>
> Juri Lelli suggested the call to task_non_contending() in review.
>
> The Sashiko AI review of the third posting found the two cases with the
> 0-lag time ahead. deadline_bw_test, added later in this series, tests
> this in pi_former_owner_asleep and deboost_released_resets_period.
>
> Fixes: 209a0cbda7a0 ("sched/deadline: Improve the tracking of active utilization")
> Reported-by: Tejun Heo <tj@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/2b5fb3f22bca6aa383be8f4781923392@xxxxxxxxxx/
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Link: https://lore.kernel.org/all/20261103-b4-sched-dl-bw-fixes-v1-2-dd761fe005b4@xxxxxxxxxx/
> ---
Reviewed-by: Juri Lelli <juri.lelli@xxxxxxxxxx>
Thanks,
Juri