From 9935a951e9552f0693dff9bdf75091d57036b3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= Date: Mon, 30 Sep 2024 15:18:16 +0200 Subject: [PATCH] scheduler: Do not assume that perf events have type attribute The perf.evlist.read_on_cpu function may return instances of classes that do not have the type attribute, e.g. perf.lost_event. Make sure we do not read the type attribute if we are not sure that it exists. Resolves: RHEL-60898 --- tuned/plugins/plugin_scheduler.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tuned/plugins/plugin_scheduler.py b/tuned/plugins/plugin_scheduler.py index 7d9bcbe0..c25b35ee 100644 --- a/tuned/plugins/plugin_scheduler.py +++ b/tuned/plugins/plugin_scheduler.py @@ -1098,10 +1098,13 @@ def _thread_code(self, instance): event = instance._evlist.read_on_cpu(cpu) if event: read_events = True - if event.type == perf.RECORD_COMM or \ - (self._perf_process_fork_value and event.type == perf.RECORD_FORK): + if isinstance(event, perf.comm_event) or ( + self._perf_process_fork_value + and isinstance(event, perf.task_event) + and event.type == perf.RECORD_FORK + ): self._add_pid(instance, int(event.tid), r) - elif event.type == perf.RECORD_EXIT: + elif isinstance(event, perf.task_event) and event.type == perf.RECORD_EXIT: self._remove_pid(instance, int(event.tid)) @command_custom("cgroup_ps_blacklist", per_device = False)