Re: [PATCH v13 18/36] sched/deadline: Make a rebuild count a task in the root domain it runs in
From: sashiko-bot
Date: Tue Dec 01 2026 - 14:12:02 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: missing dl_bw_gen check in
__dl_task_bw_move_cpu()
--
commit 7839622ca2175dc96fddcd96c7f89dcd473e1cdd
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Make a rebuild count a task in the root domain it runs in
This commit introduces dl_task_rebuild_cpu() to select the root domain
where a deadline task's bandwidth is counted during a rebuild, leaves out
live tasks that have no active CPU, and switches
dl_get_task_effective_cpus() to HK_TYPE_DOMAIN_BOOT.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index f618fee64f5bc..4b3c73c2a0d34 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -3992,12 +4059,20 @@ void dl_add_task_root_domain(struct task_struct *p)
> return;
> }
>
> - msk = this_cpu_cpumask_var_ptr(local_cpu_mask_dl);
> - dl_get_task_effective_cpus(p, msk);
> - cpu = cpumask_first_and(cpu_active_mask, msk);
> - BUG_ON(cpu >= nr_cpu_ids);
> -
> + cpu = dl_task_rebuild_cpu(p);
> raw_spin_lock(&dl_departed_lock);
> + if (cpu >= nr_cpu_ids && list_empty(&p->dl.dl_departed_node)) {
> + /*
> + * No active CPU can count the bandwidth of this task. Leave it
> + * out of this rebuild. dl_bw_gen then keeps its release from
> + * removing anything. A later rebuild, or
> + * dl_task_offline_migration(), counts it again. Do not leave
> + * out a departed task: the code below counts it on the CPU
> + * recorded, if that CPU is active.
> + */
> + goto unlock;
> + }
[Severity: Medium]
When a rebuild leaves a sleeping task out because its allowed isolated CPUs
went offline, p->dl.dl_bw_gen stays behind dl_bw_gen while
p->dl.dl_bw_cpu still points to an offline CPU whose runqueue is attached
to def_root_domain.
If the sleeping task is then moved via cpuset_attach to a cpuset with
active CPUs in def_root_domain (such as an active isolcpus="domain" CPU or
an isolated cpuset partition), can __dl_task_bw_move_cpu() and
set_cpus_allowed_dl() skip accounting its bandwidth in def_root_domain?
Neither function checks that p->dl.dl_bw_gen == dl_bw_gen before treating
p->dl.dl_bw_cpu's root domain as already counting the task:
kernel/sched/deadline.c:__dl_task_bw_move_cpu() {
...
cpu = dl_task_root_domain_cpu(p);
if (cpumask_intersects_and(cpu_rq(cpu)->rd->span, new_mask,
cpu_active_mask))
return -1;
...
}
kernel/sched/deadline.c:set_cpus_allowed_dl() {
...
if (p->dl.dl_bw && !dl_entity_is_special(&p->dl) &&
cpu_active(ctx->dl_bw_cpu) &&
cpumask_test_cpu(ctx->dl_bw_cpu, ctx->new_mask) &&
cpu_rq(src_cpu)->rd != cpu_rq(ctx->dl_bw_cpu)->rd) {
...
}
Because def_root_domain.span contains both the stale offline dl_bw_cpu and
the active destination CPUs in def_root_domain, __dl_task_bw_move_cpu()
returns -1 (and set_cpus_allowed_dl() sees matching root domains), so
cpuset_can_attach() skips admission control and the task's bandwidth
remains uncounted in def_root_domain.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796146461.git.mathieu.desnoyers@xxxxxxxxxxxx?part=18