[RFC PATCH v4 03/28] sched: Avoid task migration within its preferred LLC

From: Chen Yu
Date: Sat Aug 09 2025 - 01:08:07 EST


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 e97ab46509e3..00bd0d25bc91 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8835,6 +8835,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.25.1