[PATCH v5 07/14] sched: Add a server arg to dl_server_update_idle_time()

Joel Fernandes
2025-06-20T20:33:00Z

Since we are adding more servers, make dl_server_update_idle_time()
accept a server argument than a specific server.

Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
---
kernel/sched/deadline.c | 17 +++++++++--------
kernel/sched/fair.c | 2 +-
kernel/sched/idle.c | 2 +-
kernel/sched/sched.h | 3 ++-
4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index ca2a31da8107..562e1e7196b1 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1609,28 +1609,29 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64
* as time available for the fair server, avoiding a penalty for the
* rt scheduler that did not consumed that time.
*/
-void dl_server_update_idle_time(struct rq *rq, struct task_struct *p)
+void dl_server_update_idle_time(struct rq *rq, struct task_struct *p,
+ struct sched_dl_entity *rq_dl_server)
{
s64 delta_exec, scaled_delta_exec;

- if (!rq->fair_server.dl_defer)
+ if (!rq_dl_server->dl_defer)
return;

/* no need to discount more */
- if (rq->fair_server.runtime < 0)
+ if (rq_dl_server->runtime < 0)
return;

delta_exec = rq_clock_task(rq) - p->se.exec_start;
if (delta_exec < 0)
return;

- scaled_delta_exec = dl_scaled_delta_exec(rq, &rq->fair_server, delta_exec);
+ scaled_delta_exec = dl_scaled_delta_exec(rq, rq_dl_server, delta_exec);

- rq->fair_server.runtime -= scaled_delta_exec;
+ rq_dl_server->runtime -= scaled_delta_exec;

- if (rq->fair_server.runtime < 0) {
- rq->fair_server.dl_defer_running = 0;
- rq->fair_server.runtime = 0;
+ if (rq_dl_server->runtime < 0) {
+ rq_dl_server->dl_defer_running = 0;
+ rq_dl_server->runtime = 0;
}

p->se.exec_start = rq_clock_task(rq);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6bf097e39b4a..033f12ba7f2a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7026,7 +7026,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
if (!rq_h_nr_queued && rq->cfs.h_nr_queued) {
/* Account for idle runtime */
if (!rq->nr_running)
- dl_server_update_idle_time(rq, rq->curr);
+ dl_server_update_idle_time(rq, rq->curr, &rq->fair_server);
dl_server_start(&rq->fair_server);
}

diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 01e9612deefe..13a3d20d35e2 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -451,7 +451,7 @@ static void wakeup_preempt_idle(struct rq *rq, struct task_struct *p, int flags)

static void put_prev_task_idle(struct rq *rq, struct task_struct *prev, struct task_struct *next)
{
- dl_server_update_idle_time(rq, prev);
+ dl_server_update_idle_time(rq, prev, &rq->fair_server);
scx_update_idle(rq, false, true);
}

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 35d7b328a9c7..1ac2fb398982 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -386,7 +386,8 @@ extern void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq,
dl_server_pick_f pick_task);

extern void dl_server_update_idle_time(struct rq *rq,
- struct task_struct *p);
+ struct task_struct *p,
+ struct sched_dl_entity *rq_dl_server);
extern void fair_server_init(struct rq *rq);
extern void __dl_server_attach_root(struct sched_dl_entity *dl_se, struct rq *rq);
extern int dl_server_apply_params(struct sched_dl_entity *dl_se,
--
2.43.0