From: Zhaoyu Liu <zackary.liu.pro@gmail.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, kuyo.chang@mediatek.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg()
Date: Tue, 21 Jun 2022 23:45:40 +0800 [thread overview]
Message-ID: <20220621154530.GA29721@pc> (raw)
In commit 40f5aa4c5eae ("sched/pelt: Fix attach_entity_load_avg() corner case"),
these code was committed:
if (se_weight(se) < se->avg.load_sum)
se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
else
se->avg.load_sum = 1;
they could be replace with:
se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
to make the code cleaner.
Signed-off-by: Zhaoyu Liu <zackary.liu.pro@gmail.com>
---
kernel/sched/fair.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 78795a997d9c..ed32f66bbd3d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3881,10 +3881,7 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
se->avg.runnable_sum = se->avg.runnable_avg * divider;
se->avg.load_sum = se->avg.load_avg * divider;
- if (se_weight(se) < se->avg.load_sum)
- se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
- else
- se->avg.load_sum = 1;
+ se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)) ?: 1;
enqueue_load_avg(cfs_rq, se);
cfs_rq->avg.util_avg += se->avg.util_avg;
--
2.17.1
next reply other threads:[~2022-06-21 15:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 15:45 Zhaoyu Liu [this message]
2022-06-22 15:20 ` [PATCH] sched/pelt: simplify load_sum assignment code in attach_entity_load_avg() Vincent Guittot
2022-06-22 15:49 ` Zackary Liu
2022-07-15 14:33 ` Zackary Liu
2022-07-18 10:27 ` Vincent Guittot
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=20220621154530.GA29721@pc \
--to=zackary.liu.pro@gmail.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kuyo.chang@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.