From e8a4a0733f47a03cf37fc71f7741cd1a46bf9aa9 Mon Sep 17 00:00:00 2001 From: Park Bumgyu Date: Tue, 10 Apr 2018 10:18:38 +0900 Subject: [PATCH] sched: ems: set cpu capacity for simplified energy model We added the SIMPLIFIED_ENERGY_TABLE config to prevent conflicts with existing energy model. If this config is enabled, the codes for legacy energy model is unactivated. Change-Id: I9b6d48334b32a50fd4cc8029d8eab85adb623a9d Signed-off-by: Park Bumgyu --- drivers/base/arch_topology.c | 2 ++ drivers/soc/samsung/exynos-topology.c | 15 +++++++++++++++ include/linux/ems.h | 12 +++++++----- init/Kconfig | 11 +++++++++++ kernel/sched/ems/energy.c | 17 +++++++++++++++-- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index b67dbb6df7b8..88c9a697e819 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -518,11 +518,13 @@ static int __init register_cpufreq_notifier(void) cpumask_copy(cpus_to_visit, cpu_possible_mask); +#ifndef CONFIG_SIMPLIFIED_ENERGY_MODEL ret = cpufreq_register_notifier(&init_cpu_capacity_notifier, CPUFREQ_POLICY_NOTIFIER); if (ret) free_cpumask_var(cpus_to_visit); +#endif return ret; } diff --git a/drivers/soc/samsung/exynos-topology.c b/drivers/soc/samsung/exynos-topology.c index 77b1152fea4e..e08501433bc1 100644 --- a/drivers/soc/samsung/exynos-topology.c +++ b/drivers/soc/samsung/exynos-topology.c @@ -304,6 +304,12 @@ static int cpu_flags(void) return topology_cpu_flags(); } +#ifdef CONFIG_SIMPLIFIED_ENERGY_MODEL +#define use_simplified 1 +#else +#define use_simplified 0 +#endif + static inline const struct sched_group_energy * const cpu_core_energy(int cpu) { @@ -312,6 +318,9 @@ const struct sched_group_energy * const cpu_core_energy(int cpu) int max_cap_idx; int level = cpu_energy_level[cpu].core; + if (use_simplified) + return NULL; + if (level < 0) return NULL; @@ -338,6 +347,9 @@ const struct sched_group_energy * const cpu_coregroup_energy(int cpu) struct sched_group_energy *sge; int level = cpu_energy_level[cpu].coregroup; + if (use_simplified) + return NULL; + if (level < 0) return NULL; @@ -356,6 +368,9 @@ const struct sched_group_energy * const cpu_cluster_energy(int cpu) struct sched_group_energy *sge; int level = cpu_energy_level[cpu].cluster; + if (use_simplified) + return NULL; + if (level < 0) return NULL; diff --git a/include/linux/ems.h b/include/linux/ems.h index 8ddbf7168353..bfb35a3ab193 100644 --- a/include/linux/ems.h +++ b/include/linux/ems.h @@ -55,10 +55,6 @@ extern void update_lbt_overutil(int cpu, unsigned long capacity); extern void gb_qos_update_request(struct gb_qos_request *req, u32 new_value); extern void request_kernel_prefer_perf(int grp_idx, int enable); - -extern void init_sched_energy_table(struct cpumask *cpus, int table_size, - unsigned long *f_table, unsigned int *v_table, - int max_f, int min_f); #else static inline struct sched_group *exynos_fit_idlest_group(struct sched_domain *sd, struct task_struct *p) { return NULL; } @@ -86,8 +82,14 @@ static inline void update_lbt_overutil(int cpu, unsigned long capacity) { } static inline void gb_qos_update_request(struct gb_qos_request *req, u32 new_value) { } static inline void request_kernel_prefer_perf(int grp_idx, int enable) { } +#endif /* CONFIG_SCHED_EMS */ +#ifdef CONFIG_SIMPLIFIED_ENERGY_MODEL +extern void init_sched_energy_table(struct cpumask *cpus, int table_size, + unsigned long *f_table, unsigned int *v_table, + int max_f, int min_f); +#else static inline void init_sched_energy_table(struct cpumask *cpus, int table_size, unsigned long *f_table, unsigned int *v_table, int max_f, int min_f) { } -#endif /* CONFIG_SCHED_EMS */ +#endif diff --git a/init/Kconfig b/init/Kconfig index 3004ed5c7544..466cfca437ce 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1088,6 +1088,17 @@ config DEFAULT_USE_ENERGY_AWARE Say N if unsure. +config SIMPLIFIED_ENERGY_MODEL + bool "Enable simplified energy model feature" + depends on SCHED_EMS + default n + help + This option enables support for simplified energy model. This allows + using a simple energy table declared per_cpu instead of using the EAS + energy table. + + Say N if unsure. + config SCHED_USE_FLUID_RT bool "Enable Fluid RT scheduler feature" depends on SMP diff --git a/kernel/sched/ems/energy.c b/kernel/sched/ems/energy.c index 394d40109cd2..262a2dff686a 100644 --- a/kernel/sched/ems/energy.c +++ b/kernel/sched/ems/energy.c @@ -324,6 +324,7 @@ int select_energy_cpu(struct task_struct *p, int prev_cpu, int sd_flag, int sync return select_eco_cpu(&eenv); } +#ifdef CONFIG_SIMPLIFIED_ENERGY_MODEL static void fill_power_table(struct energy_table *table, int table_size, unsigned long *f_table, unsigned int *v_table, @@ -403,6 +404,7 @@ void init_sched_energy_table(struct cpumask *cpus, int table_size, int cpu, i, mips, valid_table_size = 0; int max_mips = 0; unsigned long max_mips_freq = 0; + int last_state; mips = per_cpu(energy_table, cpumask_any(cpus)).mips; for_each_cpu(cpu, cpus) { @@ -452,9 +454,9 @@ void init_sched_energy_table(struct cpumask *cpus, int table_size, continue; if (table->mips > max_mips) { - int last_state = table->nr_states - 1; - max_mips = table->mips; + + last_state = table->nr_states - 1; max_mips_freq = table->states[last_state].frequency; } } @@ -466,12 +468,22 @@ void init_sched_energy_table(struct cpumask *cpus, int table_size, * recalculated. */ for_each_possible_cpu(cpu) { + struct sched_domain *sd; + table = &per_cpu(energy_table, cpu); if (!table->states) continue; fill_cap_table(table, max_mips, max_mips_freq); show_energy_table(table, cpu); + + last_state = table->nr_states - 1; + topology_set_cpu_scale(cpu, table->states[last_state].cap); + + rcu_read_lock(); + for_each_domain(cpu, sd) + update_group_capacity(sd, cpu); + rcu_read_unlock(); } } @@ -515,3 +527,4 @@ static int __init init_sched_energy_data(void) return 0; } pure_initcall(init_sched_energy_data); +#endif /* CONFIG_SIMPLIFIED_ENERGY_MODEL */ -- 2.20.1