Re: [PATCH v13 20/36] sched/deadline: Keep a task in the root domain that counts its bandwidth
From: sashiko-bot
Date: Tue Dec 01 2026 - 14:02:41 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: stale dl_bw_def for departed tasks in
dl_clear_root_domains()
--
commit 951a7fe2fe695c77ff8cf06e107558af78b19d1b
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
sched/deadline: Keep a task in the root domain that counts its bandwidth
This commit introduces dl_task_bw_span() and dl_bw_def tracking to keep
SCHED_DEADLINE tasks and their bandwidth in the root domain that admitted
them across CPU selection, hotplug, and sched domain rebuilds.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 67dfd3e11832b..0a925f91ebec7 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -4272,7 +4465,7 @@ void dl_add_task_root_domain(struct task_struct *p)
> raw_spin_lock(&dl_b->lock);
> __dl_add(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span));
> raw_spin_unlock(&dl_b->lock);
> - p->dl.dl_bw_cpu = cpu;
> + dl_record_bw_cpu(&p->dl, cpu);
> p->dl.dl_bw_gen = dl_bw_gen;
> unlock:
> raw_spin_unlock(&dl_departed_lock);
> @@ -4428,7 +4621,11 @@ void dl_clear_root_domains(void)
> * has not reached still waits for it: see dl_bw_move_blocked().
> */
> WARN_ON_ONCE(!(dl_bw_rebuild_seq & 1));
> - WRITE_ONCE(dl_bw_rebuild_seq, dl_bw_rebuild_seq + 1);
> + /*
> + * After the writes of rq->rd and of dl_bw_gen: pairs with the
> + * acquire in dl_task_bw_rd().
> + */
> + smp_store_release(&dl_bw_rebuild_seq, dl_bw_rebuild_seq + 1);
> WRITE_ONCE(dl_bw_walking, true);
> for_each_possible_cpu(cpu) {
> if (!dl_bw_visited(cpu, cookie))
[Severity: Medium]
Should the dl_departed_list loop in dl_clear_root_domains() also call
dl_record_bw_cpu(dl_se, cpu) when it re-counts a departed task's bandwidth?
kernel/sched/deadline.c:dl_clear_root_domains() {
...
list_for_each_entry(dl_se, &dl_departed_list, dl_departed_node) {
cpu = dl_se->dl_bw_cpu;
...
dl_b = dl_bw_of(cpu);
raw_spin_lock(&dl_b->lock);
__dl_add(dl_b, dl_se->dl_bw, dl_bw_cpus(cpu));
raw_spin_unlock(&dl_b->lock);
dl_se->dl_bw_gen = dl_bw_gen;
}
}
If the rebuild moved cpu into or out of def_root_domain (for example, when
a cpuset partition changes between root and isolated), dl_se->dl_bw_def is
left stale, and dl_add_task_root_domain() skips the task because
dl_se->dl_bw_gen is already equal to dl_bw_gen. If priority inheritance
then boosts the task back into dl_sched_class before its 0-lag time and
another rebuild runs, dl_task_rebuild_cpu() will read the stale dl_bw_def
and move the bandwidth to the wrong side without admission control.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796146461.git.mathieu.desnoyers@xxxxxxxxxxxx?part=20