[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <171378597395.10875.4756338867265230405.tip-bot2@tip-bot2>
Date: Mon, 22 Apr 2024 11:39:33 -0000
From: "tip-bot2 for Tianchen Ding" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Tianchen Ding <dtcccc@...ux.alibaba.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Abel Wu <wuyun.abel@...edance.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: sched/urgent] sched/eevdf: Fix miscalculation in
reweight_entity() when se is not curr
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: afae8002b4fd3560c8f5f1567f3c3202c30a70fa
Gitweb: https://git.kernel.org/tip/afae8002b4fd3560c8f5f1567f3c3202c30a70fa
Author: Tianchen Ding <dtcccc@...ux.alibaba.com>
AuthorDate: Wed, 06 Mar 2024 10:21:33 +08:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Mon, 22 Apr 2024 13:01:26 +02:00
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@...ux.alibaba.com>
[peterz: flip if() condition for clarity]
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Abel Wu <wuyun.abel@...edance.com>
Link: https://lkml.kernel.org/r/20240306022133.81008-3-dtcccc@linux.alibaba.com
---
kernel/sched/fair.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5551ce2..6d26691 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,24 +3786,26 @@ 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);
}
dequeue_load_avg(cfs_rq, se);
- if (!se->on_rq) {
+ if (se->on_rq) {
+ reweight_eevdf(se, avruntime, weight);
+ } else {
/*
* 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);
}
update_load_set(&se->load, weight);
Powered by blists - more mailing lists