This mixin class provides recipe parameter 'disable_idlestates' that can be
used to control the CPU idle states before running a performance test through
BaseEnrtRecipe.do_perf_tests().
The value of the parameter is passed as the latency argument (-D) of the
'cpupower idle-set' that will disable all idle states with a equal or higher
latency than the specified value.
If the value is 0 this will effectively disable all CPU idle states.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
.../PerfTestMixins/DisableIdleStatesMixin.py | 42 +++++++++++++++++++
lnst/Recipes/ENRT/PerfTestMixins/__init__.py | 1 +
2 files changed, 43 insertions(+)
create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/DisableIdleStatesMixin.py
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/DisableIdleStatesMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/DisableIdleStatesMixin.py
new file mode 100644
index 00000000..4281016f
--- /dev/null
+++ b/lnst/Recipes/ENRT/PerfTestMixins/DisableIdleStatesMixin.py
@@ -0,0 +1,42 @@
+from lnst.Common.Parameters import IntParam
+from lnst.Recipes.ENRT.PerfTestMixins import BasePerfTestTweakMixin
+
+class DisableIdleStatesMixin(BasePerfTestTweakMixin):
+ disable_idlestates = IntParam(default=-1)
+
+ def generate_perf_test_tweak_description(self, perf_config):
+ description = super().generate_perf_test_tweak_description(perf_config)
+ latency = self.params.disable_idlestates
+ tweak_config = perf_config.perf_test_tweak_config
+ if 'idlestates' in tweak_config:
+ for host in tweak_config['idlestates']['hosts']:
+ desc = "disabled idle states with latency higher than {} "\
+ "on host {}".format(latency, host.hostid)
+ description.append(desc)
+ else:
+ description.append("skipped disabling idle states")
+
+ return description
+
+ def apply_perf_test_tweak(self, perf_config):
+ super().apply_perf_test_tweak(perf_config)
+ latency = self.params.disable_idlestates
+ if latency != -1:
+ tweak_config = perf_config.perf_test_tweak_config
+ tweak_config['idlestates'] = {'hosts': []}
+
+ flow_measurement = self._get_flow_measurement_from_config(perf_config)
+ flow = flow_measurement.conf[0]
+ for host in [flow.generator, flow.receiver]:
+ # TODO: save previous state
+ host.run("cpupower idle-set -D {}".format(latency))
+ tweak_config['idlestates']['hosts'].append(host)
+
+ def remove_perf_test_tweak(self, perf_config):
+ tweak_config = perf_config.perf_test_tweak_config
+ if 'idlestates' in tweak_config:
+ for host in tweak_config['idlestates']['hosts']:
+ host.run("cpupower idle-set -E")
+ del tweak_config['idlestates']
+
+ super().remove_perf_test_tweak(perf_config)
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
index 9f320118..fc5b4747 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
@@ -1,2 +1,3 @@
from lnst.Recipes.ENRT.PerfTestMixins.BasePerfTestTweakMixin import
BasePerfTestTweakMixin
from lnst.Recipes.ENRT.PerfTestMixins.SctpFirewallPerfTestMixin import
SctpFirewallPerfTestMixin
+from lnst.Recipes.ENRT.PerfTestMixins.DisableIdleStatesMixin import
DisableIdleStatesMixin
--
2.21.3