Skip to content

Commit afae800

Browse files
dtccccPeter Zijlstra
authored andcommitted
sched/eevdf: Fix miscalculation in reweight_entity() when se is not curr
reweight_eevdf() only keeps V unchanged inside itself. When se != cfs_rq->curr, it would be dequeued from rb tree first. So that V is changed and the result is wrong. Pass the original V to reweight_eevdf() to fix this issue. Fixes: eab03c2 ("sched/eevdf: Fix vruntime adjustment on reweight") Signed-off-by: Tianchen Ding <[email protected]> [peterz: flip if() condition for clarity] Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Abel Wu <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 11b1b8b commit afae800

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

kernel/sched/fair.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,11 +3676,10 @@ static inline void
36763676
dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
36773677
#endif
36783678

3679-
static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
3679+
static void reweight_eevdf(struct sched_entity *se, u64 avruntime,
36803680
unsigned long weight)
36813681
{
36823682
unsigned long old_weight = se->load.weight;
3683-
u64 avruntime = avg_vruntime(cfs_rq);
36843683
s64 vlag, vslice;
36853684

36863685
/*
@@ -3787,24 +3786,26 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
37873786
unsigned long weight)
37883787
{
37893788
bool curr = cfs_rq->curr == se;
3789+
u64 avruntime;
37903790

37913791
if (se->on_rq) {
37923792
/* commit outstanding execution time */
37933793
update_curr(cfs_rq);
3794+
avruntime = avg_vruntime(cfs_rq);
37943795
if (!curr)
37953796
__dequeue_entity(cfs_rq, se);
37963797
update_load_sub(&cfs_rq->load, se->load.weight);
37973798
}
37983799
dequeue_load_avg(cfs_rq, se);
37993800

3800-
if (!se->on_rq) {
3801+
if (se->on_rq) {
3802+
reweight_eevdf(se, avruntime, weight);
3803+
} else {
38013804
/*
38023805
* Because we keep se->vlag = V - v_i, while: lag_i = w_i*(V - v_i),
38033806
* we need to scale se->vlag when w_i changes.
38043807
*/
38053808
se->vlag = div_s64(se->vlag * se->load.weight, weight);
3806-
} else {
3807-
reweight_eevdf(cfs_rq, se, weight);
38083809
}
38093810

38103811
update_load_set(&se->load, weight);

0 commit comments

Comments
 (0)