public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Sync se's load_avg with cfs_rq in reweight_entity
@ 2024-07-16 15:08 Chuyi Zhou
  2024-07-17 11:18 ` Chengming Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: Chuyi Zhou @ 2024-07-16 15:08 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot
  Cc: chengming.zhou, linux-kernel, Chuyi Zhou

In reweight_entity(), if !se->on_rq (e.g. when we are reweighting a
sleeping task), we should sync the load_avg of se to cfs_rq before calling
dequeue_load_avg(). Otherwise, the load_avg of this se can be inaccurate.

Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
---
 kernel/sched/fair.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9057584ec06d..2807f6e72ad1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3782,6 +3782,8 @@ static void reweight_eevdf(struct sched_entity *se, u64 avruntime,
 	se->deadline = avruntime + vslice;
 }
 
+static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags);
+
 static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
 			    unsigned long weight)
 {
@@ -3795,7 +3797,11 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
 		if (!curr)
 			__dequeue_entity(cfs_rq, se);
 		update_load_sub(&cfs_rq->load, se->load.weight);
+	} else {
+		/* Sync with the cfs_rq before removing our load_avg */
+		update_load_avg(cfs_rq, se, 0);
 	}
+
 	dequeue_load_avg(cfs_rq, se);
 
 	if (se->on_rq) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-18  2:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16 15:08 [PATCH] sched/fair: Sync se's load_avg with cfs_rq in reweight_entity Chuyi Zhou
2024-07-17 11:18 ` Chengming Zhou
2024-07-18  2:32   ` Chuyi Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox