Skip to content

Commit

Permalink
fix: workaround for redhat-performance#662
Browse files Browse the repository at this point in the history
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] redhat-performance#662

Signed-off-by: Adriaan Schmidt <[email protected]>
  • Loading branch information
adriaan42 committed Oct 1, 2024
1 parent a9bf1ce commit 97b2e60
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions tuned/plugins/plugin_kthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

#
Expand All @@ -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):
Expand Down Expand Up @@ -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 thread
# 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)
Expand Down

0 comments on commit 97b2e60

Please sign in to comment.