From 3de224c44457f59a898153740beab5fd4a62ef69 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Thu, 25 Aug 2022 12:34:45 -0700 Subject: [PATCH] sched/walt: fix packing worthy gold tasks running on silvers The current code identifies the first 32bit cpu as the packing cpu when the load conditions are met. However, it skips checking if that 32bit cpu is actually halted. In case it were halted, the select_task_rq()->is_cpu_allowed() fails, causing the task to run on a fallback cpu which invariably ends up being a silver cpu. Fix this by finding the first unhalted cpu for packing. If its a 32bit task further find a 32bit supporting cpu. Either case always ensure that an unhalted cpu is used for packing. Change-Id: I459c70fe3793a26c4b06bb80f8660003b1875c85 Signed-off-by: Abhijeet Dharmapurikar --- kernel/sched/walt/walt.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index 94404dc16078..c78354ec4ec2 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -1002,7 +1002,6 @@ static inline int walt_find_and_choose_cluster_packing_cpu(int start_cpu, struct struct walt_rq *wrq = (struct walt_rq *)rq->android_vendor_data1; struct walt_sched_cluster *cluster = wrq->cluster; cpumask_t unhalted_cpus; - cpumask_t cluster_32bit_cpus; int packing_cpu; /* if idle_enough feature is not enabled */ @@ -1011,22 +1010,19 @@ static inline int walt_find_and_choose_cluster_packing_cpu(int start_cpu, struct if (!sysctl_sched_cluster_util_thres_pct) return -1; - /* find all 32 bit capable cpus in this cluster */ - cpumask_and(&cluster_32bit_cpus, &cluster->cpus, system_32bit_el0_cpumask()); - /* pack 32 bit and 64 bit tasks on the same cpu, if possible */ - if (cpumask_weight(&cluster_32bit_cpus) > 0) { - packing_cpu = cpumask_first(&cluster_32bit_cpus); - } else { - /* find all unhalted active cpus */ - cpumask_andnot(&unhalted_cpus, cpu_active_mask, cpu_halt_mask); + /* find all unhalted active cpus */ + cpumask_andnot(&unhalted_cpus, cpu_active_mask, cpu_halt_mask); - /* find all unhalted active cpus in this cluster */ - cpumask_and(&unhalted_cpus, &unhalted_cpus, &cluster->cpus); + /* find all unhalted active cpus in this cluster */ + cpumask_and(&unhalted_cpus, &unhalted_cpus, &cluster->cpus); - /* return the first found unhalted, active cpu, in this cluster */ - packing_cpu = cpumask_first(&unhalted_cpus); - } + if (is_compat_thread(task_thread_info(p))) + /* try to find a packing cpu within 32 bit subset */ + cpumask_and(&unhalted_cpus, &unhalted_cpus, system_32bit_el0_cpumask()); + + /* return the first found unhalted, active cpu, in this cluster */ + packing_cpu = cpumask_first(&unhalted_cpus); /* packing cpu must be a valid cpu for runqueue lookup */ if (packing_cpu >= nr_cpu_ids)