Re: [PATCH] sched/deadline: Fix DL server divide-by-zero for inactive CPUs

From: Hui Su

Date: Sat Sep 19 2026 - 09:47:27 EST


> As for the patch, the same division is unguarded in several other callers
> in deadline.c:
>
> task_non_contending() (this trace)
> inactive_task_timer()
> set_cpus_allowed_dl()
> sched_dl_overflow()
> dl_bw_manage()
>
> Would it make sense to guard inside __dl_sub() and __dl_add() instead?

Hi Mikhail,

Thanks for the report and suggestion.

I agree that handling cpus == 0 in __dl_sub() and __dl_add() is the better
fix. I audited the other callers and reworked the fix in that direction.

I'm planning to post v2 as a two-patch series. The first patch handles
cpus == 0 in the common __dl_sub() and __dl_add() helpers, covering the
other DL bandwidth paths as well as the sched_setscheduler() failure you
reported. The second patch keeps the cpu_active() check for the newer
debugfs DL server interface.

I'm splitting them because the helper issue predates the DL server debugfs
interface, so keeping the generic fix separate also makes the review and
stable backport scope clearer.

I also added targeted tests for the task_non_contending() and
inactive_task_timer() zero-CPU paths, as well as cpus=0/1/2/4 accounting,
root-domain rebuild stress, and the set_cpus_allowed_dl() bandwidth-move
path. All passed on x86_64.

I'll post v2 shortly.

Thanks,
Hui