From 99d9c9b5b9f0d1a67101d7e86f0a3e11a90a5515 Mon Sep 17 00:00:00 2001 From: Rick Yiu Date: Tue, 25 Feb 2020 17:18:04 +0800 Subject: [PATCH] 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 Signed-off-by: Alexander Winkowski --- kernel/sched/fair.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index caaa82992e71..e9611ae53914 100755 --- a/kernel/sched/fair.c +++ b/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; }