From 295f1a8a53b4681328d1c4d188e635643a718933 Mon Sep 17 00:00:00 2001 From: Connor O'Brien Date: Mon, 8 Apr 2019 12:38:40 -0700 Subject: [PATCH] sched/fair: fix implementation of is_min_capacity_cpu() With CONFIG_SCHED_WALT disabled, is_min_capacity_cpu() is defined to always return true, which breaks the intended behavior of task_fits_max(). Revise is_min_capacity_cpu() to return correct results. An earlier version of this patch failed to handle the case when min_cap_orig_cpu == -1 while sched domains are being updated due to hotplug. Add a check for this case. Test: trace shows increased top-app placement on medium cores Bug: 117499098 Bug: 128477368 Bug: 130756111 Change-Id: Ia2b41aa7c57f071c997bcd0e9cdfd0808f6a2bf9 Signed-off-by: Connor O'Brien Signed-off-by: Alexander Winkowski --- kernel/sched/sched.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b3f1b55bb408..10ede4912b33 100755 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3054,7 +3054,17 @@ task_in_cum_window_demand(struct rq *rq, struct task_struct *p) static inline bool hmp_capable(void) { return false; } static inline bool is_max_capacity_cpu(int cpu) { return true; } -static inline bool is_min_capacity_cpu(int cpu) { return true; } +static inline bool is_min_capacity_cpu(int cpu) +{ +#ifdef CONFIG_SMP + int min_cpu = cpu_rq(cpu)->rd->min_cap_orig_cpu; + + return unlikely(min_cpu == -1) || + capacity_orig_of(cpu) == capacity_orig_of(min_cpu); +#else + return true; +#endif +} static inline int preferred_cluster(struct sched_cluster *cluster, struct task_struct *p)