Re: [PATCH v2] sched: use u64 for bandwidth ratio calculations

From: Michal Koutný

Date: Tue Apr 07 2026 - 08:32:40 EST


On Fri, Apr 03, 2026 at 05:00:14PM -0400, Joseph Salisbury <joseph.salisbury@xxxxxxxxxx> wrote:
> to_ratio() computes BW_SHIFT-scaled bandwidth ratios from u64 period and
> runtime values, but it returns unsigned long. tg_rt_schedulable() also
> stores the current group limit and the accumulated child sum in unsigned
> long.
>
> On 32-bit builds, large bandwidth ratios can be truncated and the RT
> group sum can wrap when enough siblings are present. That can let an
> overcommitted RT hierarchy pass the schedulability check, and it also
> narrows the helper result for other callers.
>
> Return u64 from to_ratio() and use u64 for the RT group totals so
> bandwidth ratios are preserved and compared at full width on both 32-bit
> and 64-bit builds.

Thanks.

> Fixes: b40b2e8eb521 ("sched: rt: multi level group constraints")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: Codex:GPT-5
> Signed-off-by: Joseph Salisbury <joseph.salisbury@xxxxxxxxxx>
> ---
> v2:
> - Change to_ratio() to return u64 and update its declaration.
> - Keep tg_rt_schedulable() bandwidth totals in u64.
> - Drop the extra Fixes: tag and add Michal Koutny to Cc:.
>
> kernel/sched/core.c | 2 +-
> kernel/sched/rt.c | 2 +-
> kernel/sched/sched.h | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Michal Koutný <mkoutny@xxxxxxxx>

Attachment: signature.asc
Description: PGP signature