Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c70fc32

Browse files
author
Peter Zijlstra
committed
sched/fair: Adhere to place_entity() constraints
Mike reports that commit 6d71a9c ("sched/fair: Fix EEVDF entity placement bug causing scheduling lag") relies on commit 4423af8 ("sched/fair: optimize the PLACE_LAG when se->vlag is zero") to not trip a WARN in place_entity(). What happens is that the lag of the very last entity is 0 per definition -- the average of one element matches the value of that element. Therefore place_entity() will match the condition skipping the lag adjustment: if (sched_feat(PLACE_LAG) && cfs_rq->nr_queued && se->vlag) { Without the 'se->vlag' condition -- it will attempt to adjust the zero lag even though we're inserting into an empty tree. Notably, we should have failed the 'cfs_rq->nr_queued' condition, but don't because they didn't get updated. Additionally, move update_load_add() after placement() as is consistent with other place_entity() users -- this change is non-functional, place_entity() does not use cfs_rq->load. Fixes: 6d71a9c ("sched/fair: Fix EEVDF entity placement bug causing scheduling lag") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reported-by: Mike Galbraith <[email protected]> Signed-off-by: "Peter Zijlstra (Intel)" <[email protected]> Signed-off-by: Mike Galbraith <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 44671e2 commit c70fc32

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/sched/fair.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3795,6 +3795,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
37953795
update_entity_lag(cfs_rq, se);
37963796
se->deadline -= se->vruntime;
37973797
se->rel_deadline = 1;
3798+
cfs_rq->nr_queued--;
37983799
if (!curr)
37993800
__dequeue_entity(cfs_rq, se);
38003801
update_load_sub(&cfs_rq->load, se->load.weight);
@@ -3821,10 +3822,11 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
38213822

38223823
enqueue_load_avg(cfs_rq, se);
38233824
if (se->on_rq) {
3824-
update_load_add(&cfs_rq->load, se->load.weight);
38253825
place_entity(cfs_rq, se, 0);
3826+
update_load_add(&cfs_rq->load, se->load.weight);
38263827
if (!curr)
38273828
__enqueue_entity(cfs_rq, se);
3829+
cfs_rq->nr_queued++;
38283830

38293831
/*
38303832
* The entity's vruntime has been adjusted, so let's check

0 commit comments

Comments
 (0)