Message ID | 1411403047-32010-3-git-send-email-morten.rasmussen@arm.com |
---|---|
State | New |
Headers | show |
Quoting Morten Rasmussen (2014-09-22 09:24:02) > Architectures that don't have any other means for tracking cpu frequency > changes need a callback from cpufreq to implement a scaling factor to > enable scale-invariant per-entity load-tracking in the scheduler. > > To compute the scale invariance correction factor the architecture would > need to know both the max frequency and the current frequency. This > patch defines weak functions for setting both from cpufreq. > > Related architecture specific functions use weak function definitions. > The same approach is followed here. > > These callbacks can be used to implement frequency scaling of cpu > capacity later. > > Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com> > --- > drivers/cpufreq/cpufreq.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index d9fdedd..e911f6b 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -278,6 +278,10 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) > } > #endif > > +void __weak arch_scale_set_curr_freq(int cpu, unsigned long freq) {} > + > +void __weak arch_scale_set_max_freq(int cpu, unsigned long freq) {} Hi Morten, This approach assumes a single implementation for an architecture, which probably will not scale across the myriad platforms we have merged in mainline today. For ARM there could be any number of methods for determining a cpus capacity, including use of CPUfreq or some other platform-specific method. I am vaguely aware of Intel-based platforms that do not implement ACPI, so for that architecture I assume that an arch hook that assumes ACPI is similarly restrictive. I'll reply to this thread with a pair of patches that try to generalize the functions you created in patches #2-4 of this series. I'm currently hacking on a Chromebook 2 using the arm_big_little CPUfreq driver, so you'll notice that is where I decided to implement the ops. Of course those could be implemented in arch code, or some other driver. Regards, Mike > + > static void __cpufreq_notify_transition(struct cpufreq_policy *policy, > struct cpufreq_freqs *freqs, unsigned int state) > { > @@ -315,6 +319,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, > pr_debug("FREQ: %lu - CPU: %lu\n", > (unsigned long)freqs->new, (unsigned long)freqs->cpu); > trace_cpu_frequency(freqs->new, freqs->cpu); > + arch_scale_set_curr_freq(freqs->cpu, freqs->new); > srcu_notifier_call_chain(&cpufreq_transition_notifier_list, > CPUFREQ_POSTCHANGE, freqs); > if (likely(policy) && likely(policy->cpu == freqs->cpu)) > @@ -2135,7 +2140,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, > struct cpufreq_policy *new_policy) > { > struct cpufreq_governor *old_gov; > - int ret; > + int ret, cpu; > > pr_debug("setting new policy for CPU %u: %u - %u kHz\n", > new_policy->cpu, new_policy->min, new_policy->max); > @@ -2173,6 +2178,9 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, > policy->min = new_policy->min; > policy->max = new_policy->max; > > + for_each_cpu(cpu, policy->cpus) > + arch_scale_set_max_freq(cpu, policy->max); > + > pr_debug("new min and max freqs are %u - %u kHz\n", > policy->min, policy->max); > > -- > 1.7.9.5 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
The fair scheduler needs a method to retrieve the capacity of a cpu, which may be derived from several platform-specific factors including micro-architectural differences (e.g. big.LITTLE cpus), cpus with different transistor types or process node properties (e.g. Nvidia Tegra30 LP cpu) and cpu frequency (for cpus that dynamically scale clock speed). This info is inherently machine-specific and the first patch in this series implements a new callback, .get_capacity as part of struct capacity_ops. The default simply returns SCHED_CAPACITY_SCALE. The second patch populates that callback with CPUfreq-based method for machines using the arm_big_little CPUfreq driver. This can likely be abstracted out a bit more to be generally useful to more CPUfreq drivers but I wanted to gather feedback on the approach before going any further. Mike Turquette (2): sched: cfs: introduce capacity_ops cpufreq: arm_big_little: provide cpu capacity arch/arm/include/asm/topology.h | 2 ++ arch/arm/kernel/topology.c | 42 ++------------------------------- drivers/cpufreq/arm_big_little.c | 51 ++++++++++++++++++++++++++++++++++++++++ include/linux/sched.h | 28 ++++++++++++++++++++++ kernel/sched/fair.c | 41 +++++++++++++++++++++++++++----- 5 files changed, 118 insertions(+), 46 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d9fdedd..e911f6b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -278,6 +278,10 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) } #endif +void __weak arch_scale_set_curr_freq(int cpu, unsigned long freq) {} + +void __weak arch_scale_set_max_freq(int cpu, unsigned long freq) {} + static void __cpufreq_notify_transition(struct cpufreq_policy *policy, struct cpufreq_freqs *freqs, unsigned int state) { @@ -315,6 +319,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, pr_debug("FREQ: %lu - CPU: %lu\n", (unsigned long)freqs->new, (unsigned long)freqs->cpu); trace_cpu_frequency(freqs->new, freqs->cpu); + arch_scale_set_curr_freq(freqs->cpu, freqs->new); srcu_notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs); if (likely(policy) && likely(policy->cpu == freqs->cpu)) @@ -2135,7 +2140,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, struct cpufreq_policy *new_policy) { struct cpufreq_governor *old_gov; - int ret; + int ret, cpu; pr_debug("setting new policy for CPU %u: %u - %u kHz\n", new_policy->cpu, new_policy->min, new_policy->max); @@ -2173,6 +2178,9 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, policy->min = new_policy->min; policy->max = new_policy->max; + for_each_cpu(cpu, policy->cpus) + arch_scale_set_max_freq(cpu, policy->max); + pr_debug("new min and max freqs are %u - %u kHz\n", policy->min, policy->max);
Architectures that don't have any other means for tracking cpu frequency changes need a callback from cpufreq to implement a scaling factor to enable scale-invariant per-entity load-tracking in the scheduler. To compute the scale invariance correction factor the architecture would need to know both the max frequency and the current frequency. This patch defines weak functions for setting both from cpufreq. Related architecture specific functions use weak function definitions. The same approach is followed here. These callbacks can be used to implement frequency scaling of cpu capacity later. Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com> --- drivers/cpufreq/cpufreq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)