From 17c58c55e83a49887fbf4c24393903c07d783186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Tue, 14 Jan 2025 15:31:06 +0100 Subject: [PATCH 1/2] tuned-ppd: Check that TuneD profile change signal is relevant If there are multiple profile switches coming closely after each other, all signals excepts the last one (with the current TuneD profile) are not relevant anymore and should be ignored. --- tuned/ppd/controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tuned/ppd/controller.py b/tuned/ppd/controller.py index 98d3b79..c4d89a5 100644 --- a/tuned/ppd/controller.py +++ b/tuned/ppd/controller.py @@ -244,6 +244,9 @@ class Controller(exports.interfaces.ExportableInterface): if not result: return self._profile_holds.clear() + if tuned_profile != self._tuned_interface.active_profile(): + log.debug("Received a profile change signal from TuneD, but it is not relevant anymore.") + return try: ppd_profile = self._config.tuned_to_ppd.get(tuned_profile, self._on_battery) except KeyError: From f4546e5ab6d776297c17af67a0ddf9f3a85a4cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Tue, 14 Jan 2025 15:33:07 +0100 Subject: [PATCH 2/2] tuned-ppd: Do not always clear holds with TuneD profile change signal The signal is received even when the profile change originates within tuned-ppd. We cannot reliably detect that is the case, so do not clear profile holds if the signalled profile corresponds to the currently active one. --- 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 c4d89a5..643fe21 100644 --- a/tuned/ppd/controller.py +++ b/tuned/ppd/controller.py @@ -243,7 +243,6 @@ class Controller(exports.interfaces.ExportableInterface): """ if not result: return - self._profile_holds.clear() if tuned_profile != self._tuned_interface.active_profile(): log.debug("Received a profile change signal from TuneD, but it is not relevant anymore.") return @@ -254,6 +253,7 @@ class Controller(exports.interfaces.ExportableInterface): log.warning("TuneD profile changed to an unknown profile '%s'" % tuned_profile) if self._active_profile != ppd_profile: log.info("Profile changed to '%s'" % ppd_profile) + self._profile_holds.clear() self._active_profile = ppd_profile exports.property_changed("ActiveProfile", self._active_profile) if ppd_profile != UNKNOWN_PROFILE: