Skip to content

Commit e9ca57d

Browse files
captain5050acmel
authored andcommitted
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>
1 parent 9d9a83c commit e9ca57d

File tree

4 files changed

+0
-60
lines changed

4 files changed

+0
-60
lines changed

tools/lib/perf/Documentation/libperf.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ SYNOPSIS
3939

4040
struct perf_cpu_map *perf_cpu_map__new_any_cpu(void);
4141
struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
42-
struct perf_cpu_map *perf_cpu_map__read(FILE *file);
4342
struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
4443
struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig,
4544
struct perf_cpu_map *other);

tools/lib/perf/cpumap.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -162,62 +162,6 @@ static struct perf_cpu_map *cpu_map__trim_new(int nr_cpus, const struct perf_cpu
162162
return cpus;
163163
}
164164

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-
221165
struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
222166
{
223167
struct perf_cpu_map *cpus = NULL;

tools/lib/perf/include/perf/cpumap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define __LIBPERF_CPUMAP_H
44

55
#include <perf/core.h>
6-
#include <stdio.h>
76
#include <stdbool.h>
87

98
/** A wrapper around a CPU to avoid confusion with the perf_cpu_map's map's indices. */
@@ -37,7 +36,6 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__new_online_cpus(void);
3736
* perf_cpu_map__new_online_cpus is returned.
3837
*/
3938
LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
40-
LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file);
4139
LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
4240
LIBPERF_API int perf_cpu_map__merge(struct perf_cpu_map **orig,
4341
struct perf_cpu_map *other);

tools/lib/perf/libperf.map

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LIBPERF_0.0.1 {
66
perf_cpu_map__get;
77
perf_cpu_map__put;
88
perf_cpu_map__new;
9-
perf_cpu_map__read;
109
perf_cpu_map__nr;
1110
perf_cpu_map__cpu;
1211
perf_cpu_map__has_any_cpu_or_is_empty;

0 commit comments

Comments
 (0)