OSDN Git Service

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 86a199c..80d587a 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 8355d3c..fa1e5aa 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 3536242..65201c6 100644 (file)
@@ -1,6 +1,7 @@
 LIBPERF_0.0.1 {
        global:
                libperf_set_print;
+               perf_cpu_map__dummy_new;
        local:
                *;
 };
index ba033a6..c6d3f44 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 d17effd..c094fb8 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 5eb4e1f..acda9bf 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 c2ba9ae..0ce3f6b 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 1bedec2..461c1e6 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 5aeb726..a389752 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;
                }