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] 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