libperf cpumap: Remove perf_cpu_map__read()
authorIan Rogers <irogers@google.com>
Fri, 6 Dec 2024 04:40:34 +0000 (20:40 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 9 Dec 2024 20:52:41 +0000 (17:52 -0300)
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>
tools/lib/perf/Documentation/libperf.txt
tools/lib/perf/cpumap.c
tools/lib/perf/include/perf/cpumap.h
tools/lib/perf/libperf.map

index fcfb9499ef9cdfbdfa7903c13f32a060b49e19c2..59aabdd3cabff19c9a4835d9d20a74c6087d9a06 100644 (file)
@@ -39,7 +39,6 @@ SYNOPSIS
 
   struct perf_cpu_map *perf_cpu_map__new_any_cpu(void);
   struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
-  struct perf_cpu_map *perf_cpu_map__read(FILE *file);
   struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
   struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig,
                                            struct perf_cpu_map *other);
index a0c10ed9914ed3d6b4c87a9b35b07ea1c215ef99..36f6579b3006348b7a7aa273883686f82106a607 100644 (file)
@@ -162,62 +162,6 @@ static struct perf_cpu_map *cpu_map__trim_new(int nr_cpus, const struct perf_cpu
        return cpus;
 }
 
-struct perf_cpu_map *perf_cpu_map__read(FILE *file)
-{
-       struct perf_cpu_map *cpus = NULL;
-       int nr_cpus = 0;
-       struct perf_cpu *tmp_cpus = NULL, *tmp;
-       int max_entries = 0;
-       int n, cpu, prev;
-       char sep;
-
-       sep = 0;
-       prev = -1;
-       for (;;) {
-               n = fscanf(file, "%u%c", &cpu, &sep);
-               if (n <= 0)
-                       break;
-               if (prev >= 0) {
-                       int new_max = nr_cpus + cpu - prev - 1;
-
-                       WARN_ONCE(new_max >= MAX_NR_CPUS, "Perf can support %d CPUs. "
-                                                         "Consider raising MAX_NR_CPUS\n", MAX_NR_CPUS);
-
-                       if (new_max >= max_entries) {
-                               max_entries = new_max + MAX_NR_CPUS / 2;
-                               tmp = realloc(tmp_cpus, max_entries * sizeof(struct perf_cpu));
-                               if (tmp == NULL)
-                                       goto out_free_tmp;
-                               tmp_cpus = tmp;
-                       }
-
-                       while (++prev < cpu)
-                               tmp_cpus[nr_cpus++].cpu = prev;
-               }
-               if (nr_cpus == max_entries) {
-                       max_entries += MAX_NR_CPUS;
-                       tmp = realloc(tmp_cpus, max_entries * sizeof(struct perf_cpu));
-                       if (tmp == NULL)
-                               goto out_free_tmp;
-                       tmp_cpus = tmp;
-               }
-
-               tmp_cpus[nr_cpus++].cpu = cpu;
-               if (n == 2 && sep == '-')
-                       prev = cpu;
-               else
-                       prev = -1;
-               if (n == 1 || sep == '\n')
-                       break;
-       }
-
-       if (nr_cpus > 0)
-               cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
-out_free_tmp:
-       free(tmp_cpus);
-       return cpus;
-}
-
 struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
 {
        struct perf_cpu_map *cpus = NULL;
index c83bfb2c36ff9bd0950ff9626368f1024ef82b44..188a667babc60f41029747e20285beb1152e2140 100644 (file)
@@ -3,7 +3,6 @@
 #define __LIBPERF_CPUMAP_H
 
 #include <perf/core.h>
-#include <stdio.h>
 #include <stdbool.h>
 
 /** 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);
  *                     perf_cpu_map__new_online_cpus is returned.
  */
 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
-LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file);
 LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
 LIBPERF_API int perf_cpu_map__merge(struct perf_cpu_map **orig,
                                    struct perf_cpu_map *other);
index 2aa79b696032688e89e8f21264a55a0e9e449b51..fdd8304fe9d05862376c122d68777a6bf6a03d80 100644 (file)
@@ -6,7 +6,6 @@ LIBPERF_0.0.1 {
                perf_cpu_map__get;
                perf_cpu_map__put;
                perf_cpu_map__new;
-               perf_cpu_map__read;
                perf_cpu_map__nr;
                perf_cpu_map__cpu;
                perf_cpu_map__has_any_cpu_or_is_empty;