From 737d8c0af4f569007289c277aa555e0089d81acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Fri, 19 Apr 2024 09:50:25 +0200 Subject: [PATCH 1/3] ppd: Add debug logs when changing base profile --- tuned/ppd/controller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tuned/ppd/controller.py b/tuned/ppd/controller.py index f74d218..fdbfc4d 100644 --- a/tuned/ppd/controller.py +++ b/tuned/ppd/controller.py @@ -135,6 +135,7 @@ class Controller(exports.interfaces.ExportableInterface): def load_config(self): self._config = PPDConfig(PPD_CONFIG_FILE) + log.debug("Setting base profile to %s" % self._config.default_profile) self._base_profile = self._config.default_profile self.switch_profile(self._config.default_profile) @@ -172,6 +173,7 @@ class Controller(exports.interfaces.ExportableInterface): def set_active_profile(self, profile): if profile not in self._config.ppd_to_tuned: raise dbus.exceptions.DBusException("Invalid profile '%s'" % profile) + log.debug("Setting base profile to %s" % profile) self._base_profile = profile self._profile_holds.clear() self.switch_profile(profile) From b2ed1258c73055c2830c438ae1f3214e3c84ee3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Fri, 19 Apr 2024 09:51:31 +0200 Subject: [PATCH 2/3] ppd: Fix hold releasing Do not iterate directly through the dictionary of holds, because it's being modified. Instead, iterate through the list of the dictionary keys. --- tuned/ppd/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuned/ppd/controller.py b/tuned/ppd/controller.py index fdbfc4d..966da4c 100644 --- a/tuned/ppd/controller.py +++ b/tuned/ppd/controller.py @@ -88,7 +88,7 @@ class ProfileHoldManager(object): self._controller.switch_profile(new_profile) def clear(self): - for cookie in self._holds: + for cookie in list(self._holds.keys()): self._cancel(cookie) From 31b21edc8a5c19e5c1f9c7c602c49a22aa15749f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Fri, 19 Apr 2024 09:53:08 +0200 Subject: [PATCH 3/3] ppd: Adjust the detection of 'performance-degraded' In rare cases, 'lap-mode' and 'no-turbo' files may be empty. Do not attempt to convert their content into integers. Instead check if it's directly equal to "1" (after stripping whitespace). --- tuned/ppd/controller.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tuned/ppd/controller.py b/tuned/ppd/controller.py index 966da4c..0f472d9 100644 --- a/tuned/ppd/controller.py +++ b/tuned/ppd/controller.py @@ -105,12 +105,10 @@ class Controller(exports.interfaces.ExportableInterface): def _check_performance_degraded(self): performance_degraded = PerformanceDegraded.NONE - if os.path.exists(NO_TURBO_PATH): - if int(self._cmd.read_file(NO_TURBO_PATH)) == 1: - performance_degraded = PerformanceDegraded.HIGH_OPERATING_TEMPERATURE - if os.path.exists(LAP_MODE_PATH): - if int(self._cmd.read_file(LAP_MODE_PATH)) == 1: - performance_degraded = PerformanceDegraded.LAP_DETECTED + if os.path.exists(NO_TURBO_PATH) and self._cmd.read_file(NO_TURBO_PATH).strip() == "1": + performance_degraded = PerformanceDegraded.HIGH_OPERATING_TEMPERATURE + if os.path.exists(LAP_MODE_PATH) and self._cmd.read_file(LAP_MODE_PATH).strip() == "1": + performance_degraded = PerformanceDegraded.LAP_DETECTED if performance_degraded != self._performance_degraded: log.info("Performance degraded: %s" % performance_degraded) self._performance_degraded = performance_degraded