This mixin class provides recipe parameter 'disable_turboboost' that can be
used to disable CPU turboboost before running a performance test through
BaseEnrtRecipe.do_perf_tests().
It uses intel_pstate sysfs interface to disable the CPU feature and so
it is usable only by systems with Intel CPUs.
To use it pass 'disable_turboost=True' parameter when creating an instance of
BaseEnrtRecipe.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
.../PerfTestMixins/DisableTurboboostMixin.py | 55 +++++++++++++++++++
lnst/Recipes/ENRT/PerfTestMixins/__init__.py | 1 +
2 files changed, 56 insertions(+)
create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/DisableTurboboostMixin.py
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/DisableTurboboostMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/DisableTurboboostMixin.py
new file mode 100644
index 00000000..8beec018
--- /dev/null
+++ b/lnst/Recipes/ENRT/PerfTestMixins/DisableTurboboostMixin.py
@@ -0,0 +1,55 @@
+from lnst.Common.Parameters import BoolParam
+from lnst.Recipes.ENRT.PerfTestMixins import BasePerfTestTweakMixin
+
+class DisableTurboboostMixin(BasePerfTestTweakMixin):
+ disable_turboboost = BoolParam(default=False)
+
+ def generate_perf_test_tweak_description(self, perf_config):
+ description = super().generate_perf_test_tweak_description(perf_config)
+ tweak_config = perf_config.perf_test_tweak_config
+ if 'turboboost' in tweak_config:
+ for host, host_data in tweak_config['turboboost'].items():
+ description.append(host_data['desc'])
+ else:
+ description.append("skipped disabling turboboost through
intel_pstate")
+
+ return description
+
+ def _is_turboboost_supported(self, host):
+ file_check = host.run("ls
/sys/devices/system/cpu/intel_pstate/no_turbo")
+ return file_check.passed
+
+ def apply_perf_test_tweak(self, perf_config):
+ super().apply_perf_test_tweak(perf_config)
+ if self.params.disable_turboboost:
+ tweak_config = perf_config.perf_test_tweak_config
+ tweak_config['turboboost'] = {}
+
+ flow_measurement = self._get_flow_measurement_from_config(perf_config)
+ flow = flow_measurement.conf[0]
+ for host in [flow.generator, flow.receiver]:
+ if self._is_turboboost_supported(host):
+ # TODO: save previous state
+ host.run("echo 1 >
/sys/devices/system/cpu/intel_pstate/no_turbo")
+ desc = "disabled turboboost through intel_pstate on
{}".format(host.hostid)
+ turboboost_status = 'disabled'
+ else:
+ desc = "warning: user requested to disable turboboost "\
+ "through intel_pstate but the sysfs file is not
available "\
+ "on host {}".format(host.hostid)
+ turboboost_status = 'unsupported'
+ tweak_config['turboboost'][host] = {
+ 'desc': desc,
+ 'status': turboboost_status,
+ }
+
+ def remove_perf_test_tweak(self, perf_config):
+ tweak_config = perf_config.perf_test_tweak_config
+ if 'turboboost' in tweak_config:
+ for host, host_data in tweak_config['turboboost'].items():
+ if host_data['status'] == 'disabled':
+ host.run("echo 0 >
/sys/devices/system/cpu/intel_pstate/no_turbo")
+
+ del tweak_config['turboboost']
+
+ super().remove_perf_test_tweak(perf_config)
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
index fc5b4747..cbc9eda8 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
@@ -1,3 +1,4 @@
from lnst.Recipes.ENRT.PerfTestMixins.BasePerfTestTweakMixin import
BasePerfTestTweakMixin
from lnst.Recipes.ENRT.PerfTestMixins.SctpFirewallPerfTestMixin import
SctpFirewallPerfTestMixin
from lnst.Recipes.ENRT.PerfTestMixins.DisableIdleStatesMixin import
DisableIdleStatesMixin
+from lnst.Recipes.ENRT.PerfTestMixins.DisableTurboboostMixin import
DisableTurboboostMixin
--
2.21.3