linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chunxin Zang <spring.cxz@gmail.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org
Cc: dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
	vschneid@redhat.com, linux-kernel@vger.kernel.org,
	yangchen11@lixiang.com, zhouchunhua@lixiang.com,
	zangchunxin@lixiang.com, Chunxin Zang <spring.cxz@gmail.com>
Subject: [PATCH] sched/fair: Reset vlag in dequeue when PLAGE_LAG is disabled
Date: Fri, 29 Mar 2024 17:19:33 +0800	[thread overview]
Message-ID: <20240329091933.340739-1-spring.cxz@gmail.com> (raw)

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@lixiang.com>
Signed-off-by: Chunxin Zang <spring.cxz@gmail.com>
---
 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


                 reply	other threads:[~2024-03-29  9:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240329091933.340739-1-spring.cxz@gmail.com \
    --to=spring.cxz@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=yangchen11@lixiang.com \
    --cc=zangchunxin@lixiang.com \
    --cc=zhouchunhua@lixiang.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).