This patch refines function find_new_capacity() with more general arguments, so this function can be used as a general function to predict OPP index. And using 80% as the margin to predict OPP idx.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/fair.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) mode change 100644 => 100755 kernel/sched/fair.c
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c old mode 100644 new mode 100755 index 487fbe5..42a40bf --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5383,18 +5383,20 @@ long group_norm_util(struct energy_env *eenv, struct sched_group *sg) return util_sum; }
-static int find_new_capacity(struct energy_env *eenv, - const struct sched_group_energy * const sge) +static int find_new_capacity(const struct sched_group_energy const *sge, + unsigned long util) { int idx; - unsigned long util = group_max_util(eenv);
for (idx = 0; idx < sge->nr_cap_states; idx++) { - if (sge->cap_states[idx].cap >= util) + if (sge->cap_states[idx].cap * 1024 >= + util * capacity_margin) break; }
- eenv->cap_idx = idx; + /* roll back to max index */ + if (idx == sge->nr_cap_states) + idx = idx - 1;
return idx; } @@ -5465,7 +5467,8 @@ static int sched_group_energy(struct energy_env *eenv) else eenv->sg_cap = sg;
- cap_idx = find_new_capacity(eenv, sg->sge); + cap_idx = find_new_capacity(sg->sge, group_max_util(eenv)); + eenv->cap_idx = cap_idx;
if (sg->group_weight == 1) { /* Remove capacity of src CPU (before task move) */ -- 1.9.1