Skip to content

Commit 052c3d8

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
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 have 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@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20250708165630.1948751-5-vincent.guittot@linaro.org
1 parent 9de74a9 commit 052c3d8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

kernel/sched/fair.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,18 +884,20 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
884884
/*
885885
* Set the vruntime up to which an entity can run before looking
886886
* for another entity to pick.
887-
* In case of run to parity, we protect the entity up to its deadline.
887+
* In case of run to parity, we use the shortest slice of the enqueued
888+
* entities to set the protected period.
888889
* When run to parity is disabled, we give a minimum quantum to the running
889890
* entity to ensure progress.
890891
*/
891892
static inline void set_protect_slice(struct sched_entity *se)
892893
{
893-
u64 slice = se->slice;
894+
u64 slice = normalized_sysctl_sched_base_slice;
894895
u64 vprot = se->deadline;
895896

896-
if (!sched_feat(RUN_TO_PARITY))
897-
slice = min(slice, normalized_sysctl_sched_base_slice);
897+
if (sched_feat(RUN_TO_PARITY))
898+
slice = cfs_rq_min_slice(cfs_rq_of(se));
898899

900+
slice = min(slice, se->slice);
899901
if (slice != se->slice)
900902
vprot = min_vruntime(vprot, se->vruntime + calc_delta_fair(slice, se));
901903

0 commit comments

Comments
 (0)