Skip to content

Commit 397721e

Browse files
olsajiriacmel
authored andcommitted
libperf: Add perf_cpu_map__dummy_new() function
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>
1 parent 959b83c commit 397721e

9 files changed

Lines changed: 24 additions & 19 deletions

File tree

‎tools/perf/lib/cpumap.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,16 @@
33
#include <stdlib.h>
44
#include <linux/refcount.h>
55
#include <internal/cpumap.h>
6+
7+
struct perf_cpu_map *perf_cpu_map__dummy_new(void)
8+
{
9+
struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
10+
11+
if (cpus != NULL) {
12+
cpus->nr = 1;
13+
cpus->map[0] = -1;
14+
refcount_set(&cpus->refcnt, 1);
15+
}
16+
17+
return cpus;
18+
}

‎tools/perf/lib/include/perf/cpumap.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#ifndef __LIBPERF_CPUMAP_H
33
#define __LIBPERF_CPUMAP_H
44

5+
#include <perf/core.h>
6+
57
struct perf_cpu_map;
68

9+
LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void);
10+
711
#endif /* __LIBPERF_CPUMAP_H */

‎tools/perf/lib/libperf.map‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LIBPERF_0.0.1 {
22
global:
33
libperf_set_print;
4+
perf_cpu_map__dummy_new;
45
local:
56
*;
67
};

‎tools/perf/tests/sw-clock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
5656
}
5757
evlist__add(evlist, evsel);
5858

59-
cpus = cpu_map__dummy_new();
59+
cpus = perf_cpu_map__dummy_new();
6060
threads = thread_map__new_by_tid(getpid());
6161
if (!cpus || !threads) {
6262
err = -ENOMEM;

‎tools/perf/tests/task-exit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
6363
* perf_evlist__prepare_workload we'll fill in the only thread
6464
* we're monitoring, the one forked there.
6565
*/
66-
cpus = cpu_map__dummy_new();
66+
cpus = perf_cpu_map__dummy_new();
6767
threads = thread_map__new_by_tid(-1);
6868
if (!cpus || !threads) {
6969
err = -ENOMEM;

‎tools/perf/util/cpumap.c‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ struct perf_cpu_map *cpu_map__new(const char *cpu_list)
189189
else if (*cpu_list != '\0')
190190
cpus = cpu_map__default_new();
191191
else
192-
cpus = cpu_map__dummy_new();
192+
cpus = perf_cpu_map__dummy_new();
193193
invalid:
194194
free(tmp_cpus);
195195
out:
@@ -256,19 +256,6 @@ size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp)
256256
#undef BUFSIZE
257257
}
258258

259-
struct perf_cpu_map *cpu_map__dummy_new(void)
260-
{
261-
struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
262-
263-
if (cpus != NULL) {
264-
cpus->nr = 1;
265-
cpus->map[0] = -1;
266-
refcount_set(&cpus->refcnt, 1);
267-
}
268-
269-
return cpus;
270-
}
271-
272259
struct perf_cpu_map *cpu_map__empty_new(int nr)
273260
{
274261
struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);

‎tools/perf/util/cpumap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
#include <stdbool.h>
77
#include <linux/refcount.h>
88
#include <internal/cpumap.h>
9+
#include <perf/cpumap.h>
910

1011
#include "perf.h"
1112
#include "util/debug.h"
1213

1314
struct perf_cpu_map *cpu_map__new(const char *cpu_list);
1415
struct perf_cpu_map *cpu_map__empty_new(int nr);
15-
struct perf_cpu_map *cpu_map__dummy_new(void);
1616
struct perf_cpu_map *cpu_map__new_data(struct cpu_map_data *data);
1717
struct perf_cpu_map *cpu_map__read(FILE *file);
1818
size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);

‎tools/perf/util/evlist.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
10861086
return -1;
10871087

10881088
if (target__uses_dummy_map(target))
1089-
cpus = cpu_map__dummy_new();
1089+
cpus = perf_cpu_map__dummy_new();
10901090
else
10911091
cpus = cpu_map__new(target->cpu_list);
10921092

‎tools/perf/util/evsel.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
18401840
static struct perf_cpu_map *empty_cpu_map;
18411841

18421842
if (empty_cpu_map == NULL) {
1843-
empty_cpu_map = cpu_map__dummy_new();
1843+
empty_cpu_map = perf_cpu_map__dummy_new();
18441844
if (empty_cpu_map == NULL)
18451845
return -ENOMEM;
18461846
}

0 commit comments

Comments
 (0)