Re: [PATCH v12 20/43] sched/deadline: Do not truncate a bandwidth to 32 bits in __dl_add/sub()

From: Juri Lelli

Date: Mon Nov 30 2026 - 07:57:04 EST


Hello,

On 27/11/26 09:35, Mathieu Desnoyers wrote:
> __dl_add() and __dl_sub() spread a change of total_bw over the extra_bw
> of the active CPUs of the root domain. Commit daec57983670
> ("sched/deadline: Reclaim bandwidth not used by dl tasks") added this,
> for the bandwidth of one task. That is at most 1 << 20, the bandwidth
> of one CPU.
>
> But cpuset_can_attach() reserves the sum of the bandwidths of all the
> deadline tasks it moves, with dl_bw_alloc(). __dl_add() and __dl_sub()
> cast the bandwidth to s32 before the division. Past S32_MAX, more than
> 2048 CPUs of deadline bandwidth, the cast flips its sign. The extra_bw
> of each CPU then moves the wrong way. GRUB lets reclaiming tasks run
> more than the free bandwidth, or less. This was found by reading. It
> needs a machine with more than 2048 CPUs, so no case tests it.
>
> Fix this by dividing on 64 bits, with div_u64().
>
> The Sashiko AI review of the first series found this.
>
> Fixes: daec57983670 ("sched/deadline: Reclaim bandwidth not used by dl tasks")
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---

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

Thanks,
Juri