Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Vincent Guittot and committed by
Peter Zijlstra
052c3d87 9de74a98

+6 -4
+6 -4
kernel/sched/fair.c
··· 884 884 /* 885 885 * Set the vruntime up to which an entity can run before looking 886 886 * 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. 888 889 * When run to parity is disabled, we give a minimum quantum to the running 889 890 * entity to ensure progress. 890 891 */ 891 892 static inline void set_protect_slice(struct sched_entity *se) 892 893 { 893 - u64 slice = se->slice; 894 + u64 slice = normalized_sysctl_sched_base_slice; 894 895 u64 vprot = se->deadline; 895 896 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)); 898 899 900 + slice = min(slice, se->slice); 899 901 if (slice != se->slice) 900 902 vprot = min_vruntime(vprot, se->vruntime + calc_delta_fair(slice, se)); 901 903