[PATCH 6/7] sched: Make sched entity usage tracking scale-invariant
From: Morten Rasmussen
Date: Mon Sep 22 2014 - 12:24:20 EST
Apply scale-invariance correction factor to usage tracking as well.
cc: Paul Turner <pjt@xxxxxxxxxx>
cc: Ben Segall <bsegall@xxxxxxxxxx>
Signed-off-by: Morten Rasmussen <morten.rasmussen@xxxxxxx>
---
kernel/sched/fair.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d8a8c83..c7aa8c1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2302,9 +2302,9 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
int runnable,
int running)
{
- u64 delta, periods;
- u32 runnable_contrib;
- int delta_w, decayed = 0;
+ u64 delta, scaled_delta, periods;
+ u32 runnable_contrib, scaled_runnable_contrib;
+ int delta_w, scaled_delta_w, decayed = 0;
u32 scale_cap = arch_scale_load_capacity(cpu);
delta = now - sa->last_runnable_update;
@@ -2339,11 +2339,12 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu,
*/
delta_w = 1024 - delta_w;
+ scaled_delta_w = (delta_w * scale_cap) >> SCHED_CAPACITY_SHIFT;
+
if (runnable)
- sa->runnable_avg_sum += (delta_w * scale_cap)
- >> SCHED_CAPACITY_SHIFT;
+ sa->runnable_avg_sum += scaled_delta_w;
if (running)
- sa->usage_avg_sum += delta_w;
+ sa->usage_avg_sum += scaled_delta_w;
sa->runnable_avg_period += delta_w;
delta -= delta_w;
@@ -2361,20 +2362,23 @@ 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);
- if (runnable)
- sa->runnable_avg_sum += (runnable_contrib * scale_cap)
+ scaled_runnable_contrib = (runnable_contrib * scale_cap)
>> SCHED_CAPACITY_SHIFT;
+
+ if (runnable)
+ sa->runnable_avg_sum += scaled_runnable_contrib;
if (running)
- sa->usage_avg_sum += runnable_contrib;
+ sa->usage_avg_sum += scaled_runnable_contrib;
sa->runnable_avg_period += runnable_contrib;
}
/* Remainder of delta accrued against u_0` */
+ scaled_delta = (delta * scale_cap) >> SCHED_CAPACITY_SHIFT;
+
if (runnable)
- sa->runnable_avg_sum += (delta * scale_cap)
- >> SCHED_CAPACITY_SHIFT;
+ sa->runnable_avg_sum += scaled_delta;
if (running)
- sa->usage_avg_sum += delta;
+ sa->usage_avg_sum += scaled_delta;
sa->runnable_avg_period += delta;
return decayed;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/