Message ID | 20170727193312.9849-1-dietmar.eggemann@arm.com |
---|---|
Headers | show |
Series | arm, arm64, cpufreq: frequency- and cpu-invariant accounting support for task scheduler | expand |
On 27-07-17, 20:33, Dietmar Eggemann wrote: > Free cpumask cpus_to_visit in case registering > init_cpu_capacity_notifier has failed or the parsing of the cpu > capacity-dmips-mhz property is done. The cpumask cpus_to_visit is > only used inside the notifier call init_cpu_capacity_callback. > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: Juri Lelli <juri.lelli@arm.com> > Reported-by: Vincent Guittot <vincent.guittot@linaro.org> > Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > Acked-by: Vincent Guittot <vincent.guittot@linaro.org> > Tested-by: Juri Lelli <juri.lelli@arm.com> > Reviewed-by: Juri Lelli <juri.lelli@arm.com> > --- > drivers/base/arch_topology.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) Acked-by: Viresh Kumar <viresh.kumar@linaro.org> -- viresh
On 27-07-17, 20:33, Dietmar Eggemann wrote: > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 9bf97a366029..04e2f7e4964e 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2404,6 +2404,17 @@ int cpufreq_boost_enabled(void) > EXPORT_SYMBOL_GPL(cpufreq_boost_enabled); > > /********************************************************************* > + * FREQUENCY INVARIANT ACCOUNTING SUPPORT * > + *********************************************************************/ We don't need another of these fancy headers :) Just add below routine somewhere at the top, maybe before cpufreq_generic_init(). > + > +__weak void arch_set_freq_scale(struct cpumask *cpus, > + unsigned long cur_freq, > + unsigned long max_freq) > +{ > +} > +EXPORT_SYMBOL_GPL(arch_set_freq_scale); > + > +/********************************************************************* > * REGISTER / UNREGISTER CPUFREQ DRIVER * > *********************************************************************/ > static enum cpuhp_state hp_online; > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index f10a9b3761cd..e38acc1a4d47 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -899,6 +899,9 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy) > > extern unsigned int arch_freq_get_on_cpu(int cpu); > > +extern void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, > + unsigned long max_freq); > + > /* the following are really really optional */ > extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; > extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs; > -- > 2.11.0 -- viresh
On 27-07-17, 20:33, Dietmar Eggemann wrote: > Call the frequency-invariance setter function arch_set_freq_scale() > if the new frequency has been successfully set which is indicated by > dev_pm_opp_set_rate() returning 0. > > Cc: Rafael J. Wysocki <rjw@rjwysocki.net> > Cc: Viresh Kumar <viresh.kumar@linaro.org> > Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > --- > drivers/cpufreq/cpufreq-dt.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c > index fef3c2160691..cbac8a7dbc50 100644 > --- a/drivers/cpufreq/cpufreq-dt.c > +++ b/drivers/cpufreq/cpufreq-dt.c > @@ -43,9 +43,17 @@ static struct freq_attr *cpufreq_dt_attr[] = { > static int set_target(struct cpufreq_policy *policy, unsigned int index) > { > struct private_data *priv = policy->driver_data; > + unsigned long freq = policy->freq_table[index].frequency; > + int ret; > + > + ret = dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000); > > - return dev_pm_opp_set_rate(priv->cpu_dev, > - policy->freq_table[index].frequency * 1000); > + if (!ret) { > + arch_set_freq_scale(policy->related_cpus, freq, > + policy->cpuinfo.max_freq); > + } > + > + return ret; > } Acked-by: Viresh Kumar <viresh.kumar@linaro.org> -- viresh
On 27-07-17, 20:33, Dietmar Eggemann wrote: > Implements the arch-specific (arm and arm64) frequency-invariance setter > function arch_set_freq_scale() which provides the following frequency > scaling factor: > > current_freq(cpu) << SCHED_CAPACITY_SHIFT / max_supported_freq(cpu) > > One possible consumer of the frequency-invariance getter function > topology_get_freq_scale() is the Per-Entity Load Tracking (PELT) > mechanism of the task scheduler. > > Allow inlining of topology_get_freq_scale() into the task scheduler > fast path (e.g. __update_load_avg_se()) by coding it as a static inline > function in the arch topology header file. > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: Juri Lelli <juri.lelli@arm.com> > Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > --- > drivers/base/arch_topology.c | 14 ++++++++++++++ > include/linux/arch_topology.h | 10 ++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 562e0c93ae52..af9ab98a233e 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -22,6 +22,20 @@ > #include <linux/string.h> > #include <linux/sched/topology.h> > > +DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; > + > +void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, > + unsigned long max_freq) > +{ > + unsigned long scale; > + int i; > + > + scale = (cur_freq << SCHED_CAPACITY_SHIFT) / max_freq; > + > + for_each_cpu(i, cpus) > + per_cpu(freq_scale, i) = scale; > +} > + > static DEFINE_MUTEX(cpu_scale_mutex); > static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE; > > diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h > index 9af3c174c03a..3e3c2657c9a1 100644 > --- a/include/linux/arch_topology.h > +++ b/include/linux/arch_topology.h > @@ -4,6 +4,8 @@ > #ifndef _LINUX_ARCH_TOPOLOGY_H_ > #define _LINUX_ARCH_TOPOLOGY_H_ > > +#include <linux/percpu.h> > + > void topology_normalize_cpu_scale(void); > > struct device_node; > @@ -14,4 +16,12 @@ unsigned long topology_get_cpu_scale(struct sched_domain *sd, int cpu); > > void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity); > > +DECLARE_PER_CPU(unsigned long, freq_scale); > + > +static inline > +unsigned long topology_get_freq_scale(struct sched_domain *sd, int cpu) > +{ > + return per_cpu(freq_scale, cpu); > +} > + > #endif /* _LINUX_ARCH_TOPOLOGY_H_ */ Acked-by: Viresh Kumar <viresh.kumar@linaro.org> -- viresh
Hi Viresh, On 28/07/17 08:30, Viresh Kumar wrote: > On 27-07-17, 20:33, Dietmar Eggemann wrote: >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c >> index 9bf97a366029..04e2f7e4964e 100644 >> --- a/drivers/cpufreq/cpufreq.c >> +++ b/drivers/cpufreq/cpufreq.c >> @@ -2404,6 +2404,17 @@ int cpufreq_boost_enabled(void) >> EXPORT_SYMBOL_GPL(cpufreq_boost_enabled); >> >> /********************************************************************* >> + * FREQUENCY INVARIANT ACCOUNTING SUPPORT * >> + *********************************************************************/ > > We don't need another of these fancy headers :) > > Just add below routine somewhere at the top, maybe before > cpufreq_generic_init(). Yes, sure. Will address this in the upcoming v4. Thanks the review! -- Dietmar
Hi Russell, On 27/07/17 20:33, Dietmar Eggemann wrote: [...] > Patch high level description: > > [ 01/10] Fix to free cpumask cpus_to_visit > [ 02/10] Default (empty, weak) arch_set_freq_scale() implementation > [03,04/10] Call arch_set_freq_scale() from two cpufreq drivers > (arm_big_little and cpufreq-dt) > [ 05/10] FIE > [ 06/10] Allow CIE inlining > [07,08/10] Enable frequency- and cpu-invariant accounting on arm Would you have time to review patch 7 and 8. I already got an Acked-by from the ARM64 maintainer for the arm64 related counterpart functionality. Thanks, -- Dietmar [...]
Hi Rafael, On 27/07/17 20:33, Dietmar Eggemann wrote: [...] > Patch high level description: > > [ 01/10] Fix to free cpumask cpus_to_visit > [ 02/10] Default (empty, weak) arch_set_freq_scale() implementation > [03,04/10] Call arch_set_freq_scale() from two cpufreq drivers > (arm_big_little and cpufreq-dt) Could you please have a look at patches 2-4 which touch the cpufreq subsystem. Thanks, -- Dietmar [....]
On Thu, Jul 27, 2017 at 08:33:09PM +0100, Dietmar Eggemann wrote: > Commit dfbca41f3479 ("sched: Optimize freq invariant accounting") > changed the wiring which now has to be done by associating > arch_scale_freq_capacity with the actual implementation provided > by the architecture. > > Define arch_scale_freq_capacity to use the arch_topology "driver" > function topology_get_freq_scale() for the task scheduler's > frequency-invariant accounting instead of the default > arch_scale_freq_capacity() in kernel/sched/sched.h. > > Cc: Russell King <linux@arm.linux.org.uk> > Cc: Juri Lelli <juri.lelli@arm.com> > Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > Acked-by: Vincent Guittot <vincent.guittot@linaro.org> > Tested-by: Juri Lelli <juri.lelli@arm.com> > Reviewed-by: Juri Lelli <juri.lelli@arm.com> Acked-by: Russell King <rmk+kernel@armlinux.org.uk> -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up
On Thu, Jul 27, 2017 at 08:33:10PM +0100, Dietmar Eggemann wrote: > Commit 8cd5601c5060 ("sched/fair: Convert arch_scale_cpu_capacity() from > weak function to #define") changed the wiring which now has to be done > by associating arch_scale_cpu_capacity with the actual implementation > provided by the architecture. > > Define arch_scale_cpu_capacity to use the arch_topology "driver" > function topology_get_cpu_scale() for the task scheduler's cpu-invariant > accounting instead of the default arch_scale_cpu_capacity() in > kernel/sched/sched.h. > > Cc: Russell King <linux@arm.linux.org.uk> > Cc: Juri Lelli <juri.lelli@arm.com> > Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com> > Acked-by: Vincent Guittot <vincent.guittot@linaro.org> > Tested-by: Juri Lelli <juri.lelli@arm.com> > Reviewed-by: Juri Lelli <juri.lelli@arm.com> Acked-by: Russell King <rmk+kernel@armlinux.org.uk> -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up