sched/fair: check if mid capacity cpu exists

Mid capacity cpu was first introduced on kernel 4.14 for floral.
However, other 4.14 platforms may not have mid capacity cpu, such
as sunfish. So, we need to check if it exists before using it.

Bug: 142551658
Test: boot to home
Change-Id: I9b7f5b94b337167b9790def4953854baab96eaa2
Signed-off-by: Rick Yiu <rickyiu@google.com>
Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
fourteen
Rick Yiu 5 years ago committed by Jenna
parent 4a71488ad8
commit 99d9c9b5b9
  1. 14
      kernel/sched/fair.c

@ -5811,9 +5811,17 @@ static inline bool
cpu_is_in_target_set(struct task_struct *p, int cpu)
{
struct root_domain *rd = cpu_rq(cpu)->rd;
int first_cpu = (schedtune_task_boost(p)) ?
rd->mid_cap_orig_cpu : rd->min_cap_orig_cpu;
int next_usable_cpu = cpumask_next(first_cpu - 1, &p->cpus_allowed);
int first_cpu, next_usable_cpu;
if (schedtune_task_boost(p)) {
first_cpu = rd->mid_cap_orig_cpu != -1 ? rd->mid_cap_orig_cpu :
rd->max_cap_orig_cpu;
} else {
first_cpu = rd->min_cap_orig_cpu;
}
next_usable_cpu = cpumask_next(first_cpu - 1, &p->cpus_allowed);
return cpu >= next_usable_cpu || next_usable_cpu >= nr_cpu_ids;
}

Loading…
Cancel
Save