Re: [PATCH v7 27/40] sched/deadline: Move a task's bandwidth to the root domain it runs in

From: Mathieu Desnoyers

Date: Wed Nov 18 2026 - 08:40:16 EST


> Can dl_task_move_bw() move the departing bandwidth of a non-deadline
> task that was PI-boosted back into the deadline class?

Yes, and this is intended. A departed task boosted back is in the class.
A rebuild counts it where it runs, like any deadline task (see
switched_to_dl()). The move does the same thing at the wakeup.

The bandwidth is moved, not released. One root domain counts it at any
time. If the boost ends before the 0-lag time, the task goes back on the
departed list with the new record. Its inactive timer then releases the
bandwidth there. The move has no check for room. That is a known limit,
which the cover letter lists for this patch. This was checked by
reading.

> Does skipping dl_task_move_bw() when p->is_blocked &&
> task_on_rq_migrating(p) also drop the bandwidth move for normal
> queued migrations of mutex-blocked tasks under
> CONFIG_SCHED_PROXY_EXEC?

Yes, thanks. On this base, proxy_set_task_cpu() does not call
migrate_task_rq_dl(). So the check guarded no proxy migration. It only
skipped the ordinary migrations of a blocked task.

With admission control on, I found no such migration that crosses root
domains. sched_setaffinity() must keep the span, patch 28 keeps the task
in it, and a cpuset attach moves the bandwidth itself. With admission
control off, sched_setaffinity() can cross. The bandwidth then stays
behind until the task sleeps and wakes, or migrates again.

The next version removes the check. It stays in the proxy execution RFC,
in the patch that makes a proxy migration call migrate_task_rq(). That
series also wakes a blocked deadline task through the full path, which
moves the bandwidth. This was checked by reading, not reproduced.

> Can keeping dl_bw_rebuilding() true until the end of the tasklist
> walk drop bandwidth moves for tasks that dl_add_task_root_domain()
> has already visited?

Yes. The message says the rebuild that follows counts the task. That
holds only for a task the walk has not reached yet.

The root domains are final once the walk starts. So the next version
ends the rebuild window in dl_clear_root_domains(). A flag,
dl_bw_walking, then covers the walk of the task list. A helper,
dl_bw_move_blocked(p), blocks a move in two cases:
- the sched domains are being rebuilt;
- the walk runs and has not counted p yet (p has an old dl_bw_gen).
The walk then counts p where it is. A task the walk already counted
moves its bandwidth again. The walk and a wakeup both hold the pi_lock
of the task, so they are ordered.

This moves the boundary of the known limit of patch 28. A wakeup can
pick its CPU before the walk reaches the task, and be queued after the
walk counted it. Its bandwidth then moves with no check for room. The
cover letter and the message of patch 28 state this.

> In addition, when dl_task_bw_elsewhere() runs under rq->__lock
> without p->pi_lock, it reads bw_cpu = READ_ONCE(p->dl.dl_bw_cpu)
> before checking dl_bw_rebuilding() and READ_ONCE(dl_bw_gen)

That lockless test is only a hint. dl_task_move_bw() reads the record
again under dl_departed_lock. A stale read can only skip a move. The
next wakeup or migration tests again. I left it.

Both points were checked by reading. Neither was reproduced.

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com