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 <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Ian Rogers 2025-10-05 11:24:22 -07:00 committed by Namhyung Kim
parent 468071acfc
commit 5bf6291113

View 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) {