From: Mike Turquette <mturquette@linaro.org>
To: Morten Rasmussen <morten.rasmussen@arm.com>,
peterz@infradead.org, mingo@redhat.com
Cc: dietmar.eggemann@arm.com, pjt@google.com, bsegall@google.com,
vincent.guittot@linaro.org, nicolas.pitre@linaro.org,
rjw@rjwysocki.net, linux-kernel@vger.kernel.org,
tuukka.tikkanen@linaro.org,
Mike Turquette <mturquette@linaro.org>
Subject: [PATCH RFC 2/2] cpufreq: arm_big_little: provide cpu capacity
Date: Tue, 7 Oct 2014 23:26:12 -0700 [thread overview]
Message-ID: <1412749572-29449-3-git-send-email-mturquette@linaro.org> (raw)
In-Reply-To: <1412749572-29449-1-git-send-email-mturquette@linaro.org>
Move the cpu capacity bits out of arch/arm/ and into the CPUfreq driver.
Not all ARM devices will use CPUfreq and it is unsafe to assume as such
in topology.c.
Instead, use the new capacity_ops introduced into CFS. If this code is
generic enough then it could be factored and shared via a header to make
it easier for other CPUfreq drivers to take advantage of it.
Signed-off-by: Mike Turquette <mturquette@linaro.org>
---
This approach simply builds on top of Morten's series. I am not sure
that the per-cpu method is the best way to go in the future. And if so I
imagine that the CPUfreq core could provide everything except for the
cpu_eff part.
In general I think that the overlap between CPUfreq drivers and
arch/arm/kernel/topology.c is something that needs to addresssed soon,
as both pieces of code are re-inventing parts of each other.
arch/arm/include/asm/topology.h | 2 ++
arch/arm/kernel/topology.c | 42 ++-------------------------------
drivers/cpufreq/arm_big_little.c | 51 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 40 deletions(-)
diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h
index 2fe85ff..3951232 100644
--- a/arch/arm/include/asm/topology.h
+++ b/arch/arm/include/asm/topology.h
@@ -14,6 +14,8 @@ struct cputopo_arm {
};
extern struct cputopo_arm cpu_topology[NR_CPUS];
+extern unsigned long max_raw_capacity;
+DECLARE_PER_CPU(unsigned long, cpu_raw_capacity);
#define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id)
#define topology_core_id(cpu) (cpu_topology[cpu].core_id)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 5f049ec..a2c9b5f 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -79,8 +79,8 @@ static unsigned long *__cpu_capacity;
static unsigned long middle_capacity = 1;
-static unsigned long max_raw_capacity = 1;
-static DEFINE_PER_CPU(unsigned long, cpu_raw_capacity);
+unsigned long max_raw_capacity = 1;
+DEFINE_PER_CPU(unsigned long, cpu_raw_capacity);
/*
* Iterate all CPUs' descriptor in DT and compute the efficiency
@@ -175,44 +175,6 @@ static void update_cpu_capacity(unsigned int cpu)
cpu, arch_scale_freq_capacity(NULL, cpu));
}
-/*
- * Scheduler load-tracking scale-invariance
- *
- * Provides the scheduler with a scale-invariance correction factor that
- * compensates for frequency scaling and micro-architecture differences between
- * cpus.
- */
-
-static DEFINE_PER_CPU(atomic_long_t, cpu_curr_freq);
-static DEFINE_PER_CPU(atomic_long_t, cpu_max_freq);
-
-/* cpufreq callback function setting current cpu frequency */
-void arch_scale_set_curr_freq(int cpu, unsigned long freq)
-{
- atomic_long_set(&per_cpu(cpu_curr_freq, cpu), freq);
-}
-
-/* cpufreq callback function setting max cpu frequency */
-void arch_scale_set_max_freq(int cpu, unsigned long freq)
-{
- atomic_long_set(&per_cpu(cpu_max_freq, cpu), freq);
-}
-
-unsigned long arch_scale_load_capacity(int cpu)
-{
- unsigned long curr = atomic_long_read(&per_cpu(cpu_curr_freq, cpu));
- unsigned long max = atomic_long_read(&per_cpu(cpu_max_freq, cpu));
- unsigned long ret;
-
- if (!max || !per_cpu(cpu_raw_capacity, cpu))
- return SCHED_CAPACITY_SCALE;
-
- ret = (curr * SCHED_CAPACITY_SCALE) / max;
- ret = (ret * per_cpu(cpu_raw_capacity, cpu)) / max_raw_capacity;
-
- return ret;
-}
-
#else
static inline void parse_dt_topology(void) {}
static inline void update_cpu_capacity(unsigned int cpuid) {}
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index a46c223..5baffbd 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -31,7 +31,10 @@
#include <linux/slab.h>
#include <linux/topology.h>
#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/rcupdate.h>
#include <asm/bL_switcher.h>
+#include <asm/topology.h>
#include "arm_big_little.h"
@@ -533,9 +536,52 @@ static struct notifier_block bL_switcher_notifier = {
.notifier_call = bL_cpufreq_switcher_notifier,
};
+/*
+ * Scheduler load-tracking scale-invariance
+ *
+ * Provides the scheduler with a scale-invariance correction factor that
+ * compensates for frequency scaling and micro-architecture differences between
+ * cpus.
+ */
+
+static DEFINE_PER_CPU(atomic_long_t, cpu_curr_freq);
+static DEFINE_PER_CPU(atomic_long_t, cpu_max_freq);
+
+/* cpufreq callback function setting current cpu frequency */
+void arch_scale_set_curr_freq(int cpu, unsigned long freq)
+{
+ atomic_long_set(&per_cpu(cpu_curr_freq, cpu), freq);
+}
+
+/* cpufreq callback function setting max cpu frequency */
+void arch_scale_set_max_freq(int cpu, unsigned long freq)
+{
+ atomic_long_set(&per_cpu(cpu_max_freq, cpu), freq);
+}
+
+/*
+ * scale_load_capacity returns the current capacity for a given cpu, adjusted
+ * for micro-architectural differences and taking into accout cpu frequency
+ */
+unsigned long scale_load_capacity(int cpu)
+{
+ unsigned long curr = atomic_long_read(&per_cpu(cpu_curr_freq, cpu));
+ unsigned long max = atomic_long_read(&per_cpu(cpu_max_freq, cpu));
+ unsigned long ret;
+
+ if (!max || !per_cpu(cpu_raw_capacity, cpu))
+ return SCHED_CAPACITY_SCALE;
+
+ ret = (curr * SCHED_CAPACITY_SCALE) / max;
+ ret = (ret * per_cpu(cpu_raw_capacity, cpu)) / max_raw_capacity;
+
+ return ret;
+}
+
int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops)
{
int ret, i;
+ unsigned long flags;
if (arm_bL_ops) {
pr_debug("%s: Already registered: %s, exiting\n", __func__,
@@ -550,6 +596,11 @@ int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops)
arm_bL_ops = ops;
+ spin_lock_irqsave(&cfs_capacity_ops.lock, flags);
+ cfs_capacity_ops.get_capacity = scale_load_capacity;
+ spin_unlock_irqrestore(&cfs_capacity_ops.lock, flags);
+ synchronize_rcu();
+
ret = bL_switcher_get_enabled();
set_switching_enabled(ret);
--
1.8.3.2
next prev parent reply other threads:[~2014-10-08 6:26 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-22 16:24 [PATCH 0/7] sched: Scale-invariant per-entity load-tracking Morten Rasmussen
2014-09-22 16:24 ` [PATCH 1/7] sched: Introduce scale-invariant load tracking Morten Rasmussen
2014-09-25 13:48 ` Vincent Guittot
2014-09-25 17:23 ` Morten Rasmussen
2014-09-26 7:36 ` Vincent Guittot
2014-09-26 9:38 ` Morten Rasmussen
2014-10-02 20:34 ` Peter Zijlstra
2014-10-08 11:00 ` Morten Rasmussen
2014-10-08 11:21 ` Vincent Guittot
2014-10-08 13:53 ` Morten Rasmussen
2014-10-08 14:08 ` Vincent Guittot
2014-10-08 14:16 ` Morten Rasmussen
2014-10-08 11:38 ` Vincent Guittot
2014-10-08 14:05 ` Morten Rasmussen
2014-10-10 9:07 ` Peter Zijlstra
2014-10-08 0:50 ` Yuyang Du
2014-10-08 12:54 ` Dietmar Eggemann
2014-10-10 9:16 ` Peter Zijlstra
2014-10-10 9:14 ` Peter Zijlstra
2014-09-22 16:24 ` [PATCH 2/7] cpufreq: Architecture specific callback for frequency changes Morten Rasmussen
2014-10-08 6:07 ` Mike Turquette
2014-10-08 6:26 ` [PATCH RFC 0/2] introduce capacity_ops to CFS Mike Turquette
2014-10-08 6:26 ` [PATCH RFC 1/2] sched: cfs: introduce capacity_ops Mike Turquette
2014-10-08 8:37 ` Peter Zijlstra
[not found] ` <20141008232836.4379.3339@quantum>
2014-10-09 9:00 ` Peter Zijlstra
[not found] ` <20141009173433.4379.58492@quantum>
2014-10-09 19:00 ` Peter Zijlstra
2014-10-08 6:26 ` Mike Turquette [this message]
2014-10-08 15:48 ` [PATCH RFC 2/2] cpufreq: arm_big_little: provide cpu capacity Morten Rasmussen
[not found] ` <20141008223732.4379.78047@quantum>
2014-10-09 9:02 ` Peter Zijlstra
[not found] ` <20141009172513.4379.56718@quantum>
2014-10-09 17:38 ` Peter Zijlstra
2014-09-22 16:24 ` [PATCH 3/7] arm: Frequency invariant scheduler load-tracking support Morten Rasmussen
2014-09-22 16:24 ` [PATCH 4/7] arm: Micro-architecture invariant load tracking support Morten Rasmussen
2014-09-22 16:24 ` [PATCH 5/7] sched: Implement usage tracking Morten Rasmussen
2014-09-22 16:24 ` [PATCH 6/7] sched: Make sched entity usage tracking scale-invariant Morten Rasmussen
2014-09-22 17:13 ` bsegall
2014-09-23 13:35 ` Morten Rasmussen
2014-10-02 21:04 ` Peter Zijlstra
2014-09-22 16:24 ` [PATCH 7/7] sched: Track sched_entity usage contributions Morten Rasmussen
2014-09-22 17:09 ` bsegall
2014-09-23 13:59 ` Morten Rasmussen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412749572-29449-3-git-send-email-mturquette@linaro.org \
--to=mturquette@linaro.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=nicolas.pitre@linaro.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=rjw@rjwysocki.net \
--cc=tuukka.tikkanen@linaro.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).