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: eab03c23c2a1 ("sched/eevdf: Fix vruntime adjustment on reweight")
Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com>
[peterz: flip if() condition for clarity]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Abel Wu <wuyun.abel@bytedance.com>
Link: https://lkml.kernel.org/r/20240306022133.81008-3-dtcccc@linux.alibaba.com

authored by Tianchen Ding and committed by Peter Zijlstra afae8002 11b1b8bc

Changed files
+6 -5
kernel
sched
+6 -5
kernel/sched/fair.c
··· 3676 3676 dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } 3677 3677 #endif 3678 3678 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, 3680 3680 unsigned long weight) 3681 3681 { 3682 3682 unsigned long old_weight = se->load.weight; 3683 - u64 avruntime = avg_vruntime(cfs_rq); 3684 3683 s64 vlag, vslice; 3685 3684 3686 3685 /* ··· 3786 3787 unsigned long weight) 3787 3788 { 3788 3789 bool curr = cfs_rq->curr == se; 3790 + u64 avruntime; 3789 3791 3790 3792 if (se->on_rq) { 3791 3793 /* commit outstanding execution time */ 3792 3794 update_curr(cfs_rq); 3795 + avruntime = avg_vruntime(cfs_rq); 3793 3796 if (!curr) 3794 3797 __dequeue_entity(cfs_rq, se); 3795 3798 update_load_sub(&cfs_rq->load, se->load.weight); 3796 3799 } 3797 3800 dequeue_load_avg(cfs_rq, se); 3798 3801 3799 - if (!se->on_rq) { 3802 + if (se->on_rq) { 3803 + reweight_eevdf(se, avruntime, weight); 3804 + } else { 3800 3805 /* 3801 3806 * Because we keep se->vlag = V - v_i, while: lag_i = w_i*(V - v_i), 3802 3807 * we need to scale se->vlag when w_i changes. 3803 3808 */ 3804 3809 se->vlag = div_s64(se->vlag * se->load.weight, weight); 3805 - } else { 3806 - reweight_eevdf(cfs_rq, se, weight); 3807 3810 } 3808 3811 3809 3812 update_load_set(&se->load, weight);