From 298bc3a7f3e34c1f25ad7bcb7cd977046a4d12a7 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 15 Oct 2019 13:33:21 +0100 Subject: [PATCH] output_processors/cpustates: Deal with cpufreq data being unavailable If the `cpufreq` module is not detected as present then warn the user and processes the remaining data instead of crashing. --- wa/output_processors/cpustates.py | 3 +++ wa/utils/cpustates.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wa/output_processors/cpustates.py b/wa/output_processors/cpustates.py index 936b1170..9239d755 100755 --- a/wa/output_processors/cpustates.py +++ b/wa/output_processors/cpustates.py @@ -94,6 +94,9 @@ class CpuStatesProcessor(OutputProcessor): if not trace_file: self.logger.warning('Text trace does not appear to have been generated; skipping this iteration.') return + if 'cpufreq' not in target_info.modules: + msg = '"cpufreq" module not detected on target, cpu frequency information may be missing.' + self.logger.warning(msg) self.logger.info('Generating power state reports from trace...') reports = report_power_stats( # pylint: disable=unbalanced-tuple-unpacking diff --git a/wa/utils/cpustates.py b/wa/utils/cpustates.py index 632b7e9f..0dc59d5a 100755 --- a/wa/utils/cpustates.py +++ b/wa/utils/cpustates.py @@ -560,12 +560,12 @@ class CpuUtilizationTimeline(object): headers = ['ts'] + ['{} CPU{}'.format(cpu.name, cpu.id) for cpu in cpus] self.writer.writerow(headers) - self._max_freq_list = [cpu.cpufreq.available_frequencies[-1] for cpu in cpus] + self._max_freq_list = [cpu.cpufreq.available_frequencies[-1] for cpu in cpus if cpu.cpufreq.available_frequencies] def update(self, timestamp, core_states): # NOQA row = [timestamp] for core, [_, frequency] in enumerate(core_states): - if frequency is not None: + if frequency is not None and core in self._max_freq_list: frequency /= float(self._max_freq_list[core]) row.append(frequency) else: