aboutsummaryrefslogtreecommitdiff
path: root/kernel/sched/fair.c
diff options
context:
space:
mode:
authorDietmar Eggemann <dietmar.eggemann@arm.com>2014-12-02 14:06:24 +0000
committerVincent Guittot <vincent.guittot@linaro.org>2014-12-03 15:53:42 +0100
commit9422f02b83fbd5decebaa577f81b05136dc38cc9 (patch)
treef044d387ecfe374342307f99c8f3d9a9e3dec201 /kernel/sched/fair.c
parentbdae7fcd7ba2fbd8dec7881ea27bccf998bd84a7 (diff)
sched: Make usage and load tracking cpu scale-invariant
Besides the existing frequency scale-invariance correction factor, apply cpu scale-invariance correction factor to usage and load tracking. Cpu scale-invariance takes cpu performance deviations due to micro-architectural differences (i.e. instructions per seconds) between cpus in HMP systems (e.g. big.LITTLE) and differences in the frequency value of the highest OPP between cpus in SMP systems into consideration. Each segment of the sched_avg::{running_avg_sum, runnable_avg_sum} geometric series is now scaled by the cpu performance factor too so the sched_avg::{utilization_avg_contrib, load_avg_contrib} of each entity will be invariant from the particular cpu of the HMP/SMP system it is gathered on. As a result, cfs_rq::runnable_load_avg which is the sum of sched_avg::load_avg_contrib, becomes cpu scale-invariant too. So the {usage, load} level that is returned by {get_cpu_usage, weighted_cpuload} stays relative to the max cpu performance of the system. Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Diffstat (limited to 'kernel/sched/fair.c')
-rw-r--r--kernel/sched/fair.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 80d112254f25..d0d829a848f5 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2267,6 +2267,21 @@ static u32 __compute_runnable_contrib(u64 n)
}
unsigned long __weak arch_scale_freq_capacity(struct sched_domain *sd, int cpu);
+unsigned long __weak arch_scale_cpu_capacity(struct sched_domain *sd, int cpu);
+
+static unsigned long contrib_scale_factor(int cpu)
+{
+ unsigned long scale_factor;
+
+ scale_factor = arch_scale_freq_capacity(NULL, cpu);
+ scale_factor *= arch_scale_cpu_capacity(NULL, cpu);
+ scale_factor >>= SCHED_CAPACITY_SHIFT;
+
+ return scale_factor;
+}
+
+#define scale_contrib(contrib, scale_factor) \
+ ((contrib * scale_factor) >> SCHED_CAPACITY_SHIFT)
/*
* We can represent the historical contribution to runnable average as the
@@ -2304,7 +2319,7 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
u64 delta, scaled_delta, periods;
u32 runnable_contrib, scaled_runnable_contrib;
int delta_w, scaled_delta_w, decayed = 0;
- unsigned long scale_freq = arch_scale_freq_capacity(NULL, cpu);
+ unsigned long scale_factor;
delta = now - sa->last_runnable_update;
/*
@@ -2325,6 +2340,8 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
return 0;
sa->last_runnable_update = now;
+ scale_factor = contrib_scale_factor(cpu);
+
/* delta_w is the amount already accumulated against our next period */
delta_w = sa->avg_period % 1024;
if (delta + delta_w >= 1024) {
@@ -2337,7 +2354,7 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
* period and accrue it.
*/
delta_w = 1024 - delta_w;
- scaled_delta_w = (delta_w * scale_freq) >> SCHED_CAPACITY_SHIFT;
+ scaled_delta_w = scale_contrib(delta_w, scale_factor);
if (runnable)
sa->runnable_avg_sum += scaled_delta_w;
@@ -2360,8 +2377,8 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
/* Efficiently calculate \sum (1..n_period) 1024*y^i */
runnable_contrib = __compute_runnable_contrib(periods);
- scaled_runnable_contrib = (runnable_contrib * scale_freq)
- >> SCHED_CAPACITY_SHIFT;
+ scaled_runnable_contrib =
+ scale_contrib(runnable_contrib, scale_factor);
if (runnable)
sa->runnable_avg_sum += scaled_runnable_contrib;
@@ -2371,7 +2388,7 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
}
/* Remainder of delta accrued against u_0` */
- scaled_delta = (delta * scale_freq) >> SCHED_CAPACITY_SHIFT;
+ scaled_delta = scale_contrib(delta, scale_factor);
if (runnable)
sa->runnable_avg_sum += scaled_delta;