Re: [PATCH v6 05/37] sched/deadline: Refuse dl_server debugfs writes while the rq is offline
From: sashiko-bot
Date: Mon Nov 16 2026 - 14:30:38 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 20746e8301600abc34772d08e7fcdc3dbeb36656
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;
[Severity: Medium]
Can a debugfs write still slip through during sched_cpu_deactivate() after
cpu_active(cpu) is cleared?
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()
dl_server_start()
sched_set_rq_offline(rq, cpu)
rq->online = 0
During the synchronize_rcu() window, rq->online is still 1 and the root
domain has not yet been rebuilt by cpuset_cpu_inactive(), but cpu_active(cpu)
is already false. In dl_server_apply_params(), dl_bw_cpus(cpu) and
dl_bw_capacity(cpu) weight rd->span against cpu_active_mask, so they exclude
the deactivating CPU while dl_b->total_bw still includes its server
bandwidth. If this was the last active CPU in its root domain, cpus and cap
are 0; if other active CPUs remain, __dl_overflow() checks N servers against
N - 1 CPUs' capacity and __dl_sub() / __dl_add() miscalculate extra_bw
across N - 1 CPUs. dl_server_start() also re-enqueues the server on the
deactivating runqueue after balance_push_set(cpu, true).
Checking (!rq->online || !cpu_active(cpu_of(rq))) under the rq lock would
cover both the activation and deactivation windows.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116190549.230119-1-mathieu.desnoyers@xxxxxxxxxxxx?part=5