Re: [PATCH v12 20/43] sched/deadline: Do not truncate a bandwidth to 32 bits in __dl_add/sub()
From: David Laight
Date: Tue Dec 01 2026 - 12:20:36 EST
On Tue, 1 Dec 2026 11:27:55 -0500
Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> wrote:
> On 2026-12-01 11:14, David Laight wrote:
> > You need to get the casts in the right order.
> > The quotient needs zero extending to 64bits before being negated.
> > eg -(s64)((u32)task_by / cpus)
> > or 0LL - (u32)task_bw / cpus.
> >
> > Although that is still only right for 4096 cpu.
>
> Right, with that order the negation is correct. The patch already
> negates in that order, after a 64-bit divide:
>
> -(s64)div_u64(tsk_bw, cpus)
>
> It divides on 64 bits because of the limit of 4096 CPUs. A cpuset
> attach reserves the sum of the bandwidths of the tasks it moves. That
> sum can pass U32_MAX on a machine with more than 4096 CPUs. v13 will
> keep this code as it is.
I should stop arguing :-)
That is only a 64 by 32 divide.
My brain flags up people adding 64 by 64 divides because one of the
build bots doesn't like a type and they haven't even considered the
domain of the value.
David
>
> > There is also the RCU_LOCKDEP check.
> > rcu is usually used lists (or similar) that are followed often but
> > relatively rarely modified.
> > I've not even tried to see what that is about.
>
> The check asserts that the caller is in an RCU-sched read section. That
> keeps the root domain alive while __dl_update() walks its span. It does
> not stop two CPUs from writing the same extra_bw at once.
>
> > If this code is only executed when cpu 'move' then I'd have thought
> > there would be minimal contention from a single global lock.
> > This code would then hold the lock.
>
> __dl_update() runs at each change of total_bw, not only at a CPU move.
> It runs from __dl_add() and __dl_sub(), on the paths listed in my
> first reply. Two calls of __dl_update() can only meet on a CPU that
> moves to another root domain. v13 will not fix this race.
>
> Thanks,
>
> Mathieu
>
>