perf pmu: Add perf_pmu__{open,scan}_file_at()
authorNamhyung Kim <namhyung@kernel.org>
Fri, 31 Mar 2023 20:29:48 +0000 (13:29 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Apr 2023 16:23:59 +0000 (13:23 -0300)
commit3a69672e881afc1dcc8ed60272197af8958b5404
tree69762f6448fe77e63687ecffd1bf11f8cdc9dee6
parent463786658d234df43ad1d9dfcf8aba25176d071c
perf pmu: Add perf_pmu__{open,scan}_file_at()

These two helpers will also use openat() to reduce the overhead with
relative pathnames.  Convert other functions in pmu_lookup() to use
the new helpers.

Committer testing:

Before:

  ⬢[acme@toolbox perf-tools-next]$ perf bench internals pmu-scan
  # Running 'internals/pmu-scan' benchmark:
  Computing performance of sysfs PMU event scan for 100 times
    Average PMU scanning took: 2729.040 usec (+- 7.117 usec)
  ⬢[acme@toolbox perf-tools-next]$

After:

  ⬢[acme@toolbox perf-tools-next]$ perf bench internals pmu-scan
  # Running 'internals/pmu-scan' benchmark:
  Computing performance of sysfs PMU event scan for 100 times
    Average PMU scanning took: 2419.870 usec (+- 9.057 usec)
  ⬢[acme@toolbox perf-tools-next]$

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230331202949.810326-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmu.c
tools/perf/util/pmu.h