From: lirongqing <lirongqing@baidu.com>
To: <tj@kernel.org>, <void@manifault.com>, <arighi@nvidia.com>,
<changwoo@igalia.com>, <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>, <vschneid@redhat.com>,
<linux-kernel@vger.kernel.org>
Cc: Li RongQing <lirongqing@baidu.com>
Subject: [PATCH] sched_ext: Simplify cpumask computation in balance_scx
Date: Fri, 7 Mar 2025 14:45:33 +0800 [thread overview]
Message-ID: <20250307064533.2663-1-lirongqing@baidu.com> (raw)
From: Li RongQing <lirongqing@baidu.com>
Compare SMT CPU against RQ CPU and skip balance it, to avoid calling
for_each_cpu_andnot() and cpumask_of(), they are relatively expensive
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
kernel/sched/ext.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 0f1da19..7e40ede 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2920,11 +2920,19 @@ static int balance_scx(struct rq *rq, struct task_struct *prev,
*/
if (sched_core_enabled(rq)) {
const struct cpumask *smt_mask = cpu_smt_mask(cpu_of(rq));
- int scpu;
+ int scpu, cpu;
- for_each_cpu_andnot(scpu, smt_mask, cpumask_of(cpu_of(rq))) {
- struct rq *srq = cpu_rq(scpu);
- struct task_struct *sprev = srq->curr;
+ cpu = cpu_of(rq);
+
+ for_each_cpu(scpu, smt_mask) {
+ struct rq *srq;
+ struct task_struct *sprev;
+
+ if (scpu == cpu)
+ continue;
+
+ srq = cpu_rq(scpu);
+ sprev = srq->curr;
WARN_ON_ONCE(__rq_lockp(rq) != __rq_lockp(srq));
update_rq_clock(srq);
--
2.9.4
next reply other threads:[~2025-03-07 6:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 6:45 lirongqing [this message]
2025-03-07 15:58 ` Tejun Heo
2025-03-08 13:32 ` 答复: [????] " Li,Rongqing
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=20250307064533.2663-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.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=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--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
all inboxes | Powered by JetHome®