From: Ian Rogers Date: Thu, 10 Jul 2025 23:51:22 +0000 (-0700) Subject: perf python: In str(evsel) use the evsel__pmu_name helper X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7d5b635d9f4314c93bc1f9828f5d757decb860bc;p=users%2Fjedix%2Flinux-maple.git perf python: In str(evsel) use the evsel__pmu_name helper The evsel__pmu_name helper will internally use evsel__find_pmu that handles legacy events, extended types, etc. in determining a PMU and will provide a better value than just trying to access the PMU's name directly as the PMU may not have been computed. Signed-off-by: Ian Rogers Link: https://lore.kernel.org/r/20250710235126.1086011-10-irogers@google.com Signed-off-by: Namhyung Kim --- diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index b5ee9f7a4662..0821205b1aaa 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -925,10 +925,7 @@ static PyObject *pyrf_evsel__str(PyObject *self) struct pyrf_evsel *pevsel = (void *)self; struct evsel *evsel = &pevsel->evsel; - if (!evsel->pmu) - return PyUnicode_FromFormat("evsel(%s)", evsel__name(evsel)); - - return PyUnicode_FromFormat("evsel(%s/%s/)", evsel->pmu->name, evsel__name(evsel)); + return PyUnicode_FromFormat("evsel(%s/%s/)", evsel__pmu_name(evsel), evsel__name(evsel)); } static PyMethodDef pyrf_evsel__methods[] = {