[PATCH v5 02/14] sched/debug: Stop and start server based on if it was active

Joel Fernandes
2025-06-20T20:32:52Z

Currently the DL server interface for applying parameters checks
CFS-internals to identify if the server is active. This is error-prone
and makes it difficult when adding new servers in the future.

Fix it, by using dl_server_active() which is also used by the DL server
code to determine if the DL server was started.

Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
kernel/sched/debug.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 9db3fcb4bc8b..276d51a5690a 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -349,6 +349,7 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
{
long cpu = (long) ((struct seq_file *) filp->private_data)->private;
struct rq *rq = cpu_rq(cpu);
+ bool was_active = false;
u64 runtime, period;
int retval = 0;
size_t err;
@@ -381,7 +382,8 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
return -EINVAL;
}

- if (rq->cfs.h_nr_queued) {
+ if (dl_server_active(&rq->fair_server)) {
+ was_active = true;
update_rq_clock(rq);
dl_server_stop(&rq->fair_server);
}
@@ -392,7 +394,7 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
printk_deferred("Fair server disabled in CPU %d, system may crash due to starvation.\n",
cpu_of(rq));

- if (rq->cfs.h_nr_queued)
+ if (was_active)
dl_server_start(&rq->fair_server);

if (retval < 0)
--
2.43.0