This mixin class extends BaseEnrtRecipe with ability to control the CPU idle
states before running the tests.
The class adds 'minimal_idlestates_latency' parameter that is passed as the
latency argument (-D) of the 'cpupower idle-set' that will disable all idle
states with an 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>
---
.../ConfigMixins/DisableIdleStatesMixin.py | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 lnst/Recipes/ENRT/ConfigMixins/DisableIdleStatesMixin.py
diff --git a/lnst/Recipes/ENRT/ConfigMixins/DisableIdleStatesMixin.py
b/lnst/Recipes/ENRT/ConfigMixins/DisableIdleStatesMixin.py
new file mode 100644
index 00000000..ca45dfb3
--- /dev/null
+++ b/lnst/Recipes/ENRT/ConfigMixins/DisableIdleStatesMixin.py
@@ -0,0 +1,42 @@
+from lnst.Common.Parameters import IntParam
+from lnst.Recipes.ENRT.ConfigMixins import BaseSubConfigMixin
+
+class DisableIdleStatesMixin(BaseSubConfigMixin):
+ minimal_idlestates_latency = IntParam()
+
+ @property
+ def disable_idlestates_host_list(self):
+ """
+ The value of this property is a list of hosts for which the CPU idle
+ states should be turned off. Derived class can override this property.
+ """
+ return []
+
+ def apply_sub_configuration(self, config):
+ super().apply_sub_configuration(config)
+
+ latency = getattr(self.params, "minimal_idlestates_latency", None)
+ if latency is not None:
+ for host in self.disable_idlestates_host_list:
+ # TODO: save previous state
+ host.run("cpupower idle-set -D {}".format(latency))
+
+ def generate_sub_configuration_description(self, config):
+ description = super().generate_sub_configuration_description(config)
+
+ latency = getattr(self.params, "minimal_idlestates_latency", None)
+ if latency is not None:
+ for host in self.disable_idlestates_host_list:
+ description.append("disabled idle states with latency higher than
"\
+ "{} on host {}".format(latency, host.hostid)
+ )
+ else:
+ description.append("configuration of idle states skipped")
+
+ return description
+
+ def remove_sub_configuration(self, config):
+ for host in self.disable_idlestates_host_list:
+ host.run("cpupower idle-set -E")
+
+ return super().remove_sub_configuration(config)
--
2.21.3