]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
libperf: Adopt perf_cpu_map__max() function
authorJiri Olsa <jolsa@kernel.org>
Mon, 2 Sep 2019 12:12:53 +0000 (14:12 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 10 Sep 2019 13:33:32 +0000 (14:33 +0100)
From 'perf stat', so that it can be used from multiple places.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20190902121255.536-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/lib/cpumap.c
tools/perf/lib/include/perf/cpumap.h
tools/perf/lib/libperf.map

index 7e17bf9f700ad44608ec5b45cec16bff5c4155a3..5bc0c570b7b60268bf190bb1739ffcf22f6c8411 100644 (file)
@@ -822,18 +822,6 @@ static int perf_stat__get_core(struct perf_stat_config *config __maybe_unused,
        return cpu_map__get_core(map, cpu, NULL);
 }
 
-static int cpu_map__get_max(struct perf_cpu_map *map)
-{
-       int i, max = -1;
-
-       for (i = 0; i < map->nr; i++) {
-               if (map->map[i] > max)
-                       max = map->map[i];
-       }
-
-       return max;
-}
-
 static int perf_stat__get_aggr(struct perf_stat_config *config,
                               aggr_get_id_t get_id, struct perf_cpu_map *map, int idx)
 {
@@ -928,7 +916,7 @@ static int perf_stat_init_aggr_mode(void)
         * taking the highest cpu number to be the size of
         * the aggregation translate cpumap.
         */
-       nr = cpu_map__get_max(evsel_list->core.cpus);
+       nr = perf_cpu_map__max(evsel_list->core.cpus);
        stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1);
        return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
 }
index 1f0e6f334237ac3243548f3504baf45b22788a3d..2ca1fafa620dfca8ee992b87eb35fe5c36220d0f 100644 (file)
@@ -260,3 +260,15 @@ int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu)
 
        return -1;
 }
+
+int perf_cpu_map__max(struct perf_cpu_map *map)
+{
+       int i, max = -1;
+
+       for (i = 0; i < map->nr; i++) {
+               if (map->map[i] > max)
+                       max = map->map[i];
+       }
+
+       return max;
+}
index 8aa995c59498956f4c5999dc1e7a5d203596cec5..ac9aa497f84ab3151799e1bc4689b5e0b0fd1dc4 100644 (file)
@@ -16,6 +16,7 @@ LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map);
 LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx);
 LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
 LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map);
+LIBPERF_API int perf_cpu_map__max(struct perf_cpu_map *map);
 
 #define perf_cpu_map__for_each_cpu(cpu, idx, cpus)             \
        for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx);   \
index dc4d66363bc4def6905225596d5054ab6c914cbb..cd0d17b996c8c203e0b657cb8df936d63f343a52 100644 (file)
@@ -9,6 +9,7 @@ LIBPERF_0.0.1 {
                perf_cpu_map__nr;
                perf_cpu_map__cpu;
                perf_cpu_map__empty;
+               perf_cpu_map__max;
                perf_thread_map__new_dummy;
                perf_thread_map__set_pid;
                perf_thread_map__comm;