Skip to content

Commit 3a0baa8

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 052c3d8 commit 3a0baa8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

kernel/sched/fair.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,13 +889,13 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
889889
* When run to parity is disabled, we give a minimum quantum to the running
890890
* entity to ensure progress.
891891
*/
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)
893893
{
894894
u64 slice = normalized_sysctl_sched_base_slice;
895895
u64 vprot = se->deadline;
896896

897897
if (sched_feat(RUN_TO_PARITY))
898-
slice = cfs_rq_min_slice(cfs_rq_of(se));
898+
slice = cfs_rq_min_slice(cfs_rq);
899899

900900
slice = min(slice, se->slice);
901901
if (slice != se->slice)
@@ -904,6 +904,13 @@ static inline void set_protect_slice(struct sched_entity *se)
904904
se->vprot = vprot;
905905
}
906906

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));
912+
}
913+
907914
static inline bool protect_slice(struct sched_entity *se)
908915
{
909916
return ((s64)(se->vprot - se->vruntime) > 0);
@@ -5467,7 +5474,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
54675474
__dequeue_entity(cfs_rq, se);
54685475
update_load_avg(cfs_rq, se, UPDATE_TG);
54695476

5470-
set_protect_slice(se);
5477+
set_protect_slice(cfs_rq, se);
54715478
}
54725479

54735480
update_stats_curr_start(cfs_rq, se);
@@ -8720,6 +8727,9 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
87208727
if (__pick_eevdf(cfs_rq, !do_preempt_short) == pse)
87218728
goto preempt;
87228729

8730+
if (sched_feat(RUN_TO_PARITY) && do_preempt_short)
8731+
update_protect_slice(cfs_rq, se);
8732+
87238733
return;
87248734

87258735
preempt:

0 commit comments

Comments
 (0)