Skip to content

Commit bfbb3a0

Browse files
credppundiramit
authored andcommitted
ANDROID: sched/fair: Select correct capacity state for energy_diff
The util returned from group_max_util is not capped at the max util present in the group, so it can be larger than the capacity stored in the array. Ensure that when this happens, we always use the last entry in the array to fetch energy from. Tested with synthetics on Juno board. Bug: 38159576 Change-Id: I89fb52fb7e68fa3e682e308acc232596672d03f7 Signed-off-by: Chris Redpath <chris.redpath@arm.com>
1 parent b215e14 commit bfbb3a0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

kernel/sched/fair.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,17 +5384,20 @@ long group_norm_util(struct energy_env *eenv, struct sched_group *sg)
53845384
static int find_new_capacity(struct energy_env *eenv,
53855385
const struct sched_group_energy * const sge)
53865386
{
5387-
int idx;
5387+
int idx, max_idx = sge->nr_cap_states - 1;
53885388
unsigned long util = group_max_util(eenv);
53895389

5390+
/* default is max_cap if we don't find a match */
5391+
eenv->cap_idx = max_idx;
5392+
53905393
for (idx = 0; idx < sge->nr_cap_states; idx++) {
5391-
if (sge->cap_states[idx].cap >= util)
5394+
if (sge->cap_states[idx].cap >= util) {
5395+
eenv->cap_idx = idx;
53925396
break;
5397+
}
53935398
}
53945399

5395-
eenv->cap_idx = idx;
5396-
5397-
return idx;
5400+
return eenv->cap_idx;
53985401
}
53995402

54005403
static int group_idle_state(struct energy_env *eenv, struct sched_group *sg)

0 commit comments

Comments
 (0)