public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: pugaowei <pugaowei@oppo.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com
Cc: linux-kernel@vger.kernel.org, pugaowei <pugaowei@oppo.com>
Subject: [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()
Date: Fri, 31 May 2024 11:08:33 +0800	[thread overview]
Message-ID: <20240531030833.3375-1-pugaowei@oppo.com> (raw)

we should update the weight of cfs_rq before update_cfs_group().
Ensure that we can get accurate shares of the cfs_rq when its
weights changes. we can find this work was done correctly in
dequeue_entity(). so fix it.

Signed-off-by: pugaowei <pugaowei@oppo.com>
---
 kernel/sched/fair.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a5b1ae0aa55..395840f3fa1d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5304,6 +5304,12 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 	 */
 	update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH);
 	se_update_runnable(se);
+
+	/*
+	 * we should update the weight of cfs_rq before update_cfs_group.
+	 * Ensure we can get accurate shares of the cfs_rq when its weights changes.
+	 */
+	account_entity_enqueue(cfs_rq, se);
 	/*
 	 * XXX update_load_avg() above will have attached us to the pelt sum;
 	 * but update_cfs_group() here will re-adjust the weight and have to
@@ -5318,8 +5324,6 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 	if (!curr)
 		place_entity(cfs_rq, se, flags);
 
-	account_entity_enqueue(cfs_rq, se);
-
 	/* Entity has migrated, no longer consider this task hot */
 	if (flags & ENQUEUE_MIGRATED)
 		se->exec_start = 0;
-- 
2.17.1


             reply	other threads:[~2024-05-31  3:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  3:08 pugaowei [this message]
2024-06-03  5:51 ` [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity() kernel test robot
2024-06-04  1:57   ` 答复: " 普高伟(kuroky)

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=20240531030833.3375-1-pugaowei@oppo.com \
    --to=pugaowei@oppo.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 \
    /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