mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] sched/fair: Sync se's load_avg with cfs_rq in reweight_task
@ 2024-07-20  5:12 Chuyi Zhou
  2024-07-22  5:17 ` K Prateek Nayak
  2024-07-22  6:34 ` Dietmar Eggemann
  0 siblings, 2 replies; 8+ messages in thread
From: Chuyi Zhou @ 2024-07-20  5:12 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, vschneid
  Cc: chengming.zhou, linux-kernel, Chuyi Zhou

In reweight_task(), there are two situations:

1. The task was on_rq, then the task's load_avg is accurate because we
synchronized it with cfs_rq through update_load_avg() in dequeue_task().

2. The task is sleeping, its load_avg might not have been updated for some
time, which can result in inaccurate dequeue_load_avg() in
reweight_entity().

This patch solves this by using update_load_avg() to synchronize the
load_avg of se with cfs_rq. For tasks were on_rq, since we already update
load_avg to accurate values in dequeue_task(), this change will not have
other effects due to the short time interval between the two updates.

Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
---
Changes in v2:
- change the description in commit log.
- use update_load_avg() in reweight_task() rather than in reweight_entity
suggested by chengming.
- Link to v1: https://lore.kernel.org/lkml/20240716150840.23061-1-zhouchuyi@bytedance.com/
---
 kernel/sched/fair.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9057584ec06d..b1e07ce90284 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3835,12 +3835,15 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
 	}
 }
 
+static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags);
+
 void reweight_task(struct task_struct *p, const struct load_weight *lw)
 {
 	struct sched_entity *se = &p->se;
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
 	struct load_weight *load = &se->load;
 
+	update_load_avg(cfs_rq, se, 0);
 	reweight_entity(cfs_rq, se, lw->weight);
 	load->inv_weight = lw->inv_weight;
 }
-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <66ee1520-48b8-4229-8bdd-9746c8bea5fe@bytedance.com>]

end of thread, other threads:[~2024-07-30 10:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-20  5:12 [PATCH v2] sched/fair: Sync se's load_avg with cfs_rq in reweight_task Chuyi Zhou
2024-07-22  5:17 ` K Prateek Nayak
2024-07-22  6:40   ` Chengming Zhou
2024-07-22  8:15     ` K Prateek Nayak
2024-07-28 20:14   ` Qais Yousef
2024-07-22  6:34 ` Dietmar Eggemann
2024-07-22  9:39   ` Chuyi Zhou
     [not found] <66ee1520-48b8-4229-8bdd-9746c8bea5fe@bytedance.com>
2024-07-30 10:26 ` Chuyi Zhou

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

all inboxes | Powered by JetHome®