From 33ae742cc00a1c89065b4cd9f7f999e1d3c9123d Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Wed, 17 May 2017 16:14:06 +0100 Subject: [PATCH 1/2] tests/eas/load_tracking: Remove dependency on EnergyModel This test requires only the max capacities of the CPUs, which is available in sysfs in mainline (from v4.10). Instead of requiring a full EnergyModel, just use those files. --- tests/eas/load_tracking.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/eas/load_tracking.py b/tests/eas/load_tracking.py index 5985f3a38..c77c66dc9 100644 --- a/tests/eas/load_tracking.py +++ b/tests/eas/load_tracking.py @@ -45,6 +45,15 @@ class _LoadTrackingBase(LisaTest): 'modules': ['cpufreq', 'cgroups'], } + @memoized + @staticmethod + def _get_cpu_capacity(test_env, cpu): + if test_env.nrg_model: + return test_env.nrg_model.get_cpu_capacity(cpu) + + return test_env.target.read_int( + '/sys/devices/system/cpu/cpu{}/cpu_capacity'.format(cpu)) + @classmethod def setUpClass(cls, *args, **kwargs): super(_LoadTrackingBase, cls).runExperiments(*args, **kwargs) @@ -83,14 +92,19 @@ class _LoadTrackingBase(LisaTest): # Find the capacity of the CPU the workload was run on [cpu] = experiment.wload.cpus cpufreq = experiment.conf['cpufreq'] + + cpu_capacity = self._get_cpu_capacity(self.te, cpu) if cpufreq['governor'] == 'userspace': freq = cpufreq['freqs'][cpu] + max_freq = max(self.te.target.cpufreq.list_frequencies(cpu)) + cpu_capacity *= float(freq) / max_freq else: assert cpufreq['governor'] == 'performance' - freq = None - cpu_capacity = self.te.nrg_model.get_cpu_capacity(cpu, freq) - scaling_factor = float(cpu_capacity) / self.te.nrg_model.capacity_scale + # Scale the relative CPU/freq capacity into the range 0..1 + scale = max(self._get_cpu_capacity(self.te, cpu) + for cpu in range(self.te.target.number_of_cpus)) + scaling_factor = float(cpu_capacity) / scale return UTIL_SCALE * (duty_cycle_pct / 100.) * scaling_factor @@ -177,7 +191,8 @@ class FreqInvarianceTest(_LoadTrackingBase): @classmethod def _getExperimentsConf(cls, test_env): # Run on one of the CPUs with highest capacity - cpu = test_env.nrg_model.biggest_cpus[0] + cpu = max(range(test_env.target.number_of_cpus), + key=lambda c: cls._get_cpu_capacity(test_env, c)) wloads = { 'fie_10pct' : cls.get_wload(cpu) @@ -267,8 +282,13 @@ class CpuInvarianceTest(_LoadTrackingBase): def _getExperimentsConf(cls, test_env): # Run the 10% workload on one CPU in each capacity group wloads = {} - for group in test_env.nrg_model.cpu_groups: - cpu = group[0] + tested_caps = set() + for cpu in range(test_env.target.number_of_cpus): + cap = cls._get_cpu_capacity(test_env, cpu) + if cap in tested_caps: + # No need to test on every CPU, just one for each capacity value + continue + tested_caps.add(cap) wloads['cie_cpu{}'.format(cpu)] = cls.get_wload(cpu) conf = { -- GitLab From 0407cfbc0c17326965472890258ca496eca72e34 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Fri, 19 May 2017 13:52:33 +0100 Subject: [PATCH 2/2] tests/eas/load_tracking: Cosmetic improvements Split up the CPU scaling and frequency scaling, and improve some comments. Zero functional change, just aims to improve clarity a little bit. --- tests/eas/load_tracking.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/eas/load_tracking.py b/tests/eas/load_tracking.py index c77c66dc9..989c57137 100644 --- a/tests/eas/load_tracking.py +++ b/tests/eas/load_tracking.py @@ -89,11 +89,13 @@ class _LoadTrackingBase(LisaTest): sched_assert = self.get_sched_assert(experiment, task) duty_cycle_pct = sched_assert.getDutyCycle(self.get_window(experiment)) - # Find the capacity of the CPU the workload was run on + # Find the (max) capacity of the CPU the workload was run on [cpu] = experiment.wload.cpus - cpufreq = experiment.conf['cpufreq'] - cpu_capacity = self._get_cpu_capacity(self.te, cpu) + + # Scale the capacity linearly according to the frequency the workload + # was run at + cpufreq = experiment.conf['cpufreq'] if cpufreq['governor'] == 'userspace': freq = cpufreq['freqs'][cpu] max_freq = max(self.te.target.cpufreq.list_frequencies(cpu)) -- GitLab