[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250704143612.998419-5-vincent.guittot@linaro.org>
Date: Fri, 4 Jul 2025 16:36:10 +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,
dhaval@...nis.ca,
linux-kernel@...r.kernel.org
Cc: Vincent Guittot <vincent.guittot@...aro.org>
Subject: [PATCH v2 4/6] sched/fair: Limit run to parity to the min slice of enqueued entities
Run to parity ensures that current will get a chance to run its full
slice in one go but this can create large latency and/or lag for
entities with shorter slice that has exhausted their previous slice
and wait to run their next slice.
Clamp the run to parity to the shortest slice of all enqueued entities.
Signed-off-by: Vincent Guittot <vincent.guittot@...aro.org>
---
kernel/sched/fair.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2e624a769b86..2a0348b0cc3d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -884,16 +884,20 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
/*
* HACK, Set the vruntime up to which an entity can run before picking another
* one, in vlag, which isn't used until dequeue.
- * In case of run to parity, we let the entity run to its deadline.
+ * In case of run to parity, we use the shortest slice of the enqueued entities
+ * to define the longest runtime.
* When run to parity is disabled, we give a minimum quantum to the running
* entity to ensure progress.
*/
static inline void set_protect_slice(struct sched_entity *se)
{
- u64 quantum = se->slice;
+ u64 quantum;
- if (!sched_feat(RUN_TO_PARITY))
- quantum = min(quantum, normalized_sysctl_sched_base_slice);
+ if (sched_feat(RUN_TO_PARITY))
+ quantum = cfs_rq_min_slice(cfs_rq_of(se));
+ else
+ quantum = normalized_sysctl_sched_base_slice;
+ quantum = min(quantum, se->slice);
if (quantum != se->slice)
se->vlag = min(se->deadline, se->vruntime + calc_delta_fair(quantum, se));
--
2.43.0
Powered by blists - more mailing lists