[RFC patch v3 03/20] sched: Avoid task migration within its preferred LLC

From: Tim Chen
Date: Wed Jun 18 2025 - 14:22:32 EST


From: Chen Yu <yu.c.chen@xxxxxxxxx>

It was found that when running schbench, there is a
significant amount of in-LLC task migrations, even if
the wakee is woken up on its preferred LLC. This
leads to core-to-core latency and impairs performance.

Inhibit task migration if the wakee is already in its
preferred LLC.

Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
---
kernel/sched/fair.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 89db97f8ef02..567ad2a0cfa2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8813,6 +8813,8 @@ static int select_cache_cpu(struct task_struct *p, int prev_cpu)
if (cpu < 0)
return prev_cpu;

+ if (cpus_share_cache(cpu, prev_cpu))
+ return prev_cpu;

if (static_branch_likely(&sched_numa_balancing) &&
__migrate_degrades_locality(p, prev_cpu, cpu, false) > 0) {
--
2.32.0