From 53e81c1e703eef6a563245b6ffebed3dd6ccda9c Mon Sep 17 00:00:00 2001 From: Ashay Jaiswal Date: Mon, 18 Mar 2024 17:34:44 +0530 Subject: [PATCH] sched: walt: always return active cpu as part of nohz timer vendor hook There is a possibility where WALT will not find any non-idle unhalted cpu as part on NOHZ timer target vendor hook and in that case WALT returns first available unhalted CPU which might be an offline cpu. Add check to always return an active cpu as timer target CPU. Change-Id: I072909ba9316e96b61599aaf9d946c96bdf533f7 Signed-off-by: Ashay Jaiswal --- kernel/sched/walt/walt_halt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/sched/walt/walt_halt.c b/kernel/sched/walt/walt_halt.c index dbfcff2bb84c..e77a6cb844a1 100644 --- a/kernel/sched/walt/walt_halt.c +++ b/kernel/sched/walt/walt_halt.c @@ -533,9 +533,10 @@ static void android_rvh_get_nohz_timer_target(void *unused, int *cpu, bool *done { int i, default_cpu = -1; struct sched_domain *sd; - cpumask_t unhalted; + cpumask_t active_unhalted; *done = true; + cpumask_andnot(&active_unhalted, cpu_active_mask, cpu_halt_mask); if (housekeeping_cpu(*cpu, HK_TYPE_TIMER) && !cpu_halted(*cpu)) { if (!available_idle_cpu(*cpu)) @@ -547,7 +548,7 @@ static void android_rvh_get_nohz_timer_target(void *unused, int *cpu, bool *done * find first cpu halted by core control and try to avoid * affecting externally halted cpus. */ - if (!cpumask_andnot(&unhalted, cpu_active_mask, cpu_halt_mask)) { + if (!cpumask_weight(&active_unhalted)) { cpumask_t tmp_pause, tmp_part_pause, tmp_halt, *tmp; cpumask_and(&tmp_part_pause, cpu_active_mask, &cpus_part_paused_by_us); @@ -580,8 +581,7 @@ static void android_rvh_get_nohz_timer_target(void *unused, int *cpu, bool *done } if (default_cpu == -1) { - cpumask_complement(&unhalted, cpu_halt_mask); - for_each_cpu_and(i, &unhalted, + for_each_cpu_and(i, &active_unhalted, housekeeping_cpumask(HK_TYPE_TIMER)) { if (*cpu == i) continue; @@ -592,8 +592,8 @@ static void android_rvh_get_nohz_timer_target(void *unused, int *cpu, bool *done } } - /* no active, non-halted, not-idle, choose any */ - default_cpu = cpumask_any(&unhalted); + /* choose any active unhalted cpu */ + default_cpu = cpumask_any(&active_unhalted); if (unlikely(default_cpu >= nr_cpu_ids)) goto unlock;