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 <quic_adharmap@quicinc.com>
This commit is contained in:
Abhijeet Dharmapurikar 2022-08-25 12:34:45 -07:00 committed by Sai Harshini Nimmala
parent 3abcd9269f
commit 3de224c444

View File

@ -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)