diff options
author | Ian Rogers <irogers@google.com> | 2024-12-05 20:40:33 -0800 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-12-09 17:52:41 -0300 |
commit | 9d9a83c51ae0167fcd923ebb48fd7ec4c23b10cb (patch) | |
tree | 4db05596b2c609cf247f5c72228916501c67ea7a /tools/lib/perf | |
parent | 4b8a7c0327e5657260c089df89632cdfaa53ecd1 (diff) |
libperf cpumap: Remove use of perf_cpu_map__read()
Remove use of a FILE and switch to reading a string that is then
passed to perf_cpu_map__new().
Being able to remove perf_cpu_map__read() avoids duplicated parsing
logic.
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ben Gainey <ben.gainey@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kyle Meyer <kyle.meyer@hpe.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20241206044035.1062032-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/perf')
-rw-r--r-- | tools/lib/perf/cpumap.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c index f7bde19558e2..a0c10ed9914e 100644 --- a/tools/lib/perf/cpumap.c +++ b/tools/lib/perf/cpumap.c @@ -11,6 +11,7 @@ #include <ctype.h> #include <limits.h> #include "internal.h" +#include <api/fs/fs.h> #define MAX_NR_CPUS 4096 @@ -103,12 +104,12 @@ static struct perf_cpu_map *cpu_map__new_sysconf(void) static struct perf_cpu_map *cpu_map__new_sysfs_online(void) { struct perf_cpu_map *cpus = NULL; - FILE *onlnf; + char *buf = NULL; + size_t buf_len; - onlnf = fopen("/sys/devices/system/cpu/online", "r"); - if (onlnf) { - cpus = perf_cpu_map__read(onlnf); - fclose(onlnf); + if (sysfs__read_str("devices/system/cpu/online", &buf, &buf_len) >= 0) { + cpus = perf_cpu_map__new(buf); + free(buf); } return cpus; } |