From: Fernand Sieber <sieberf@amazon.com>
To: <mingo@redhat.com>, <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.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>, <dwmw@amazon.co.uk>,
<jschoenh@amazon.de>, <liuyuxua@amazon.com>
Subject: [PATCH 2/4] sched/fair: Still look for the idlest cpu with no matching cookie
Date: Mon, 22 Sep 2025 14:39:23 +0200 [thread overview]
Message-ID: <beefbc1474a94868c22b0351dedc0d7398b79c33.1758543008.git.sieberf@amazon.com> (raw)
In-Reply-To: <cover.1758543008.git.sieberf@amazon.com>
The slow path for waking tasks currently discards all potential targets
when no cookie-matching CPU is found, leading to suboptimal task placement.
Fall back to selecting the idlest CPU when no cookie-matching target is
available, ensuring better CPU utilization while maintaining the preference
for cookie-compatible placements.
Signed-off-by: Fernand Sieber <sieberf@amazon.com>
---
kernel/sched/fair.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 43ddfc25af99..67746899809e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7335,7 +7335,8 @@ sched_balance_find_dst_group(struct sched_domain *sd, struct task_struct *p, int
* sched_balance_find_dst_group_cpu - find the idlest CPU among the CPUs in the group.
*/
static int
-sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
+__sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *p,
+ int this_cpu, bool cookie_match)
{
unsigned long load, min_load = ULONG_MAX;
unsigned int min_exit_latency = UINT_MAX;
@@ -7352,7 +7353,8 @@ sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *
for_each_cpu_and(i, sched_group_span(group), p->cpus_ptr) {
struct rq *rq = cpu_rq(i);
- if (!sched_core_cookie_match(rq, p))
+ /* Only matching tasks if cookie_match, else only unmatching tasks */
+ if (cookie_match ^ sched_core_cookie_match(rq, p))
continue;
if (sched_idle_cpu(i))
@@ -7391,6 +7393,17 @@ sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *
return shallowest_idle_cpu != -1 ? shallowest_idle_cpu : least_loaded_cpu;
}
+/*
+ * sched_balance_find_dst_group_cpu - find the idlest CPU among the CPUs in the group.
+ */
+static inline int
+sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
+{
+ int cpu = __sched_balance_find_dst_group_cpu(group, p, this_cpu, true);
+
+ return cpu >= 0 ? cpu : __sched_balance_find_dst_group_cpu(group, p, this_cpu, false);
+}
+
static inline int sched_balance_find_dst_cpu(struct sched_domain *sd, struct task_struct *p,
int cpu, int prev_cpu, int sd_flag)
{
--
2.43.0
Amazon Development Centre (South Africa) (Proprietary) Limited
29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa
Registration Number: 2004 / 034463 / 07
next prev parent reply other threads:[~2025-09-22 12:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 12:39 [PATCH 0/4] sched/fair: Core sched wake up path improvements Fernand Sieber
2025-09-22 12:39 ` [PATCH 1/4] sched/fair: Fix cookie check on __select_idle_cpu() Fernand Sieber
2025-09-23 8:42 ` K Prateek Nayak
2025-09-25 6:35 ` Madadi Vineeth Reddy
2025-09-22 12:39 ` Fernand Sieber [this message]
2025-09-23 1:51 ` [PATCH 2/4] sched/fair: Still look for the idlest cpu with no matching cookie K Prateek Nayak
2025-09-23 7:32 ` Fernand Sieber
2025-09-23 7:44 ` Fernand Sieber
2025-09-22 12:39 ` [PATCH 3/4] sched/fair: Add cookie checks on wake idle path Fernand Sieber
2025-09-22 12:39 ` [PATCH 4/4] sched/fair: Add more core cookie check in wake up fast path Fernand Sieber
2025-09-23 8:55 ` K Prateek Nayak
2025-09-23 9:30 ` Fernand Sieber
2025-09-24 4:21 ` K Prateek Nayak
2025-11-05 15:34 ` [PATCH 4/4] sched/fair: Add more core cookie check in wake up Fernand Sieber
2025-11-20 10:30 ` [PATCH 4/4] sched/fair: Add more core cookie check in wake up fast path Fernand Sieber
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=beefbc1474a94868c22b0351dedc0d7398b79c33.1758543008.git.sieberf@amazon.com \
--to=sieberf@amazon.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=dwmw@amazon.co.uk \
--cc=jschoenh@amazon.de \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyuxua@amazon.com \
--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
all inboxes | Powered by JetHome®