From 3e91c01a5993488bf65361c514defa7cf82f6ac3 Mon Sep 17 00:00:00 2001 From: Adriaan Schmidt Date: Thu, 25 Jul 2024 07:44:02 +0200 Subject: [PATCH] fix: workaround for #662 Calls to our _instance_[un]apply_static() are unreliable [1], so we can't use them to keep track of the active-instance count, to start/stop the perf monitor thread on demand. Instead, this keeps the thread running continuously. [1] https://github.com/redhat-performance/tuned/issues/662 Signed-off-by: Adriaan Schmidt --- tuned/plugins/plugin_kthread.py | 34 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tuned/plugins/plugin_kthread.py b/tuned/plugins/plugin_kthread.py index 7a6c3142..8d051750 100644 --- a/tuned/plugins/plugin_kthread.py +++ b/tuned/plugins/plugin_kthread.py @@ -132,6 +132,8 @@ def __init__(self, monitor_repository, storage_factory, hardware_inventory, devi def cleanup(self): super(KthreadPlugin, self).cleanup() + # workaround for #662: shut down the monitor thread + self._perf_monitor_shutdown() self._perf_shutdown() # @@ -142,6 +144,8 @@ def _init_devices(self): self._free_devices = set() self._assigned_devices = set() self._kthread_scan(initial=True) + # workaround for #662: always run the monitor thread + self._perf_monitor_start() @classmethod def _get_config_options(cls): @@ -265,19 +269,23 @@ def _get_matching_devices(self, instance, devices): matching_devices.add(device) return matching_devices - def _instance_apply_static(self, instance): - if self._instance_count == 0: - # scan for kthreads that have appeared since plugin initialization - self._kthread_scan(initial=False) - self._perf_monitor_start() - self._instance_count += 1 - super(KthreadPlugin, self)._instance_apply_static(instance) - - def _instance_unapply_static(self, instance, rollback): - super(KthreadPlugin, self)._instance_unapply_static(instance, rollback) - self._instance_count -= 1 - if self._instance_count == 0: - self._perf_monitor_shutdown() + # workaround for #662: + # calls to our _instance_[un]apply_static() are unreliable, so we can't + # use them to count active instances and start/stop the monitor thred + # on demand (https://github.com/redhat-performance/tuned/issues/662) + #def _instance_apply_static(self, instance): + # if self._instance_count == 0: + # # scan for kthreads that have appeared since plugin initialization + # self._kthread_scan(initial=False) + # self._perf_monitor_start() + # self._instance_count += 1 + # super(KthreadPlugin, self)._instance_apply_static(instance) + + #def _instance_unapply_static(self, instance, rollback): + # super(KthreadPlugin, self)._instance_unapply_static(instance, rollback) + # self._instance_count -= 1 + # if self._instance_count == 0: + # self._perf_monitor_shutdown() # # internal bookkeeping (self._kthreads)