File libperf-add-perf_cpu_map__dummy_new-function.patch of Package perf
185
1
From: Jiri Olsa <jolsa@kernel.org>
2
Date: Sun, 21 Jul 2019 13:24:16 +0200
3
Subject: libperf: Add perf_cpu_map__dummy_new() function
4
Git-commit: 397721e06e52d017cfdd403f63284ed0995d4caf
5
Patch-mainline: v5.4-rc1
6
References: jsc#SLE-13661
7
8
Move cpu_map__dummy_new() to libperf as perf_cpu_map__dummy_new() function.
9
10
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
11
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
12
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
13
Cc: Andi Kleen <ak@linux.intel.com>
14
Cc: Michael Petlan <mpetlan@redhat.com>
15
Cc: Namhyung Kim <namhyung@kernel.org>
16
Cc: Peter Zijlstra <peterz@infradead.org>
17
Link: http://lkml.kernel.org/r/20190721112506.12306-30-jolsa@kernel.org
18
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
19
Signed-off-by: Tony Jones <tonyj@suse.de>
20
---
21
tools/perf/lib/cpumap.c | 13 +++++++++++++
22
tools/perf/lib/include/perf/cpumap.h | 4 ++++
23
tools/perf/lib/libperf.map | 1 +
24
tools/perf/tests/sw-clock.c | 2 +-
25
tools/perf/tests/task-exit.c | 2 +-
26
tools/perf/util/cpumap.c | 15 +--------------
27
tools/perf/util/cpumap.h | 2 +-
28
tools/perf/util/evlist.c | 2 +-
29
tools/perf/util/evsel.c | 2 +-
30
9 files changed, 24 insertions(+), 19 deletions(-)
31
32
diff --git a/tools/perf/lib/cpumap.c b/tools/perf/lib/cpumap.c
33
index 86a199c26f20..80d587ab95aa 100644
34
--- a/tools/perf/lib/cpumap.c
35
+++ b/tools/perf/lib/cpumap.c
36
37
#include <stdlib.h>
38
#include <linux/refcount.h>
39
#include <internal/cpumap.h>
40
+
41
+struct perf_cpu_map *perf_cpu_map__dummy_new(void)
42
+{
43
+ struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
44
+
45
+ if (cpus != NULL) {
46
+ cpus->nr = 1;
47
+ cpus->map[0] = -1;
48
+ refcount_set(&cpus->refcnt, 1);
49
+ }
50
+
51
+ return cpus;
52
+}
53
diff --git a/tools/perf/lib/include/perf/cpumap.h b/tools/perf/lib/include/perf/cpumap.h
54
index 8355d3ce7d0c..fa1e5aa9d662 100644
55
--- a/tools/perf/lib/include/perf/cpumap.h
56
+++ b/tools/perf/lib/include/perf/cpumap.h
57
58
#ifndef __LIBPERF_CPUMAP_H
59
#define __LIBPERF_CPUMAP_H
60
61
+#include <perf/core.h>
62
+
63
struct perf_cpu_map;
64
65
+LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void);
66
+
67
#endif /* __LIBPERF_CPUMAP_H */
68
diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map
69
index 3536242c545c..65201c6cbe7e 100644
70
--- a/tools/perf/lib/libperf.map
71
+++ b/tools/perf/lib/libperf.map
72
73
LIBPERF_0.0.1 {
74
global:
75
libperf_set_print;
76
+ perf_cpu_map__dummy_new;
77
local:
78
*;
79
};
80
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
81
index ba033a6e6c0f..c6d3f4488b73 100644
82
--- a/tools/perf/tests/sw-clock.c
83
+++ b/tools/perf/tests/sw-clock.c
84
85
}
86
evlist__add(evlist, evsel);
87
88
- cpus = cpu_map__dummy_new();
89
+ cpus = perf_cpu_map__dummy_new();
90
threads = thread_map__new_by_tid(getpid());
91
if (!cpus || !threads) {
92
err = -ENOMEM;
93
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
94
index d17effdd55c8..c094fb8cc877 100644
95
--- a/tools/perf/tests/task-exit.c
96
+++ b/tools/perf/tests/task-exit.c
97
98
* perf_evlist__prepare_workload we'll fill in the only thread
99
* we're monitoring, the one forked there.
100
*/
101
- cpus = cpu_map__dummy_new();
102
+ cpus = perf_cpu_map__dummy_new();
103
threads = thread_map__new_by_tid(-1);
104
if (!cpus || !threads) {
105
err = -ENOMEM;
106
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
107
index 5eb4e1fbb877..acda9bfb4002 100644
108
--- a/tools/perf/util/cpumap.c
109
+++ b/tools/perf/util/cpumap.c
110
111
else if (*cpu_list != '\0')
112
cpus = cpu_map__default_new();
113
else
114
- cpus = cpu_map__dummy_new();
115
+ cpus = perf_cpu_map__dummy_new();
116
invalid:
117
free(tmp_cpus);
118
out:
119
120
#undef BUFSIZE
121
}
122
123
-struct perf_cpu_map *cpu_map__dummy_new(void)
124
-{
125
- struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
126
-
127
- if (cpus != NULL) {
128
- cpus->nr = 1;
129
- cpus->map[0] = -1;
130
- refcount_set(&cpus->refcnt, 1);
131
- }
132
-
133
- return cpus;
134
-}
135
-
136
struct perf_cpu_map *cpu_map__empty_new(int nr)
137
{
138
struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);
139
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
140
index c2ba9ae195f7..0ce3f6bd9449 100644
141
--- a/tools/perf/util/cpumap.h
142
+++ b/tools/perf/util/cpumap.h
143
144
#include <stdbool.h>
145
#include <linux/refcount.h>
146
#include <internal/cpumap.h>
147
+#include <perf/cpumap.h>
148
149
#include "perf.h"
150
#include "util/debug.h"
151
152
struct perf_cpu_map *cpu_map__new(const char *cpu_list);
153
struct perf_cpu_map *cpu_map__empty_new(int nr);
154
-struct perf_cpu_map *cpu_map__dummy_new(void);
155
struct perf_cpu_map *cpu_map__new_data(struct cpu_map_data *data);
156
struct perf_cpu_map *cpu_map__read(FILE *file);
157
size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
158
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
159
index 1bedec28e58f..461c1e68e9e7 100644
160
--- a/tools/perf/util/evlist.c
161
+++ b/tools/perf/util/evlist.c
162
163
return -1;
164
165
if (target__uses_dummy_map(target))
166
- cpus = cpu_map__dummy_new();
167
+ cpus = perf_cpu_map__dummy_new();
168
else
169
cpus = cpu_map__new(target->cpu_list);
170
171
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
172
index 5aeb7260c8e1..a389752840a9 100644
173
--- a/tools/perf/util/evsel.c
174
+++ b/tools/perf/util/evsel.c
175
176
static struct perf_cpu_map *empty_cpu_map;
177
178
if (empty_cpu_map == NULL) {
179
- empty_cpu_map = cpu_map__dummy_new();
180
+ empty_cpu_map = perf_cpu_map__dummy_new();
181
if (empty_cpu_map == NULL)
182
return -ENOMEM;
183
}
184
185