From b30e2673a8a8ebce5b0bc914e3f30282cfae7ac1 Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Tue, 9 Dec 2025 11:23:38 +0800 Subject: [PATCH] anolis: sched: fix high class task performance regression ANBZ: #27847 In commit <6b7fe4a1e321> ("sched/fair: Merge select_idle_core/cpu()"), the functions `select_idle_core` and `select_idle_cpu` were merged together. However, the adaptation for the group identity feature was incomplete: when executing `select_idle_cpu`, the case of `id_idle_cpu` was not taken into account, causing the scheduler to fail to find an idle CPU and consequently skip calling `select_idle_cpu`. To fix this issue, invoke `select_idle_cpu` within `select_idle_core` to select a fallback idle core. Signed-off-by: Yi Tao --- kernel/sched/fair.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 924ddef6348a..4de495247b7a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9121,28 +9121,31 @@ void __update_idle_core(struct rq *rq) static int select_idle_core(struct task_struct *p, int core, struct cpumask *cpus, int *idle_cpu, int *id_backup) { bool idle = true; + bool is_expellee, share_core = true; + bool dummy_idle; int cpu; if (!static_branch_likely(&sched_smt_present)) return __select_idle_cpu(core, p, id_backup); + + is_expellee = is_expellee_task(p); + for_each_cpu(cpu, cpu_smt_mask(core)) { + if (!group_identity_disabled() + && id_idle_cpu(p, cpu, is_expellee, &dummy_idle, &share_core) + && cpumask_test_cpu(cpu, cpus)) { + if (*id_backup == -1 || !is_cpu_in_sys_mode(cpu, p)) + *id_backup = cpu; + } + if (!available_idle_cpu(cpu)) { idle = false; if (*idle_cpu == -1) { if (sched_idle_cpu(cpu) && cpumask_test_cpu(cpu, cpus)) { - if (!group_identity_disabled() && - is_cpu_in_sys_mode(cpu, p) && - *id_backup == -1) - *id_backup = cpu; - else { - *idle_cpu = cpu; - break; - } + *idle_cpu = cpu; + break; } - if (!group_identity_disabled() && - (*id_backup == -1 || !is_cpu_in_sys_mode(cpu, p))) - *id_backup = cpu; continue; } break; -- Gitee