Fix type error in _get_mali_freqs:
_get_mali_freqs was creating a list of ints instead of strings which was leading
to type issues when calling _trace_read_stats on kernel 3.8. This also gets rid
of converting the GPU frequencies to MHz since that creates conflicts when we
read the frequencies later.
BUG=chromium:309770
TEST=power_LoadTest on peach pit
make sure it finishes successfully
Change-Id: I40160a45fc48884d7a50fe6e0a5793f95d4843b9
Previous-Reviewed-on: https://chromium-review.googlesource.com/174044
(cherry picked from commit 940e00c5dc0b13ec47969064a7a38b09b28c1014)
Reviewed-on: https://chromium-review.googlesource.com/174840
Tested-by: Derek Basehore <dbasehore@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
diff --git a/client/cros/power_status.py b/client/cros/power_status.py
index 7c2ee9b..8d7fef9 100644
--- a/client/cros/power_status.py
+++ b/client/cros/power_status.py
@@ -678,7 +678,8 @@
_MALI_DEV = '/sys/class/misc/mali0/device'
_MALI_EVENTS = ['mali_dvfs:mali_dvfs_set_clock']
- _MALI_TRACE_CLK_RE = r'(\d+.\d+): mali_dvfs_set_clock: frequency=(\d+)'
+ _MALI_34_TRACE_CLK_RE = r'(\d+.\d+): mali_dvfs_set_clock: frequency=(\d+)'
+ _MALI_TRACE_CLK_RE = r'(\d+.\d+): mali_dvfs_set_clock: frequency=(\d+)\d{6}'
_I915_ROOT = '/sys/kernel/debug/dri/0'
_I915_EVENTS = ['i915:intel_gpu_freq_change']
@@ -711,7 +712,7 @@
533000000
Returns:
- cur_mhz: integer of current GPU clock in mhz
+ cur_mhz: string of current GPU clock in mhz
"""
cur_mhz = None
fqs = []
@@ -729,12 +730,12 @@
fqs = result
fd.close()
else:
- cur_mhz = int(int(utils.read_one_line(fname)) / 1e6)
+ cur_mhz = str(int(int(utils.read_one_line(fname).strip()) / 1e6))
fname = os.path.join(self._MALI_DEV, 'available_frequencies')
with open(fname) as fd:
- lns = fd.readlines()
- # TODO(tbroch): remove set/sort once crbug.com/293679 resolved
- fqs = list(int(int(ln.strip()) / 1e6) for ln in set(lns))
+ for ln in fd.readlines():
+ freq = int(int(ln.strip()) / 1e6)
+ fqs.append(str(freq))
fqs.sort()
self._freqs = fqs
@@ -846,6 +847,13 @@
def _mali_read_stats(self):
"""Read Mali GPU stats
+ For 3.4:
+ Frequencies are reported in MHz.
+
+ For 3.8+:
+ Frequencies are reported in Hz, so use a regex that drops the last 6
+ digits.
+
Output in trace looks like this:
kworker/u:24-5220 [000] .... 81060.329232: mali_dvfs_set_clock: frequency=400
@@ -855,7 +863,13 @@
Dict with frequency in mhz as key and float in seconds for time
spent at that frequency.
"""
- return self._trace_read_stats(self._MALI_TRACE_CLK_RE)
+ regexp = None
+ if os.uname()[2].startswith('3.4'):
+ regexp = self._MALI_34_TRACE_CLK_RE
+ else:
+ regexp = self._MALI_TRACE_CLK_RE
+
+ return self._trace_read_stats(regexp)
def _i915_read_stats(self):