From: Ian Rogers Date: Sun, 5 Oct 2025 18:24:22 +0000 (-0700) Subject: perf evlist: Avoid scanning all PMUs for evlist__new_default X-Git-Tag: v6.19-rc1~61^2~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bf6291113d2aaa559455a04ecc2c5e6396d05a0;p=thirdparty%2Fkernel%2Flinux.git perf evlist: Avoid scanning all PMUs for evlist__new_default Rather than wildcard matching the cycles event specify only the core PMUs. This avoids potentially loading unnecessary uncore PMUs. Signed-off-by: Ian Rogers Tested-by: James Clark Signed-off-by: Namhyung Kim --- diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 80d8387e6b97b..e8217efdda532 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -101,16 +101,24 @@ struct evlist *evlist__new_default(void) { struct evlist *evlist = evlist__new(); bool can_profile_kernel; - int err; + struct perf_pmu *pmu = NULL; if (!evlist) return NULL; can_profile_kernel = perf_event_paranoid_check(1); - err = parse_event(evlist, can_profile_kernel ? "cycles:P" : "cycles:Pu"); - if (err) { - evlist__delete(evlist); - return NULL; + + while ((pmu = perf_pmus__scan_core(pmu)) != NULL) { + char buf[256]; + int err; + + snprintf(buf, sizeof(buf), "%s/cycles/%s", pmu->name, + can_profile_kernel ? "P" : "Pu"); + err = parse_event(evlist, buf); + if (err) { + evlist__delete(evlist); + return NULL; + } } if (evlist->core.nr_entries > 1) {