Re: [PATCH v2 1/2] sched/deadline: Fix divide-by-zero in DL bandwidth accounting

From: Juri Lelli

Date: Tue Sep 22 2026 - 08:50:23 EST


Hello,

On 20/09/26 00:31, Hui Su wrote:
> During CPU hot-unplug, a CPU can be cleared from cpu_active_mask before it
> is marked offline. This can leave a window where dl_bw_cpus() returns zero
> for a root domain with no remaining active CPU.
>
> DL bandwidth paths can pass this zero CPU count to __dl_sub() and
> __dl_add(), which then divide by zero while distributing the bandwidth
> update to active runqueues.
>
> This is not specific to the DL server debugfs path. Mikhail Zaslonko
> reported the same failure on s390x through sched_setscheduler(), where
> task_non_contending() reached __dl_sub() with no active CPU in the root
> domain. Other DL bandwidth paths use the same helpers.
>
> Keep updating dl_bw::total_bw when the CPU count is zero, but skip
> __dl_update(), since there are no active runqueues to receive an extra_bw
> adjustment. This avoids the division by zero in all callers while retaining
> the existing total_bw update.
>
> Fixes: daec57983670 ("sched/deadline: Reclaim bandwidth not used by dl tasks")
> Reported-by: Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx>
> Link: https://lore.kernel.org/r/c52c9e8c-260e-49a4-a88e-229e0795d07b@xxxxxxxxxxxxx
> Suggested-by: Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Hui Su <sh_def@xxxxxxx>
> ---

Looks good to me.

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

Thanks,
Juri