Based on the sched_group and waken task utilization, we can estimate the capacity index ahead energy computation, and the capacity index is consistent for all CPUs in the group.
This patch moves capacity index estimation ahead energy computation, and optimize to only estimate capacity index once and remove redundant estimations for every CPU in the code.
Change-Id: I634f2fa47d2e762a1b5e570c7f792b67e202a1d2 Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/fair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2596e51..e5d5ed5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5689,7 +5689,7 @@ static void calc_sg_energy(struct energy_env *eenv, int cpu) int total_energy = 0;
/* Compute ACTIVE energy */ - cap_idx = find_new_capacity(eenv, cpu); + cap_idx = eenv->cpu[cpu].cap_idx; busy_power = sg->sge->cap_states[cap_idx].power; /* * in order to calculate cpu_norm_util, we need to know which @@ -5834,6 +5834,8 @@ static int compute_task_energy(struct energy_env *eenv, int cpu) else eenv->sg_cap = sd_cap->groups;
+ find_new_capacity(eenv, cpu); + /* energy is unscaled to reduce rounding errors */ if (compute_energy(eenv, cpu) == -EINVAL) { eenv->next_cpu = eenv->prev_cpu; -- 1.9.1