[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250613140514.2781138-5-vincent.guittot@linaro.org>
Date: Fri, 13 Jun 2025 16:05:14 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: mingo@...hat.com,
peterz@...radead.org,
juri.lelli@...hat.com,
dietmar.eggemann@....com,
rostedt@...dmis.org,
bsegall@...gle.com,
mgorman@...e.de,
vschneid@...hat.com,
linux-kernel@...r.kernel.org
Cc: Vincent Guittot <vincent.guittot@...aro.org>
Subject: [PATCH 4/4] sched/fair: Improve NO_RUN_TO_PARITY
The slice protection of RUN_TO_PARITY should also be applied with a
minimal quantum of time for NO_RUN_TO_PARITY in order to ensure a minimum
runtime for each task with same slice duration but also to ensure
periodic switch between threads.
Signed-off-by: Vincent Guittot <vincent.guittot@...aro.org>
---
kernel/sched/fair.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d8345219dfd4..73bde511c53b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -921,15 +921,20 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
* one in vlag, which isn't used until dequeue.
* In case of run to parity, we use the shortest slice of the enqueued
* entities.
+ * When run to parity is disable we give a minimum quantum to the
+ * running entity to ensure progress.
*/
static inline void set_protect_slice(struct sched_entity *se)
{
- u64 min_slice;
+ u64 quantum;
- min_slice = cfs_rq_min_slice(cfs_rq_of(se));
+ if (sched_feat(RUN_TO_PARITY))
+ quantum = cfs_rq_min_slice(cfs_rq_of(se));
+ else
+ quantum = min(se->slice, normalized_sysctl_sched_base_slice);
- if (min_slice != se->slice)
- se->vlag = min(se->deadline, se->vruntime + calc_delta_fair(min_slice, se));
+ if (quantum != se->slice)
+ se->vlag = min(se->deadline, se->vruntime + calc_delta_fair(quantum, se));
else
se->vlag = se->deadline;
}
@@ -981,7 +986,7 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr)))
curr = NULL;
- if (sched_feat(RUN_TO_PARITY) && curr && protect_slice(curr))
+ if (curr && protect_slice(curr))
return curr;
/* Pick the leftmost entity if it's eligible */
@@ -1215,11 +1220,8 @@ static inline void update_curr_task(struct task_struct *p, s64 delta_exec)
cgroup_account_cputime(p, delta_exec);
}
-static inline bool did_preempt_short(struct cfs_rq *cfs_rq, struct sched_entity *curr)
+static inline bool resched_next_quantum(struct cfs_rq *cfs_rq, struct sched_entity *curr)
{
- if (!sched_feat(PREEMPT_SHORT))
- return false;
-
if (protect_slice(curr))
return false;
@@ -1307,7 +1309,7 @@ static void update_curr(struct cfs_rq *cfs_rq)
if (cfs_rq->nr_queued == 1)
return;
- if (resched || did_preempt_short(cfs_rq, curr)) {
+ if (resched || resched_next_quantum(cfs_rq, curr)) {
resched_curr_lazy(rq);
clear_buddies(cfs_rq, curr);
}
--
2.43.0
Powered by blists - more mailing lists