From: Park Bumgyu Date: Fri, 6 Apr 2018 05:15:09 +0000 (+0900) Subject: sched: ems: integrate common API X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=76dc8ad3942ad0b91e926e48d343c247bb11c253;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git sched: ems: integrate common API Commonly used APIs are delcared redundantly in several files in EMS. It is integrated into core.c. Change-Id: Ic42d508d1083f9321c856452f50731c2a9fa9adf Signed-off-by: Park Bumgyu --- diff --git a/include/linux/ems.h b/include/linux/ems.h index e09f91efa331..5beb19b9c116 100644 --- a/include/linux/ems.h +++ b/include/linux/ems.h @@ -43,6 +43,8 @@ extern int exynos_need_active_balance(enum cpu_idle_type idle, extern unsigned long global_boost(void); extern int find_second_max_cap(void); +extern int +exynos_wakeup_balance(struct task_struct *p, int prev_cpu, int sd_flag, int sync); extern int exynos_select_cpu(struct task_struct *p, int *backup_cpu, bool boosted, bool prefer_idle); @@ -77,6 +79,11 @@ static inline int exynos_need_active_balance(enum cpu_idle_type idle, static inline unsigned long global_boost(void) { return 0; } static inline int find_second_max_cap(void) { return -EINVAL; } +static inline int +exynos_wakeup_balance(struct task_struct *p, int prev_cpu, int sd_flag, int sync) +{ + return -1; +} static inline int exynos_select_cpu(struct task_struct *p, int *backup_cpu, bool boosted, bool prefer_idle) { return -EINVAL; } diff --git a/kernel/sched/ems/core.c b/kernel/sched/ems/core.c index 29bb9a38eb18..166530ffbd64 100644 --- a/kernel/sched/ems/core.c +++ b/kernel/sched/ems/core.c @@ -11,6 +11,25 @@ #include "ems.h" #include "../sched.h" +int task_util(struct task_struct *p) +{ + return p->se.avg.util_avg; +} + +int cpu_util_wake(int cpu, struct task_struct *p) +{ + unsigned long util, capacity; + + /* Task has no contribution or is new */ + if (cpu != task_cpu(p) || !p->se.avg.last_update_time) + return cpu_util(cpu); + + capacity = capacity_orig_of(cpu); + util = max_t(long, cpu_rq(cpu)->cfs.avg.util_avg - task_util(p), 0); + + return (util >= capacity) ? capacity : util; +} + static int select_proper_cpu(struct task_struct *p) { return -1; diff --git a/kernel/sched/ems/ems.h b/kernel/sched/ems/ems.h index b82d54245db3..87fff90c3da1 100644 --- a/kernel/sched/ems/ems.h +++ b/kernel/sched/ems/ems.h @@ -34,13 +34,5 @@ static inline int prefer_idle_cpu(struct task_struct *p) { return -1; } static inline int group_balancing(struct task_struct *p) { return -1; } #endif -#ifdef CONFIG_SCHED_EMS -extern int -exynos_wakeup_balance(struct task_struct *p, int prev_cpu, int sd_flag, int sync); -#else -static inline int -exynos_wakeup_balance(struct task_struct *p, int prev_cpu, int sd_flag, int sync) -{ - return -1; -} -#endif +extern int task_util(struct task_struct *p); +extern int cpu_util_wake(int cpu, struct task_struct *p); diff --git a/kernel/sched/ems/energy.c b/kernel/sched/ems/energy.c index 8b3ffa16983d..394d40109cd2 100644 --- a/kernel/sched/ems/energy.c +++ b/kernel/sched/ems/energy.c @@ -10,25 +10,6 @@ #include "ems.h" #include "../sched.h" -static int task_util(struct task_struct *p) -{ - return p->se.avg.util_avg; -} - -static int cpu_util_wake(int cpu, struct task_struct *p) -{ - unsigned long util, capacity; - - /* Task has no contribution or is new */ - if (cpu != task_cpu(p) || !p->se.avg.last_update_time) - return cpu_util(cpu); - - capacity = capacity_orig_of(cpu); - util = max_t(long, cpu_rq(cpu)->cfs.avg.util_avg - task_util(p), 0); - - return (util >= capacity) ? capacity : util; -} - /* * The compute capacity, power consumption at this compute capacity and * frequency of state. The cap and power are used to find the energy diff --git a/kernel/sched/ems/lbt.c b/kernel/sched/ems/lbt.c index 1c4a55443a3f..75ef7ebd8531 100644 --- a/kernel/sched/ems/lbt.c +++ b/kernel/sched/ems/lbt.c @@ -67,30 +67,6 @@ static inline int get_last_level(struct lbt_overutil *ou) return -1; } -static inline unsigned long task_util(struct task_struct *p) -{ - return p->se.avg.util_avg; -} - -static inline int check_migration_task(struct task_struct *p) -{ - return !p->se.avg.last_update_time; -} - -static inline unsigned long cpu_util_wake(int cpu, struct task_struct *p) -{ - unsigned long util, capacity; - - /* Task has no contribution or is new */ - if (cpu != task_cpu(p) || check_migration_task(p)) - return cpu_util(cpu); - - capacity = capacity_orig_of(cpu); - util = max_t(long, cpu_util(cpu) - task_util(p), 0); - - return (util >= capacity) ? capacity : util; -} - /****************************************************************/ /* External APIs */ /****************************************************************/ diff --git a/kernel/sched/ems/st_addon.c b/kernel/sched/ems/st_addon.c index 04c088b1af7a..85271da2a96a 100644 --- a/kernel/sched/ems/st_addon.c +++ b/kernel/sched/ems/st_addon.c @@ -14,30 +14,6 @@ #include "../sched.h" #include "../tune.h" -static inline unsigned long task_util(struct task_struct *p) -{ - return p->se.avg.util_avg; -} - -static inline int check_migration_task(struct task_struct *p) -{ - return !p->se.avg.last_update_time; -} - -static inline unsigned long cpu_util_wake(int cpu, struct task_struct *p) -{ - unsigned long util, capacity; - - /* Task has no contribution or is new */ - if (cpu != task_cpu(p) || check_migration_task(p)) - return cpu_util(cpu); - - capacity = capacity_orig_of(cpu); - util = max_t(long, cpu_util(cpu) - task_util(p), 0); - - return (util >= capacity) ? capacity : util; -} - /********************************************************************** * Prefer Perf * **********************************************************************/ diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5a157c85c774..81e835a12cc3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -40,7 +40,6 @@ #include "sched.h" #include "tune.h" #include "walt.h" -#include "ems/ems.h" /* * Targeted preemption latency for CPU-bound tasks: