From 1b6b0907f9ebe2fb012b10d26753200e19399d78 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 28 Aug 2015 17:11:04 +0100 Subject: [PATCH] energy_model: further fixes to idle measurement. - Fix to core frequency to min - Only disable idle states that are deeper than the measured state. Keep shallower states enabed. --- wlauto/instrumentation/energy_model/__init__.py | 9 ++++++--- wlauto/modules/cpuidle.py | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wlauto/instrumentation/energy_model/__init__.py b/wlauto/instrumentation/energy_model/__init__.py index 8b22b61f..f3c446c9 100644 --- a/wlauto/instrumentation/energy_model/__init__.py +++ b/wlauto/instrumentation/energy_model/__init__.py @@ -475,10 +475,10 @@ class EnergyModelInstrument(Instrument): if not context.spec.label.startswith('idle_'): return for idle_state in self.get_device_idle_states(self.measured_cluster): - if idle_state.id == context.spec.idle_state_id: - idle_state.disable = 0 - else: + if idle_state.id > context.spec.idle_state_index: idle_state.disable = 1 + else: + idle_state.disable = 0 def fast_start(self, context): # pylint: disable=unused-argument self.start_time = time.time() @@ -718,6 +718,7 @@ class EnergyModelInstrument(Instrument): cluster_frequencies = self.get_frequencies_param(cluster) if not cluster_frequencies: raise InstrumentError('Could not read available frequencies for {}'.format(core)) + min_frequency = min(cluster_frequencies) idle_states = self.get_device_idle_states(cluster) new_specs = [] @@ -728,8 +729,10 @@ class EnergyModelInstrument(Instrument): spec.workload_parameters = self.idle_workload_params spec.idle_state_id = state.id spec.idle_state_desc = state.desc + spec.idle_state_index = state.index if not self.no_hotplug: spec.runtime_parameters['{}_cores'.format(core)] = num_cpus + spec.runtime_parameters['{}_frequency'.format(core)] = min_frequency spec.cluster = cluster spec.num_cpus = num_cpus spec.id = '{}_idle_{}_{}'.format(cluster, state.id, num_cpus) diff --git a/wlauto/modules/cpuidle.py b/wlauto/modules/cpuidle.py index 9977e579..5030f963 100644 --- a/wlauto/modules/cpuidle.py +++ b/wlauto/modules/cpuidle.py @@ -45,8 +45,9 @@ class CpuidleState(object): raise ValueError('invalid idle state name: "{}"'.format(self.id)) return int(self.id[i:]) - def __init__(self, device, path): + def __init__(self, device, index, path): self.device = device + self.index = index self.path = path self.id = self.device.path.basename(self.path) self.cpu = self.device.path.basename(self.device.path.dirname(path)) @@ -106,7 +107,8 @@ class Cpuidle(Module): idle_states = [] for state in self.device.listdir(states_dir): if state.startswith('state'): - idle_states.append(CpuidleState(self.device, self.device.path.join(states_dir, state))) + index = int(state[5:]) + idle_states.append(CpuidleState(self.device, index, self.device.path.join(states_dir, state))) return idle_states def _on_device_init(self, context): # pylint: disable=unused-argument