mirror of
https://github.com/ARM-software/devlib.git
synced 2025-11-14 12:45:17 +00:00
module/sched: Return the correct maximum capacity
The existing behaviour assumes that the cap_states file contains a list
of capacity|cost pairs, and attempts to return the maximum capacity by
selecting the value at the second last index of the list.
This assumption fails on some newer Qualcomm kernels where the
cap_states file contains a list of capacity|frequency|cost triplets.
Consequently, the maximum frequency would be erroneously returned
instead of the maximum capacity.
Fix the problem by dynamically calculating the index of the maximum
capacity by dividing the number of entries in cap_states by the value in
nr_cap_states.
---
For example, on a certain Snapdragon 845 device:
/proc/sys/kernel/sched_domain/cpu0/domain0/group0/energy/cap_states
54 entries:
CAP FREQ COST
--------------------
65 300000 12
87 403200 17
104 480000 21
125 576000 27
141 652800 31
162 748800 37
179 825600 42
195 902400 47
212 979200 52
228 1056000 57
245 1132800 62
266 1228800 70
286 1324800 78
307 1420800 89
328 1516800 103
348 1612800 122
365 1689600 141
381 1766400 160
/proc/sys/kernel/sched_domain/cpu0/domain0/group0/energy/nr_cap_states
18
Max capacity = 381 (third-last index)
This commit is contained in:
@@ -415,7 +415,10 @@ class SchedModule(Module):
|
||||
sd = SchedProcFSData(self.target, cpu)
|
||||
|
||||
cap_states = sd.domains[0].groups[0].energy.cap_states
|
||||
return int(cap_states.split('\t')[-2])
|
||||
cap_states_list = cap_states.split('\t')
|
||||
num_cap_states = sd.domains[0].groups[0].energy.nr_cap_states
|
||||
max_cap_index = -1 * int(len(cap_states_list) / num_cap_states)
|
||||
return int(cap_states_list[max_cap_index])
|
||||
|
||||
@memoized
|
||||
def get_dmips_capacity(self, cpu):
|
||||
|
||||
Reference in New Issue
Block a user