If we enable the STEAL feature, when the newidle_balance fails, it will first find the busy CPU from the same smt, and then the same LLC.
This patch makes the following modifications: the same cluster will be scanned before LLC. Thus, we can use more memory bandwidth.
Signed-off-by: Cheng Yu serein.chengyu@huawei.com --- kernel/sched/fair.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 95d1841f8a20..2cc30fa158e5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -13164,6 +13164,19 @@ static int try_steal(struct rq *dst_rq, struct rq_flags *dst_rf) } #endif /* CONFIG_SCHED_SMT */
+#ifdef CONFIG_SCHED_CLUSTER + /* + * Then try overloaded CPUs on the same cluster to preserve cache warmth further. + */ + for_each_cpu(src_cpu, cpu_clustergroup_mask(dst_cpu)) { + if (sparsemask_test_elem(overload_cpus, src_cpu) && + steal_from(dst_rq, dst_rf, &locked, src_cpu)) { + stolen = 1; + goto out; + } + } +#endif /* CONFIG_SCHED_CLUSTER */ + /* Accept any suitable task in the LLC */
sparsemask_for_each(overload_cpus, dst_cpu, src_cpu) {