summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2023-03-31 13:29:47 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-04 13:23:59 -0300
commit463786658d234df43ad1d9dfcf8aba25176d071c (patch)
tree0fc14df2c4211aa9364f8f40758bdb0bc333ae33
parentb39094d37d0c1f6399a1a1a24453ff48b4a0c7a6 (diff)
perf pmu: Use relative path in setup_pmu_alias_list()
Likewise, x86 needs to traverse the PMU list to build alias. Let's use the new helpers to use relative paths. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Ian Rogers <irogers@google.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>
-rw-r--r--tools/perf/arch/x86/util/pmu.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/perf/arch/x86/util/pmu.c b/tools/perf/arch/x86/util/pmu.c
index f73b80dcd8bd..3c0de3370d7e 100644
--- a/tools/perf/arch/x86/util/pmu.c
+++ b/tools/perf/arch/x86/util/pmu.c
@@ -71,7 +71,7 @@ out_delete:
static int setup_pmu_alias_list(void)
{
- char path[PATH_MAX];
+ int fd, dirfd;
DIR *dir;
struct dirent *dent;
struct pmu_alias *pmu_alias;
@@ -79,10 +79,11 @@ static int setup_pmu_alias_list(void)
FILE *file;
int ret = -ENOMEM;
- if (!perf_pmu__event_source_devices_scnprintf(path, sizeof(path)))
+ dirfd = perf_pmu__event_source_devices_fd();
+ if (dirfd < 0)
return -1;
- dir = opendir(path);
+ dir = fdopendir(dirfd);
if (!dir)
return -errno;
@@ -91,11 +92,11 @@ static int setup_pmu_alias_list(void)
!strcmp(dent->d_name, ".."))
continue;
- perf_pmu__pathname_scnprintf(path, sizeof(path), dent->d_name, "alias");
- if (!file_available(path))
+ fd = perf_pmu__pathname_fd(dirfd, dent->d_name, "alias", O_RDONLY);
+ if (fd < 0)
continue;
- file = fopen(path, "r");
+ file = fdopen(fd, "r");
if (!file)
continue;