]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf evlist: Avoid scanning all PMUs for evlist__new_default
authorIan Rogers <irogers@google.com>
Sun, 5 Oct 2025 18:24:22 +0000 (11:24 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 15 Oct 2025 14:59:11 +0000 (23:59 +0900)
Rather than wildcard matching the cycles event specify only the core
PMUs. This avoids potentially loading unnecessary uncore PMUs.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/evlist.c

index 80d8387e6b97bcdf1af6146b21c048467d0f7a9a..e8217efdda5323c6eb8f3f5a8c27053c5a5a5f51 100644 (file)
@@ -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) {