Message ID | 20200924123937.20938-2-ionela.voinescu@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | condition EAS enablement on FI support | expand |
On Thursday 24 Sep 2020 at 13:39:35 (+0100), Ionela Voinescu wrote: > @@ -433,6 +437,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map) > } > #else > static void free_pd(struct perf_domain *pd) { } > +void rebuild_sched_domains_energy(void) { } Nit: maybe make that stub static inline in a header instead? I guess LTO and friends ought to clean that up for you, but it shouldn't hurt to give the compiler a little bit of help here. Otherwise, LGTM: Acked-by: Quentin Perret <qperret@google.com> > #endif /* CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL*/ > > static void free_rootdomain(struct rcu_head *rcu) > -- > 2.17.1 >
Hey, On Thursday 24 Sep 2020 at 14:34:46 (+0100), Quentin Perret wrote: > On Thursday 24 Sep 2020 at 13:39:35 (+0100), Ionela Voinescu wrote: > > @@ -433,6 +437,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map) > > } > > #else > > static void free_pd(struct perf_domain *pd) { } > > +void rebuild_sched_domains_energy(void) { } > > Nit: maybe make that stub static inline in a header instead? I guess LTO > and friends ought to clean that up for you, but it shouldn't hurt to give > the compiler a little bit of help here. > Makes sense and will do! Thank you, Ionela. > Otherwise, LGTM: > > Acked-by: Quentin Perret <qperret@google.com> > > > #endif /* CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL*/ > > > > static void free_rootdomain(struct rcu_head *rcu) > > -- > > 2.17.1 > >
diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 9ef7bf686a9f..f122115d6c54 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -158,6 +158,7 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd) return to_cpumask(sd->span); } +extern void rebuild_sched_domains_energy(void); extern void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], struct sched_domain_attr *dattr_new); diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index e39008242cf4..0337a9b025e1 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -912,16 +912,9 @@ struct cpufreq_governor *cpufreq_default_governor(void) cpufreq_governor_init(schedutil_gov); #ifdef CONFIG_ENERGY_MODEL -extern bool sched_energy_update; -extern struct mutex sched_energy_mutex; - static void rebuild_sd_workfn(struct work_struct *work) { - mutex_lock(&sched_energy_mutex); - sched_energy_update = true; - rebuild_sched_domains(); - sched_energy_update = false; - mutex_unlock(&sched_energy_mutex); + rebuild_sched_domains_energy(); } static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 55c453d140e9..4073f693e2b5 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -211,6 +211,15 @@ unsigned int sysctl_sched_energy_aware = 1; DEFINE_MUTEX(sched_energy_mutex); bool sched_energy_update; +void rebuild_sched_domains_energy(void) +{ + mutex_lock(&sched_energy_mutex); + sched_energy_update = true; + rebuild_sched_domains(); + sched_energy_update = false; + mutex_unlock(&sched_energy_mutex); +} + #ifdef CONFIG_PROC_SYSCTL int sched_energy_aware_handler(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) @@ -223,13 +232,8 @@ int sched_energy_aware_handler(struct ctl_table *table, int write, ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); if (!ret && write) { state = static_branch_unlikely(&sched_energy_present); - if (state != sysctl_sched_energy_aware) { - mutex_lock(&sched_energy_mutex); - sched_energy_update = 1; - rebuild_sched_domains(); - sched_energy_update = 0; - mutex_unlock(&sched_energy_mutex); - } + if (state != sysctl_sched_energy_aware) + rebuild_sched_domains_energy(); } return ret; @@ -433,6 +437,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map) } #else static void free_pd(struct perf_domain *pd) { } +void rebuild_sched_domains_energy(void) { } #endif /* CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL*/ static void free_rootdomain(struct rcu_head *rcu)
Add the rebuild_sched_domains_energy() function to wrap the functionality that rebuilds the scheduling domains if any of the Energy Aware Scheduling (EAS) initialisation conditions change. This functionality is used when schedutil is added or removed or when EAS is enabled or disabled through the sched_energy_aware sysctl. Therefore, create a single function that is used in both these cases and that can be later reused. Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rafael J. Wysocki <rjw@rjwysocki.net> Cc: Viresh Kumar <viresh.kumar@linaro.org> --- include/linux/sched/topology.h | 1 + kernel/sched/cpufreq_schedutil.c | 9 +-------- kernel/sched/topology.c | 19 ++++++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-)