[PATCH] sched/fair: Reset vlag in dequeue when PLAGE_LAG is disabled
From: Chunxin Zang
Date: Fri Mar 29 2024 - 05:20:29 EST
The vlag is calculated in dequeue when PLAGE_LAG is disabled. If we
enable the PLACE_LAG at some point, the old vlag of process will
affect itself and other process. These are not in line with our
original intention, where we expect the vlag of all processes to be
calculated from 0 after the enable PLAGE_LAG.
Reviewed-by: Chen Yang <yangchen11@xxxxxxxxxxx>
Signed-off-by: Chunxin Zang <spring.cxz@xxxxxxxxx>
---
kernel/sched/fair.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 03be0d1330a6..bc103a1ee78a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3798,16 +3798,17 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
}
dequeue_load_avg(cfs_rq, se);
- if (!se->on_rq) {
+ if (sched_feat(PLACE_LAG) && !se->on_rq) {
/*
* Because we keep se->vlag = V - v_i, while: lag_i = w_i*(V - v_i),
* we need to scale se->vlag when w_i changes.
*/
se->vlag = div_s64(se->vlag * se->load.weight, weight);
- } else {
- reweight_eevdf(cfs_rq, se, weight);
}
+ if (se->on_rq)
+ reweight_eevdf(cfs_rq, se, weight);
+
update_load_set(&se->load, weight);
#ifdef CONFIG_SMP
@@ -5382,7 +5383,11 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
clear_buddies(cfs_rq, se);
- update_entity_lag(cfs_rq, se);
+ if (sched_feat(PLACE_LAG))
+ update_entity_lag(cfs_rq, se);
+ else
+ se->vlag = 0;
+
if (se != cfs_rq->curr)
__dequeue_entity(cfs_rq, se);
se->on_rq = 0;
--
2.34.1