Re: [PATCH] sched/rt: use u64 for RT group bandwidth accounting

From: Joseph Salisbury

Date: Fri Apr 03 2026 - 16:31:57 EST



Thanks for the feedback, Michal!

On 4/1/26 5:48 AM, Michal Koutný wrote:
Hi.

On Tue, Mar 17, 2026 at 03:34:02PM -0400, Joseph Salisbury <joseph.salisbury@xxxxxxxxxx> wrote:
tg_rt_schedulable() sums the bandwidth ratios of all child RT groups
and compares the result against the bandwidth available to the parent.

On 32-bit builds, the running sum is stored in unsigned long and can
overflow when enough child groups are present.
As per my calculation this'd require at least 4096 sibling RT groups
(see to_ratio() and BW_SHIFT)...

In that case, an overcommitted hierarchy may incorrectly pass the
schedulability check.
...and I expect there'd other issues with so many so little RT groups
than allowing theoretically unschedulabile configuration.
You are right.  This is mostly a correctness fix for a corner case. This patch primarily addresses the case where the arithmetic can silently truncate on 32-bit.

Use u64 for the local bandwidth totals so the accumulated child sum and
the parent limit are compared without 32-bit overflow.
You may want to fix this also in to_ratio() return type as there are
other consumers besides this check. (Although, some conditions would
still be similarly exotic, e.g. normalize_cfs_quota(), like CFQ quota of
more than 4096 (32b!) CPUs.)

Thanks,
Michal
That's a good point.   I can send a v2 that returns u64 from to_ratio() and keeps the RT totals in u64 as well.