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 <[email protected]>
---
kernel/sched/fair.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5551ce2af73e..091a1a750638 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3676,11 +3676,10 @@ static inline void
dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
#endif
-static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
+static void reweight_eevdf(struct sched_entity *se, u64 avruntime,
unsigned long weight)
{
unsigned long old_weight = se->load.weight;
- u64 avruntime = avg_vruntime(cfs_rq);
s64 vlag, vslice;
/*
@@ -3787,10 +3786,12 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
unsigned long weight)
{
bool curr = cfs_rq->curr == se;
+ u64 avruntime;
if (se->on_rq) {
/* commit outstanding execution time */
update_curr(cfs_rq);
+ avruntime = avg_vruntime(cfs_rq);
if (!curr)
__dequeue_entity(cfs_rq, se);
update_load_sub(&cfs_rq->load, se->load.weight);
@@ -3804,7 +3805,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
*/
se->vlag = div_s64(se->vlag * se->load.weight, weight);
} else {
- reweight_eevdf(cfs_rq, se, weight);
+ reweight_eevdf(se, avruntime, weight);
}
update_load_set(&se->load, weight);
--
2.39.3
On 3/4/24 11:00 AM, Tianchen Ding Wrote:
> 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 <[email protected]>
> ---
> kernel/sched/fair.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 5551ce2af73e..091a1a750638 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3676,11 +3676,10 @@ static inline void
> dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { }
> #endif
>
> -static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
> +static void reweight_eevdf(struct sched_entity *se, u64 avruntime,
> unsigned long weight)
> {
> unsigned long old_weight = se->load.weight;
> - u64 avruntime = avg_vruntime(cfs_rq);
> s64 vlag, vslice;
>
> /*
> @@ -3787,10 +3786,12 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> unsigned long weight)
> {
> bool curr = cfs_rq->curr == se;
> + u64 avruntime;
>
> if (se->on_rq) {
> /* commit outstanding execution time */
> update_curr(cfs_rq);
> + avruntime = avg_vruntime(cfs_rq);
> if (!curr)
> __dequeue_entity(cfs_rq, se);
> update_load_sub(&cfs_rq->load, se->load.weight);
> @@ -3804,7 +3805,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> */
> se->vlag = div_s64(se->vlag * se->load.weight, weight);
> } else {
> - reweight_eevdf(cfs_rq, se, weight);
> + reweight_eevdf(se, avruntime, weight);
> }
>
> update_load_set(&se->load, weight);
Reviewed-by: Abel Wu <[email protected]>