Re: [PATCH v7 05/40] sched/deadline: Refuse dl_server debugfs writes while the rq is offline

From: sashiko-bot

Date: Tue Nov 17 2026 - 09:39:20 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/debug: sched_server_write_common() misses CPU
deactivation window
--

commit 6c51bc6b398f0bfbd0028d2f5672f277e0ab2db8
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

sched/deadline: Refuse dl_server debugfs writes while the rq is offline

This commit replaces the cpu_online() check in sched_server_write_common()
with an !rq->online check to reject dl_server debugfs writes while a
runqueue is offline during CPU hotplug transitions.

> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index e6a3b516c703b..e0d6cd3bd607d 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -410,7 +410,15 @@ static ssize_t sched_server_write_common(struct file *filp, const char __user *u
> return -EINVAL;
> }
>
> - if (!cpu_online(cpu_of(rq)))
> + /*
> + * Refuse the write while the runqueue is offline. This
> + * includes the windows where the CPU goes offline or comes
> + * online. The root domain then does not count the server's
> + * bandwidth, and may have no active CPU. rq->online is set
> + * under this lock when the CPU joins a root domain that
> + * counts it. cpu_active() is set before that.
> + */
> + if (!rq->online)
> return -EBUSY;
>
> update_rq_clock(rq);

[Severity: Medium]
Does checking only !rq->online still leave a window during CPU
deactivation where cpu_active(cpu) is already false while rq->online is
still set?

In sched_cpu_deactivate(), set_cpu_active(cpu, false) clears the CPU from
cpu_active_mask before synchronize_rcu(), and sched_set_rq_offline() sets
rq->online = 0 only after synchronize_rcu() completes:

CPU0 CPU1
sched_cpu_deactivate(cpu)
set_cpu_active(cpu, false)
synchronize_rcu()
sched_server_write_common()
guard(rq_lock_irqsave)(rq)
if (!rq->online) // still 1
dl_server_apply_params()
cpus = dl_bw_cpus(cpu);
dl_server_start()
sched_set_rq_offline(rq, cpu)
rq->online = 0

Because dl_bw_cpus(cpu) and dl_bw_capacity(cpu) intersect rq->rd->span
with cpu_active_mask, they already exclude the deactivating CPU before
cpuset_cpu_inactive() rebuilds the root domain. If the CPU was the only
active CPU in its root domain (for example, a single-CPU cpuset
partition), dl_bw_cpus(cpu) is 0 while rq->online is still 1. Even when
N - 1 active CPUs remain in the root domain, dl_b->total_bw still counts
all N servers while __dl_overflow(), __dl_sub(), and __dl_add() account
against N - 1 CPUs, and dl_server_start() re-enqueues the server on the
deactivating runqueue after balance_push_set(cpu, true).

Checking (!rq->online || !cpu_active(cpu_of(rq))) under rq_lock_irqsave
would close both the activation and deactivation windows.

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794922146.git.mathieu.desnoyers@xxxxxxxxxxxx?part=5