libperf: Add perf_cpu_map__dummy_new() function
authorJiri Olsa <jolsa@kernel.org>
Sun, 21 Jul 2019 11:24:16 +0000 (13:24 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Jul 2019 21:34:44 +0000 (18:34 -0300)
Move cpu_map__dummy_new() to libperf as perf_cpu_map__dummy_new() function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-30-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/lib/cpumap.c
tools/perf/lib/include/perf/cpumap.h
tools/perf/lib/libperf.map
tools/perf/tests/sw-clock.c
tools/perf/tests/task-exit.c
tools/perf/util/cpumap.c
tools/perf/util/cpumap.h
tools/perf/util/evlist.c
tools/perf/util/evsel.c

index 86a199c26f202317d916b1ecdf6197215c22462e..80d587ab95aac4a3cd7fb9f6f3cd8ad297a9488e 100644 (file)
@@ -3,3 +3,16 @@
 #include <stdlib.h>
 #include <linux/refcount.h>
 #include <internal/cpumap.h>
+
+struct perf_cpu_map *perf_cpu_map__dummy_new(void)
+{
+       struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
+
+       if (cpus != NULL) {
+               cpus->nr = 1;
+               cpus->map[0] = -1;
+               refcount_set(&cpus->refcnt, 1);
+       }
+
+       return cpus;
+}
index 8355d3ce7d0cec272b05a32e97fa2d699ac998ff..fa1e5aa9d6623fade3a333cac4e1db3f77286631 100644 (file)
@@ -2,6 +2,10 @@
 #ifndef __LIBPERF_CPUMAP_H
 #define __LIBPERF_CPUMAP_H
 
+#include <perf/core.h>
+
 struct perf_cpu_map;
 
+LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void);
+
 #endif /* __LIBPERF_CPUMAP_H */
index 3536242c545c76f9e9eee6bf81b2f91afffda738..65201c6cbe7e9a648eb4db50a8c57126e1740217 100644 (file)
@@ -1,6 +1,7 @@
 LIBPERF_0.0.1 {
        global:
                libperf_set_print;
+               perf_cpu_map__dummy_new;
        local:
                *;
 };
index ba033a6e6c0fad80f7abadc14b83b4cb210552ba..c6d3f4488b735868ce40b6eedca0555d78485a74 100644 (file)
@@ -56,7 +56,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
        }
        evlist__add(evlist, evsel);
 
-       cpus = cpu_map__dummy_new();
+       cpus = perf_cpu_map__dummy_new();
        threads = thread_map__new_by_tid(getpid());
        if (!cpus || !threads) {
                err = -ENOMEM;
index d17effdd55c8b9c226171fb6265e9eb988760798..c094fb8cc8776d95a42ff8e1cf0b93d9ee638b10 100644 (file)
@@ -63,7 +63,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
         * perf_evlist__prepare_workload we'll fill in the only thread
         * we're monitoring, the one forked there.
         */
-       cpus = cpu_map__dummy_new();
+       cpus = perf_cpu_map__dummy_new();
        threads = thread_map__new_by_tid(-1);
        if (!cpus || !threads) {
                err = -ENOMEM;
index 5eb4e1fbb877e5c1c1d275d9ce506c018e93177e..acda9bfb40020d0edccfe684e647f2c4d787b87a 100644 (file)
@@ -189,7 +189,7 @@ struct perf_cpu_map *cpu_map__new(const char *cpu_list)
        else if (*cpu_list != '\0')
                cpus = cpu_map__default_new();
        else
-               cpus = cpu_map__dummy_new();
+               cpus = perf_cpu_map__dummy_new();
 invalid:
        free(tmp_cpus);
 out:
@@ -256,19 +256,6 @@ size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp)
 #undef BUFSIZE
 }
 
-struct perf_cpu_map *cpu_map__dummy_new(void)
-{
-       struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
-
-       if (cpus != NULL) {
-               cpus->nr = 1;
-               cpus->map[0] = -1;
-               refcount_set(&cpus->refcnt, 1);
-       }
-
-       return cpus;
-}
-
 struct perf_cpu_map *cpu_map__empty_new(int nr)
 {
        struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);
index c2ba9ae195f7d973c56f6ca75e2cbcc6fe2e239e..0ce3f6bd944900f3517a1a6398153e2ca44a0e10 100644 (file)
@@ -6,13 +6,13 @@
 #include <stdbool.h>
 #include <linux/refcount.h>
 #include <internal/cpumap.h>
+#include <perf/cpumap.h>
 
 #include "perf.h"
 #include "util/debug.h"
 
 struct perf_cpu_map *cpu_map__new(const char *cpu_list);
 struct perf_cpu_map *cpu_map__empty_new(int nr);
-struct perf_cpu_map *cpu_map__dummy_new(void);
 struct perf_cpu_map *cpu_map__new_data(struct cpu_map_data *data);
 struct perf_cpu_map *cpu_map__read(FILE *file);
 size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
index 1bedec28e58f753a1ee30e13d2e520f7f0522892..461c1e68e9e7d92d5700776e0a3c8c8ae542bb5b 100644 (file)
@@ -1086,7 +1086,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
                return -1;
 
        if (target__uses_dummy_map(target))
-               cpus = cpu_map__dummy_new();
+               cpus = perf_cpu_map__dummy_new();
        else
                cpus = cpu_map__new(target->cpu_list);
 
index 5aeb7260c8e1fd0c0f0ad0ff1783188ef42ed3dc..a389752840a9bc76a5e35041814233c8e0e6af32 100644 (file)
@@ -1840,7 +1840,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
                static struct perf_cpu_map *empty_cpu_map;
 
                if (empty_cpu_map == NULL) {
-                       empty_cpu_map = cpu_map__dummy_new();
+                       empty_cpu_map = perf_cpu_map__dummy_new();
                        if (empty_cpu_map == NULL)
                                return -ENOMEM;
                }