diff options
author | Namhyung Kim <namhyung@kernel.org> | 2023-03-31 23:29:48 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-04 19:23:59 +0300 |
commit | 3a69672e881afc1dcc8ed60272197af8958b5404 (patch) | |
tree | 69762f6448fe77e63687ecffd1bf11f8cdc9dee6 /tools/perf/util/pmu.h | |
parent | 463786658d234df43ad1d9dfcf8aba25176d071c (diff) | |
download | linux-3a69672e881afc1dcc8ed60272197af8958b5404.tar.xz |
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>
Diffstat (limited to 'tools/perf/util/pmu.h')
-rw-r--r-- | tools/perf/util/pmu.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 751c7016e7b6..32c3a75bca0e 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -220,7 +220,12 @@ bool is_pmu_core(const char *name); void print_pmu_events(const struct print_callbacks *print_cb, void *print_state); bool pmu_have_event(const char *pname, const char *name); +FILE *perf_pmu__open_file(struct perf_pmu *pmu, const char *name); +FILE *perf_pmu__open_file_at(struct perf_pmu *pmu, int dirfd, const char *name); + int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, ...) __scanf(3, 4); +int perf_pmu__scan_file_at(struct perf_pmu *pmu, int dirfd, const char *name, + const char *fmt, ...) __scanf(4, 5); bool perf_pmu__file_exists(struct perf_pmu *pmu, const char *name); @@ -259,7 +264,6 @@ int perf_pmu__pathname_scnprintf(char *buf, size_t size, const char *pmu_name, const char *filename); int perf_pmu__event_source_devices_fd(void); int perf_pmu__pathname_fd(int dirfd, const char *pmu_name, const char *filename, int flags); -FILE *perf_pmu__open_file(struct perf_pmu *pmu, const char *name); void perf_pmu__destroy(void); |