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: Fix entity's lag with run to parity

When an entity is enqueued without preempting current, we must ensure
that the slice protection is updated to take into account the slice
duration of the newly enqueued task so that its lag will not exceed
its slice (+ tick).

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-6-vincent.guittot@linaro.org

authored by

Vincent Guittot and committed by
Peter Zijlstra
3a0baa8e 052c3d87

+13 -3
+13 -3
kernel/sched/fair.c
··· 889 889 * When run to parity is disabled, we give a minimum quantum to the running 890 890 * entity to ensure progress. 891 891 */ 892 - static inline void set_protect_slice(struct sched_entity *se) 892 + static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) 893 893 { 894 894 u64 slice = normalized_sysctl_sched_base_slice; 895 895 u64 vprot = se->deadline; 896 896 897 897 if (sched_feat(RUN_TO_PARITY)) 898 - slice = cfs_rq_min_slice(cfs_rq_of(se)); 898 + slice = cfs_rq_min_slice(cfs_rq); 899 899 900 900 slice = min(slice, se->slice); 901 901 if (slice != se->slice) 902 902 vprot = min_vruntime(vprot, se->vruntime + calc_delta_fair(slice, se)); 903 903 904 904 se->vprot = vprot; 905 + } 906 + 907 + static inline void update_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) 908 + { 909 + u64 slice = cfs_rq_min_slice(cfs_rq); 910 + 911 + se->vprot = min_vruntime(se->vprot, se->vruntime + calc_delta_fair(slice, se)); 905 912 } 906 913 907 914 static inline bool protect_slice(struct sched_entity *se) ··· 5474 5467 __dequeue_entity(cfs_rq, se); 5475 5468 update_load_avg(cfs_rq, se, UPDATE_TG); 5476 5469 5477 - set_protect_slice(se); 5470 + set_protect_slice(cfs_rq, se); 5478 5471 } 5479 5472 5480 5473 update_stats_curr_start(cfs_rq, se); ··· 8726 8719 */ 8727 8720 if (__pick_eevdf(cfs_rq, !do_preempt_short) == pse) 8728 8721 goto preempt; 8722 + 8723 + if (sched_feat(RUN_TO_PARITY) && do_preempt_short) 8724 + update_protect_slice(cfs_rq, se); 8729 8725 8730 8726 return; 8731 8727