Tue, Oct 13, 2020 at 10:21:27AM CEST, olichtne(a)redhat.com wrote:
On Mon, Oct 12, 2020 at 07:15:12PM +0200, Jan Tluka wrote:
> 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)
You don't need to set a "special" value to indicate that the parameter
wasn't set.
If the parameter is not mandatory and you don't provide a value for it
on Recipe initialization, the parameter isn't available during test
execution, e.g.:
class Recipe():
optional_param = IntParam(mandatory=False)
def test(self):
if "optional_param" in self.params:
configure(self.params.optional_param)
I'll fix this.
> +
> + 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
I'm not sure about the name of the parameter... why call it
"disable_idlestates" when in reality it refers to the latency to be
used? shouldn't it somehow be reflected in the name of the parameter
itself?
Yeah, probably 'minimal_idlestates_latency' is better.
> + 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]:
I'm wondering how this will work for Virtual recipes, the generator and
receiver in those cases refer to the guest vms, can we also disable
idlestates for virtual cores?
No idea. I'll have to check.
Should we consider disabling them for the hypervisor hosts?
Very likely. I'll work on enhancing this and send v2.
-Ondrej
> + # 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
> _______________________________________________
> LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
> To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org
> Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedora...