Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libperf cpumap: Remove perf_cpu_map__read()

Function is no longer used and duplicates the parsing logic from
perf_cpu_map__new().

Remove to allow simplification.

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-8-irogers@google.com
[ Applied manually to cope with "libperf cpumap: Refactor perf_cpu_map__merge()" ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
e9ca57d7 9d9a83c5

-60
-1
tools/lib/perf/Documentation/libperf.txt
··· 39 39 40 40 struct perf_cpu_map *perf_cpu_map__new_any_cpu(void); 41 41 struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list); 42 - struct perf_cpu_map *perf_cpu_map__read(FILE *file); 43 42 struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); 44 43 struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig, 45 44 struct perf_cpu_map *other);
-56
tools/lib/perf/cpumap.c
··· 162 162 return cpus; 163 163 } 164 164 165 - struct perf_cpu_map *perf_cpu_map__read(FILE *file) 166 - { 167 - struct perf_cpu_map *cpus = NULL; 168 - int nr_cpus = 0; 169 - struct perf_cpu *tmp_cpus = NULL, *tmp; 170 - int max_entries = 0; 171 - int n, cpu, prev; 172 - char sep; 173 - 174 - sep = 0; 175 - prev = -1; 176 - for (;;) { 177 - n = fscanf(file, "%u%c", &cpu, &sep); 178 - if (n <= 0) 179 - break; 180 - if (prev >= 0) { 181 - int new_max = nr_cpus + cpu - prev - 1; 182 - 183 - WARN_ONCE(new_max >= MAX_NR_CPUS, "Perf can support %d CPUs. " 184 - "Consider raising MAX_NR_CPUS\n", MAX_NR_CPUS); 185 - 186 - if (new_max >= max_entries) { 187 - max_entries = new_max + MAX_NR_CPUS / 2; 188 - tmp = realloc(tmp_cpus, max_entries * sizeof(struct perf_cpu)); 189 - if (tmp == NULL) 190 - goto out_free_tmp; 191 - tmp_cpus = tmp; 192 - } 193 - 194 - while (++prev < cpu) 195 - tmp_cpus[nr_cpus++].cpu = prev; 196 - } 197 - if (nr_cpus == max_entries) { 198 - max_entries += MAX_NR_CPUS; 199 - tmp = realloc(tmp_cpus, max_entries * sizeof(struct perf_cpu)); 200 - if (tmp == NULL) 201 - goto out_free_tmp; 202 - tmp_cpus = tmp; 203 - } 204 - 205 - tmp_cpus[nr_cpus++].cpu = cpu; 206 - if (n == 2 && sep == '-') 207 - prev = cpu; 208 - else 209 - prev = -1; 210 - if (n == 1 || sep == '\n') 211 - break; 212 - } 213 - 214 - if (nr_cpus > 0) 215 - cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); 216 - out_free_tmp: 217 - free(tmp_cpus); 218 - return cpus; 219 - } 220 - 221 165 struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list) 222 166 { 223 167 struct perf_cpu_map *cpus = NULL;
-2
tools/lib/perf/include/perf/cpumap.h
··· 3 3 #define __LIBPERF_CPUMAP_H 4 4 5 5 #include <perf/core.h> 6 - #include <stdio.h> 7 6 #include <stdbool.h> 8 7 9 8 /** A wrapper around a CPU to avoid confusion with the perf_cpu_map's map's indices. */ ··· 36 37 * perf_cpu_map__new_online_cpus is returned. 37 38 */ 38 39 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list); 39 - LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file); 40 40 LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); 41 41 LIBPERF_API int perf_cpu_map__merge(struct perf_cpu_map **orig, 42 42 struct perf_cpu_map *other);
-1
tools/lib/perf/libperf.map
··· 6 6 perf_cpu_map__get; 7 7 perf_cpu_map__put; 8 8 perf_cpu_map__new; 9 - perf_cpu_map__read; 10 9 perf_cpu_map__nr; 11 10 perf_cpu_map__cpu; 12 11 perf_cpu_map__has_any_cpu_or_is_empty;