Skip to contentSkip to conversation

perf pfm: Don't force loading of all PMUs

PATCH Applied Ian Rogers 2 participants 3 messages Jul 22, 2025 – Jul 25, 2025 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf pfm: Don't force loading of all PMUs

Force loading all PMUs adds significant cost because DRM and other PMUs are loaded, it should also not be required if the pmus__ functions are used.

Tested by run perf test, in particular the pfm related tests. Also perf list is identical before and after.

---
 tools/perf/util/pfm.c | 4 ----
 1 file changed, 4 deletions(-)
tools/perf/util/pfm.c +0 -4
index 0dacc133ed39..e89395814e88 100644
@@ -47,10 +47,6 @@ int parse_libpfm_events_option(const struct option *opt, const char *str,
 	p_orig = p = strdup(str);
 	if (!p)
 		return -1;
-	/*
-	 * force loading of the PMU list
-	 */
-	perf_pmus__scan(NULL);
 
 	for (q = p; strsep(&p, ",{}"); q = p) {
 		sep = p ? str + (p - p_orig - 1) : "";
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
maintainer Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ian Rogers

Force loading all PMUs adds significant cost because DRM and other PMUs are loaded, it should also not be required if the pmus__ functions are used.

Tested by run perf test, in particular the pfm related tests. Also perf list is identical before and after.

I've also checked it with timing. I'll add this to the commit message.

Before:

  $ time ./perf test pfm
   54: Test libpfm4 support                                            :
   54.1: test of individual --pfm-events                               : Ok
   54.2: test groups of --pfm-events                                   : Ok
  103: perf all libpfm4 events test                                    : Ok

real 0m8.933s
user 0m1.824s
sys 0m7.122s

After:

  $ time ./perf test pfm
   54: Test libpfm4 support                                            :
   54.1: test of individual --pfm-events                               : Ok
   54.2: test groups of --pfm-events                                   : Ok
  103: perf all libpfm4 events test                                    : Ok

real 0m5.259s
user 0m1.793s
sys 0m3.570s

Thanks,
Namhyung

Quoted 24 lines
---
 tools/perf/util/pfm.c | 4 ----
 1 file changed, 4 deletions(-)
tools/perf/util/pfm.c +0 -4
index 0dacc133ed39..e89395814e88 100644
@@ -47,10 +47,6 @@ int parse_libpfm_events_option(const struct option *opt, const char *str,
 	p_orig = p = strdup(str);
 	if (!p)
 		return -1;
-	/*
-	 * force loading of the PMU list
-	 */
-	perf_pmus__scan(NULL);
 
 	for (q = p; strsep(&p, ",{}"); q = p) {
 		sep = p ? str + (p - p_orig - 1) : "";
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
maintainer Applied
#2 lore raw
In reply to Ian Rogers
Quoted 8 lines · Ian Rogers

Force loading all PMUs adds significant cost because DRM and other PMUs are loaded, it should also not be required if the pmus__ functions are used.

Tested by run perf test, in particular the pfm related tests. Also perf list is identical before and after.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung