From: "tip-bot2 for Fernand Sieber" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Fernand Sieber <sieberf@amazon.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Madadi Vineeth Reddy <vineethr@linux.ibm.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/core: Optimize core cookie matching check
Date: Tue, 11 Nov 2025 11:37:21 -0000 [thread overview]
Message-ID: <176286104123.498.6764400674538143303.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20251105152538.470586-1-sieberf@amazon.com>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 7f829bde94b1c97b1804fa5860e066ea49dbfca3
Gitweb: https://git.kernel.org/tip/7f829bde94b1c97b1804fa5860e066ea49dbfca3
Author: Fernand Sieber <sieberf@amazon.com>
AuthorDate: Wed, 05 Nov 2025 17:25:37 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 11 Nov 2025 12:33:37 +01:00
sched/core: Optimize core cookie matching check
Early return true if the core cookie matches. This avoids the SMT mask
loop to check for an idle core, which might be more expensive on wide
platforms.
Signed-off-by: Fernand Sieber <sieberf@amazon.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Link: https://patch.msgid.link/20251105152538.470586-1-sieberf@amazon.com
---
kernel/sched/sched.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index d04e007..82e74e8 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1432,6 +1432,9 @@ static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
if (!sched_core_enabled(rq))
return true;
+ if (rq->core->core_cookie == p->core_cookie)
+ return true;
+
for_each_cpu(cpu, cpu_smt_mask(cpu_of(rq))) {
if (!available_idle_cpu(cpu)) {
idle_core = false;
@@ -1443,7 +1446,7 @@ static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
* A CPU in an idle core is always the best choice for tasks with
* cookies.
*/
- return idle_core || rq->core->core_cookie == p->core_cookie;
+ return idle_core;
}
static inline bool sched_group_cookie_match(struct rq *rq,
prev parent reply other threads:[~2025-11-11 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 15:25 [PATCH] sched: " Fernand Sieber
2025-11-05 16:34 ` K Prateek Nayak
2025-11-06 11:09 ` Peter Zijlstra
2025-11-06 10:27 ` Madadi Vineeth Reddy
2025-11-11 11:37 ` tip-bot2 for Fernand Sieber [this message]
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=176286104123.498.6764400674538143303.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sieberf@amazon.com \
--cc=vineethr@linux.ibm.com \
--cc=x86@kernel.org \
/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®