aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Turquette <mturquette+renesas@baylibre.com>2016-03-09 15:18:27 -0800
committerMichael Turquette <mturquette+renesas@baylibre.com>2016-03-13 21:26:57 -0700
commitf701e4ee2dab992f7a195698381b772e7c1a4084 (patch)
treeab4949754876a737fc28ae8293e755840c12aa75
parenta4ccf611d8a1611c0be093cbd00f552d57fbd9ad (diff)
downloadlinux-schedutil-v3-enhancements.tar.gz
sched: prefer cpufreq_scale_freq_capacityschedutil-v3-enhancements
arch_scale_freq_capacity is weird. It specifies an arch hook for an implementation that could easily vary within an architecture or even a chip family. This patch helps to mitigate this weirdness by defaulting to the cpufreq-provided implementation, which should work for all cases where CONFIG_CPU_FREQ is set. If CONFIG_CPU_FREQ is not set, then try to use an implementation provided by the architecture. Failing that, fall back to SCHED_CAPACITY_SCALE. It may be desirable for cpufreq drivers to specify their own implementation of arch_scale_freq_capacity in the future. The same is true for platform code within an architecture. In both cases an efficient implementation selector will need to be created and this patch adds a comment to that effect. Signed-off-by: Michael Turquette <mturquette+renesas@baylibre.com>
-rw-r--r--kernel/sched/sched.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 469d11d197ca41..37502ea7882f46 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1368,7 +1368,21 @@ static inline int hrtick_enabled(struct rq *rq)
#ifdef CONFIG_SMP
extern void sched_avg_update(struct rq *rq);
-#ifndef arch_scale_freq_capacity
+/*
+ * arch_scale_freq_capacity can be implemented by cpufreq, platform code or
+ * arch code. We select the cpufreq-provided implementation first. If it
+ * doesn't exist then we default to any other implementation provided from
+ * platform/arch code. If those do not exist then we use the default
+ * SCHED_CAPACITY_SCALE value below.
+ *
+ * Note that if cpufreq drivers or platform/arch code have competing
+ * implementations it is up to those subsystems to select one at runtime with
+ * an efficient solution, as we cannot tolerate the overhead of indirect
+ * functions (e.g. function pointers) in the scheduler fast path
+ */
+#ifdef CONFIG_CPU_FREQ
+#define arch_scale_freq_capacity cpufreq_scale_freq_capacity
+#elif !defined(arch_scale_freq_capacity)
static __always_inline
unsigned long arch_scale_freq_capacity(struct sched_domain *sd, int cpu)
{