[PATCH v2 1/5] perf evsel: Reduce scanning core PMUs in is_hybrid

Ian Rogers
2025-01-23T07:47:05Z

evsel__is_hybrid returns true if there are multiple core PMUs and the
evsel is for a core PMU. Determining the number of core PMUs can
require loading/scanning PMUs. There's no point doing the scanning if
evsel for the is_hybrid test isn't core so reorder the tests to reduce
PMU scanning.

Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/evsel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bc144388f892..ae20691bbfae 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -3856,10 +3856,10 @@ void evsel__zero_per_pkg(struct evsel *evsel)
*/
bool evsel__is_hybrid(const struct evsel *evsel)
{
- if (perf_pmus__num_core_pmus() == 1)
+ if (!evsel->core.is_pmu_core)
return false;

- return evsel->core.is_pmu_core;
+ return perf_pmus__num_core_pmus() > 1;
}

struct evsel *evsel__leader(const struct evsel *evsel)
--
2.48.1.262.g85cc9f2d1e-goog