[PATCH v1 07/11] perf python: Update ungrouped evsel leader in clone

From: Ian Rogers
Date: Thu Jan 09 2025 - 02:52:57 EST


evsels are cloned in the python code as they form part of the Python
object pyrf_evsel. The cloning doesn't update the evsel's leader, do
this for the case of an evsel being ungrouped.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/python.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 45ee6479e4dd..9ffe1b633027 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -1303,6 +1303,8 @@ static PyObject *pyrf_evsel__from_evsel(struct evsel *evsel)
evsel__init(&pevsel->evsel, &evsel->core.attr, evsel->core.idx);

evsel__clone(&pevsel->evsel, evsel);
+ if (evsel__is_group_leader(evsel))
+ evsel__set_leader(&pevsel->evsel, &pevsel->evsel);
return (PyObject *)pevsel;
}

--
2.47.1.613.gc27f4b7a9f-goog