From 120bb69d3fc03bfedf9efe19211cc787380ee37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Fri, 29 Nov 2019 01:03:45 +0100 Subject: [PATCH] latency: support None value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows writing e.g.: [cpu] force_latency=cstate.name:XYZ|None In this case if C-state with name XYZ doesn't exist force_latency will be evaluated to 'None' and nothing will be set and no error will be reported. If '|None' is omitted, error will be reported. Another example: [cpu] force_latency=None Here, it will also set nothing and no error will be reported. When 'None' is encountered it stops parsing the latency, so writing 'None|1' will also result in no latency set. Both 'none' and 'None' can be used interchangeably with the same effect. Signed-off-by: Jaroslav Škarvada --- tuned/plugins/plugin_cpu.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py index b67c04b..b6f14b1 100644 --- a/tuned/plugins/plugin_cpu.py +++ b/tuned/plugins/plugin_cpu.py @@ -259,6 +259,7 @@ class CPULatencyPlugin(base.Plugin): log.debug("cstate ID mapped to latency: %s" % str(latency)) return latency + # returns (latency, skip), skip means we want to skip latency settings def _parse_latency(self, latency): self.cstates_latency = None latencies = str(latency).split("|") @@ -272,16 +273,19 @@ class CPULatencyPlugin(base.Plugin): latency = self._get_latency_by_cstate_id(latency[10:]) elif latency[0:12] == "cstate.name:": latency = self._get_latency_by_cstate_name(latency[12:]) + elif latency in ["none", "None"]: + log.debug("latency 'none' specified") + return None, True else: latency = None log.debug("invalid latency specified: '%s'" % str(latency)) if latency is not None: break - return latency + return latency, False def _set_latency(self, latency): - latency = self._parse_latency(latency) - if self._has_pm_qos: + latency, skip = self._parse_latency(latency) + if not skip and self._has_pm_qos: if latency is None: log.error("unable to evaluate latency value (probably wrong settings in the 'cpu' section of current profile), disabling PM QoS") self._has_pm_qos = False