[tip: sched/core] sched: Clean up DL server vs core sched
From: tip-bot2 for Peter Zijlstra
Date: Tue Sep 03 2024 - 09:39:32 EST
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 4686cc598f669dea1b50dde1568e6c65c355bc67
Gitweb: https://git.kernel.org/tip/4686cc598f669dea1b50dde1568e6c65c355bc67
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
AuthorDate: Wed, 14 Aug 2024 00:25:51 +02:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Tue, 03 Sep 2024 15:26:31 +02:00
sched: Clean up DL server vs core sched
Abide by the simple rule:
pick_next_task() := pick_task() + set_next_task(.first = true)
This allows us to trivially get rid of server_pick_next() and things
collapse nicely.
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20240813224015.837303391@xxxxxxxxxxxxx
---
include/linux/sched.h | 1 -
kernel/sched/deadline.c | 18 +++++++-----------
kernel/sched/fair.c | 13 +------------
kernel/sched/sched.h | 1 -
4 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3709ded..57cf27a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -692,7 +692,6 @@ struct sched_dl_entity {
*/
struct rq *rq;
dl_server_has_tasks_f server_has_tasks;
- dl_server_pick_f server_pick_next;
dl_server_pick_f server_pick_task;
#ifdef CONFIG_RT_MUTEXES
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index f7ac7cf..2ea929c 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1665,12 +1665,10 @@ void dl_server_stop(struct sched_dl_entity *dl_se)
void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq,
dl_server_has_tasks_f has_tasks,
- dl_server_pick_f pick_next,
dl_server_pick_f pick_task)
{
dl_se->rq = rq;
dl_se->server_has_tasks = has_tasks;
- dl_se->server_pick_next = pick_next;
dl_se->server_pick_task = pick_task;
}
@@ -2404,9 +2402,8 @@ static struct sched_dl_entity *pick_next_dl_entity(struct dl_rq *dl_rq)
/*
* __pick_next_task_dl - Helper to pick the next -deadline task to run.
* @rq: The runqueue to pick the next task from.
- * @peek: If true, just peek at the next task. Only relevant for dlserver.
*/
-static struct task_struct *__pick_next_task_dl(struct rq *rq, bool peek)
+static struct task_struct *__pick_task_dl(struct rq *rq)
{
struct sched_dl_entity *dl_se;
struct dl_rq *dl_rq = &rq->dl;
@@ -2420,10 +2417,7 @@ again:
WARN_ON_ONCE(!dl_se);
if (dl_server(dl_se)) {
- if (IS_ENABLED(CONFIG_SMP) && peek)
- p = dl_se->server_pick_task(dl_se);
- else
- p = dl_se->server_pick_next(dl_se);
+ p = dl_se->server_pick_task(dl_se);
if (!p) {
dl_se->dl_yielded = 1;
update_curr_dl_se(rq, dl_se, 0);
@@ -2440,7 +2434,7 @@ again:
#ifdef CONFIG_SMP
static struct task_struct *pick_task_dl(struct rq *rq)
{
- return __pick_next_task_dl(rq, true);
+ return __pick_task_dl(rq);
}
#endif
@@ -2448,11 +2442,13 @@ static struct task_struct *pick_next_task_dl(struct rq *rq)
{
struct task_struct *p;
- p = __pick_next_task_dl(rq, false);
+ p = __pick_task_dl(rq);
if (!p)
return p;
- if (!p->dl_server)
+ if (p->dl_server)
+ p->sched_class->set_next_task(rq, p, true);
+ else
set_next_task_dl(rq, p, true);
return p;
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index eaeb8b2..8379100 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8862,16 +8862,7 @@ static bool fair_server_has_tasks(struct sched_dl_entity *dl_se)
static struct task_struct *fair_server_pick_task(struct sched_dl_entity *dl_se)
{
-#ifdef CONFIG_SMP
return pick_task_fair(dl_se->rq);
-#else
- return NULL;
-#endif
-}
-
-static struct task_struct *fair_server_pick_next(struct sched_dl_entity *dl_se)
-{
- return pick_next_task_fair(dl_se->rq, NULL, NULL);
}
void fair_server_init(struct rq *rq)
@@ -8880,9 +8871,7 @@ void fair_server_init(struct rq *rq)
init_dl_entity(dl_se);
- dl_server_init(dl_se, rq, fair_server_has_tasks, fair_server_pick_next,
- fair_server_pick_task);
-
+ dl_server_init(dl_se, rq, fair_server_has_tasks, fair_server_pick_task);
}
/*
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index d33311d..80605e2 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -362,7 +362,6 @@ extern void dl_server_start(struct sched_dl_entity *dl_se);
extern void dl_server_stop(struct sched_dl_entity *dl_se);
extern void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq,
dl_server_has_tasks_f has_tasks,
- dl_server_pick_f pick_next,
dl_server_pick_f pick_task);
extern void dl_server_update_idle_time(struct rq *rq,