]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf evsel: Reduce scanning core PMUs in is_hybrid
authorIan Rogers <irogers@google.com>
Sat, 1 Feb 2025 07:43:16 +0000 (23:43 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 5 Feb 2025 05:28:25 +0000 (21:28 -0800)
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>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20250201074320.746259-2-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/evsel.c

index 026cf9a9893c3af8e673cf87c5f032173befb8c2..4009f7d584151279bf9c948fa73e276b20e7d0a1 100644 (file)
@@ -3866,10 +3866,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)