[RFC,v2,04/09] ARM: scheduler: add a cpu_power function

Message ID 1321274314-2318-1-git-send-email-vincent.guittot@linaro.org
State New
Headers show

Commit Message

Vincent Guittot Nov. 14, 2011, 12:38 p.m.
Add an architecture specific function for setting cpu_power

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
 arch/arm/kernel/topology.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

Patch

diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index af1c3e6..9d80e22 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -45,12 +45,32 @@ 
 struct cputopo_arm cpu_topology[NR_CPUS];
 
 /*
+ * cpu power scale management
+ */
+
+/*
+ * a per cpu data structure should be better because each cpu is mainly
+ * using its own cpu_power even it's not always true because of
+ * no_hz_idle_balance
+ */
+static DEFINE_PER_CPU(unsigned int, cpu_scale);
+
+/*
  * cpu topology mask management
  */
 
 unsigned int advanced_topology = 1;
 
 /*
+ * Update the cpu power
+ */
+
+unsigned long arch_scale_freq_power(struct sched_domain *sd, int cpu)
+{
+	return per_cpu(cpu_scale, cpu);
+}
+
+/*
  * default topology function
  */
 
@@ -281,6 +301,8 @@  void init_cpu_topology(void)
 		cpu_topo->socket_id = -1;
 		cpumask_clear(&cpu_topo->core_sibling);
 		cpumask_clear(&cpu_topo->thread_sibling);
+
+		per_cpu(cpu_scale, cpu) = SCHED_POWER_SCALE;
 	}
 	smp_wmb();
 }