Skip to content

Commit b260d25

Browse files
committed
libperf cpumap: Remove perf_cpu_map__read()
JIRA: https://issues.redhat.com/browse/RHEL-73893 upstream ======== commit e9ca57d Author: Ian Rogers <irogers@google.com> Date: Thu Dec 5 20:40:34 2024 -0800 description =========== 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> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent d22620c commit b260d25

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
@@ -161,62 +161,6 @@ static struct perf_cpu_map *cpu_map__trim_new(int nr_cpus, const struct perf_cpu
161161
return cpus;
162162
}
163163

164-
struct perf_cpu_map *perf_cpu_map__read(FILE *file)
165-
{
166-
struct perf_cpu_map *cpus = NULL;
167-
int nr_cpus = 0;
168-
struct perf_cpu *tmp_cpus = NULL, *tmp;
169-
int max_entries = 0;
170-
int n, cpu, prev;
171-
char sep;
172-
173-
sep = 0;
174-
prev = -1;
175-
for (;;) {
176-
n = fscanf(file, "%u%c", &cpu, &sep);
177-
if (n <= 0)
178-
break;
179-
if (prev >= 0) {
180-
int new_max = nr_cpus + cpu - prev - 1;
181-
182-
WARN_ONCE(new_max >= MAX_NR_CPUS, "Perf can support %d CPUs. "
183-
"Consider raising MAX_NR_CPUS\n", MAX_NR_CPUS);
184-
185-
if (new_max >= max_entries) {
186-
max_entries = new_max + MAX_NR_CPUS / 2;
187-
tmp = realloc(tmp_cpus, max_entries * sizeof(struct perf_cpu));
188-
if (tmp == NULL)
189-
goto out_free_tmp;
190-
tmp_cpus = tmp;
191-
}
192-
193-
while (++prev < cpu)
194-
tmp_cpus[nr_cpus++].cpu = prev;
195-
}
196-
if (nr_cpus == max_entries) {
197-
max_entries += MAX_NR_CPUS;
198-
tmp = realloc(tmp_cpus, max_entries * sizeof(struct perf_cpu));
199-
if (tmp == NULL)
200-
goto out_free_tmp;
201-
tmp_cpus = tmp;
202-
}
203-
204-
tmp_cpus[nr_cpus++].cpu = cpu;
205-
if (n == 2 && sep == '-')
206-
prev = cpu;
207-
else
208-
prev = -1;
209-
if (n == 1 || sep == '\n')
210-
break;
211-
}
212-
213-
if (nr_cpus > 0)
214-
cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
215-
out_free_tmp:
216-
free(tmp_cpus);
217-
return cpus;
218-
}
219-
220164
struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
221165
{
222166
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 struct perf_cpu_map *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)