[PATCH] sched: fair: don't depend on wake_wide if waker and wakee are already in same LLC
From: Barry Song
Date: Wed May 26 2021 - 05:18:37 EST
when waker and wakee are already in the same LLC, it is pointless to worry
about the competition caused by pulling wakee to waker's LLC domain.
Signed-off-by: Barry Song <song.bao.hua@xxxxxxxxxxxxx>
---
kernel/sched/fair.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 3248e24a90b0..cfb1bd47acc3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6795,7 +6795,15 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
new_cpu = prev_cpu;
}
- want_affine = !wake_wide(p) && cpumask_test_cpu(cpu, p->cpus_ptr);
+ /*
+ * we use wake_wide to make smarter pull and avoid cruel
+ * competition because of jam-packed tasks in waker's LLC
+ * domain. But if waker and wakee have been already in
+ * same LLC domain, it seems it is pointless to depend
+ * on wake_wide
+ */
+ want_affine = (cpus_share_cache(cpu, prev_cpu) || !wake_wide(p)) &&
+ cpumask_test_cpu(cpu, p->cpus_ptr);
}
rcu_read_lock();
--
2.25.1