.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | | -#include "util.h" |
---|
3 | 2 | #include <api/fs/fs.h> |
---|
4 | | -#include "../perf.h" |
---|
5 | 3 | #include "cpumap.h" |
---|
| 4 | +#include "debug.h" |
---|
| 5 | +#include "event.h" |
---|
6 | 6 | #include <assert.h> |
---|
7 | 7 | #include <dirent.h> |
---|
8 | 8 | #include <stdio.h> |
---|
.. | .. |
---|
10 | 10 | #include <linux/bitmap.h> |
---|
11 | 11 | #include "asm/bug.h" |
---|
12 | 12 | |
---|
13 | | -#include "sane_ctype.h" |
---|
| 13 | +#include <linux/ctype.h> |
---|
| 14 | +#include <linux/zalloc.h> |
---|
14 | 15 | |
---|
15 | 16 | static int max_cpu_num; |
---|
16 | 17 | static int max_present_cpu_num; |
---|
17 | 18 | static int max_node_num; |
---|
18 | 19 | static int *cpunode_map; |
---|
19 | 20 | |
---|
20 | | -static struct cpu_map *cpu_map__default_new(void) |
---|
| 21 | +static struct perf_cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus) |
---|
21 | 22 | { |
---|
22 | | - struct cpu_map *cpus; |
---|
23 | | - int nr_cpus; |
---|
| 23 | + struct perf_cpu_map *map; |
---|
24 | 24 | |
---|
25 | | - nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
---|
26 | | - if (nr_cpus < 0) |
---|
27 | | - return NULL; |
---|
28 | | - |
---|
29 | | - cpus = malloc(sizeof(*cpus) + nr_cpus * sizeof(int)); |
---|
30 | | - if (cpus != NULL) { |
---|
31 | | - int i; |
---|
32 | | - for (i = 0; i < nr_cpus; ++i) |
---|
33 | | - cpus->map[i] = i; |
---|
34 | | - |
---|
35 | | - cpus->nr = nr_cpus; |
---|
36 | | - refcount_set(&cpus->refcnt, 1); |
---|
37 | | - } |
---|
38 | | - |
---|
39 | | - return cpus; |
---|
40 | | -} |
---|
41 | | - |
---|
42 | | -static struct cpu_map *cpu_map__trim_new(int nr_cpus, int *tmp_cpus) |
---|
43 | | -{ |
---|
44 | | - size_t payload_size = nr_cpus * sizeof(int); |
---|
45 | | - struct cpu_map *cpus = malloc(sizeof(*cpus) + payload_size); |
---|
46 | | - |
---|
47 | | - if (cpus != NULL) { |
---|
48 | | - cpus->nr = nr_cpus; |
---|
49 | | - memcpy(cpus->map, tmp_cpus, payload_size); |
---|
50 | | - refcount_set(&cpus->refcnt, 1); |
---|
51 | | - } |
---|
52 | | - |
---|
53 | | - return cpus; |
---|
54 | | -} |
---|
55 | | - |
---|
56 | | -struct cpu_map *cpu_map__read(FILE *file) |
---|
57 | | -{ |
---|
58 | | - struct cpu_map *cpus = NULL; |
---|
59 | | - int nr_cpus = 0; |
---|
60 | | - int *tmp_cpus = NULL, *tmp; |
---|
61 | | - int max_entries = 0; |
---|
62 | | - int n, cpu, prev; |
---|
63 | | - char sep; |
---|
64 | | - |
---|
65 | | - sep = 0; |
---|
66 | | - prev = -1; |
---|
67 | | - for (;;) { |
---|
68 | | - n = fscanf(file, "%u%c", &cpu, &sep); |
---|
69 | | - if (n <= 0) |
---|
70 | | - break; |
---|
71 | | - if (prev >= 0) { |
---|
72 | | - int new_max = nr_cpus + cpu - prev - 1; |
---|
73 | | - |
---|
74 | | - if (new_max >= max_entries) { |
---|
75 | | - max_entries = new_max + MAX_NR_CPUS / 2; |
---|
76 | | - tmp = realloc(tmp_cpus, max_entries * sizeof(int)); |
---|
77 | | - if (tmp == NULL) |
---|
78 | | - goto out_free_tmp; |
---|
79 | | - tmp_cpus = tmp; |
---|
80 | | - } |
---|
81 | | - |
---|
82 | | - while (++prev < cpu) |
---|
83 | | - tmp_cpus[nr_cpus++] = prev; |
---|
84 | | - } |
---|
85 | | - if (nr_cpus == max_entries) { |
---|
86 | | - max_entries += MAX_NR_CPUS; |
---|
87 | | - tmp = realloc(tmp_cpus, max_entries * sizeof(int)); |
---|
88 | | - if (tmp == NULL) |
---|
89 | | - goto out_free_tmp; |
---|
90 | | - tmp_cpus = tmp; |
---|
91 | | - } |
---|
92 | | - |
---|
93 | | - tmp_cpus[nr_cpus++] = cpu; |
---|
94 | | - if (n == 2 && sep == '-') |
---|
95 | | - prev = cpu; |
---|
96 | | - else |
---|
97 | | - prev = -1; |
---|
98 | | - if (n == 1 || sep == '\n') |
---|
99 | | - break; |
---|
100 | | - } |
---|
101 | | - |
---|
102 | | - if (nr_cpus > 0) |
---|
103 | | - cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); |
---|
104 | | - else |
---|
105 | | - cpus = cpu_map__default_new(); |
---|
106 | | -out_free_tmp: |
---|
107 | | - free(tmp_cpus); |
---|
108 | | - return cpus; |
---|
109 | | -} |
---|
110 | | - |
---|
111 | | -static struct cpu_map *cpu_map__read_all_cpu_map(void) |
---|
112 | | -{ |
---|
113 | | - struct cpu_map *cpus = NULL; |
---|
114 | | - FILE *onlnf; |
---|
115 | | - |
---|
116 | | - onlnf = fopen("/sys/devices/system/cpu/online", "r"); |
---|
117 | | - if (!onlnf) |
---|
118 | | - return cpu_map__default_new(); |
---|
119 | | - |
---|
120 | | - cpus = cpu_map__read(onlnf); |
---|
121 | | - fclose(onlnf); |
---|
122 | | - return cpus; |
---|
123 | | -} |
---|
124 | | - |
---|
125 | | -struct cpu_map *cpu_map__new(const char *cpu_list) |
---|
126 | | -{ |
---|
127 | | - struct cpu_map *cpus = NULL; |
---|
128 | | - unsigned long start_cpu, end_cpu = 0; |
---|
129 | | - char *p = NULL; |
---|
130 | | - int i, nr_cpus = 0; |
---|
131 | | - int *tmp_cpus = NULL, *tmp; |
---|
132 | | - int max_entries = 0; |
---|
133 | | - |
---|
134 | | - if (!cpu_list) |
---|
135 | | - return cpu_map__read_all_cpu_map(); |
---|
136 | | - |
---|
137 | | - /* |
---|
138 | | - * must handle the case of empty cpumap to cover |
---|
139 | | - * TOPOLOGY header for NUMA nodes with no CPU |
---|
140 | | - * ( e.g., because of CPU hotplug) |
---|
141 | | - */ |
---|
142 | | - if (!isdigit(*cpu_list) && *cpu_list != '\0') |
---|
143 | | - goto out; |
---|
144 | | - |
---|
145 | | - while (isdigit(*cpu_list)) { |
---|
146 | | - p = NULL; |
---|
147 | | - start_cpu = strtoul(cpu_list, &p, 0); |
---|
148 | | - if (start_cpu >= INT_MAX |
---|
149 | | - || (*p != '\0' && *p != ',' && *p != '-')) |
---|
150 | | - goto invalid; |
---|
151 | | - |
---|
152 | | - if (*p == '-') { |
---|
153 | | - cpu_list = ++p; |
---|
154 | | - p = NULL; |
---|
155 | | - end_cpu = strtoul(cpu_list, &p, 0); |
---|
156 | | - |
---|
157 | | - if (end_cpu >= INT_MAX || (*p != '\0' && *p != ',')) |
---|
158 | | - goto invalid; |
---|
159 | | - |
---|
160 | | - if (end_cpu < start_cpu) |
---|
161 | | - goto invalid; |
---|
162 | | - } else { |
---|
163 | | - end_cpu = start_cpu; |
---|
164 | | - } |
---|
165 | | - |
---|
166 | | - for (; start_cpu <= end_cpu; start_cpu++) { |
---|
167 | | - /* check for duplicates */ |
---|
168 | | - for (i = 0; i < nr_cpus; i++) |
---|
169 | | - if (tmp_cpus[i] == (int)start_cpu) |
---|
170 | | - goto invalid; |
---|
171 | | - |
---|
172 | | - if (nr_cpus == max_entries) { |
---|
173 | | - max_entries += MAX_NR_CPUS; |
---|
174 | | - tmp = realloc(tmp_cpus, max_entries * sizeof(int)); |
---|
175 | | - if (tmp == NULL) |
---|
176 | | - goto invalid; |
---|
177 | | - tmp_cpus = tmp; |
---|
178 | | - } |
---|
179 | | - tmp_cpus[nr_cpus++] = (int)start_cpu; |
---|
180 | | - } |
---|
181 | | - if (*p) |
---|
182 | | - ++p; |
---|
183 | | - |
---|
184 | | - cpu_list = p; |
---|
185 | | - } |
---|
186 | | - |
---|
187 | | - if (nr_cpus > 0) |
---|
188 | | - cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); |
---|
189 | | - else if (*cpu_list != '\0') |
---|
190 | | - cpus = cpu_map__default_new(); |
---|
191 | | - else |
---|
192 | | - cpus = cpu_map__dummy_new(); |
---|
193 | | -invalid: |
---|
194 | | - free(tmp_cpus); |
---|
195 | | -out: |
---|
196 | | - return cpus; |
---|
197 | | -} |
---|
198 | | - |
---|
199 | | -static struct cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus) |
---|
200 | | -{ |
---|
201 | | - struct cpu_map *map; |
---|
202 | | - |
---|
203 | | - map = cpu_map__empty_new(cpus->nr); |
---|
| 25 | + map = perf_cpu_map__empty_new(cpus->nr); |
---|
204 | 26 | if (map) { |
---|
205 | 27 | unsigned i; |
---|
206 | 28 | |
---|
.. | .. |
---|
220 | 42 | return map; |
---|
221 | 43 | } |
---|
222 | 44 | |
---|
223 | | -static struct cpu_map *cpu_map__from_mask(struct cpu_map_mask *mask) |
---|
| 45 | +static struct perf_cpu_map *cpu_map__from_mask(struct perf_record_record_cpu_map *mask) |
---|
224 | 46 | { |
---|
225 | | - struct cpu_map *map; |
---|
| 47 | + struct perf_cpu_map *map; |
---|
226 | 48 | int nr, nbits = mask->nr * mask->long_size * BITS_PER_BYTE; |
---|
227 | 49 | |
---|
228 | 50 | nr = bitmap_weight(mask->mask, nbits); |
---|
229 | 51 | |
---|
230 | | - map = cpu_map__empty_new(nr); |
---|
| 52 | + map = perf_cpu_map__empty_new(nr); |
---|
231 | 53 | if (map) { |
---|
232 | 54 | int cpu, i = 0; |
---|
233 | 55 | |
---|
.. | .. |
---|
238 | 60 | |
---|
239 | 61 | } |
---|
240 | 62 | |
---|
241 | | -struct cpu_map *cpu_map__new_data(struct cpu_map_data *data) |
---|
| 63 | +struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data) |
---|
242 | 64 | { |
---|
243 | 65 | if (data->type == PERF_CPU_MAP__CPUS) |
---|
244 | 66 | return cpu_map__from_entries((struct cpu_map_entries *)data->data); |
---|
245 | 67 | else |
---|
246 | | - return cpu_map__from_mask((struct cpu_map_mask *)data->data); |
---|
| 68 | + return cpu_map__from_mask((struct perf_record_record_cpu_map *)data->data); |
---|
247 | 69 | } |
---|
248 | 70 | |
---|
249 | | -size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp) |
---|
| 71 | +size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp) |
---|
250 | 72 | { |
---|
251 | 73 | #define BUFSIZE 1024 |
---|
252 | 74 | char buf[BUFSIZE]; |
---|
.. | .. |
---|
256 | 78 | #undef BUFSIZE |
---|
257 | 79 | } |
---|
258 | 80 | |
---|
259 | | -struct cpu_map *cpu_map__dummy_new(void) |
---|
| 81 | +struct perf_cpu_map *perf_cpu_map__empty_new(int nr) |
---|
260 | 82 | { |
---|
261 | | - struct 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 | | - |
---|
272 | | -struct cpu_map *cpu_map__empty_new(int nr) |
---|
273 | | -{ |
---|
274 | | - struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr); |
---|
| 83 | + struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr); |
---|
275 | 84 | |
---|
276 | 85 | if (cpus != NULL) { |
---|
277 | 86 | int i; |
---|
.. | .. |
---|
284 | 93 | } |
---|
285 | 94 | |
---|
286 | 95 | return cpus; |
---|
287 | | -} |
---|
288 | | - |
---|
289 | | -static void cpu_map__delete(struct cpu_map *map) |
---|
290 | | -{ |
---|
291 | | - if (map) { |
---|
292 | | - WARN_ONCE(refcount_read(&map->refcnt) != 0, |
---|
293 | | - "cpu_map refcnt unbalanced\n"); |
---|
294 | | - free(map); |
---|
295 | | - } |
---|
296 | | -} |
---|
297 | | - |
---|
298 | | -struct cpu_map *cpu_map__get(struct cpu_map *map) |
---|
299 | | -{ |
---|
300 | | - if (map) |
---|
301 | | - refcount_inc(&map->refcnt); |
---|
302 | | - return map; |
---|
303 | | -} |
---|
304 | | - |
---|
305 | | -void cpu_map__put(struct cpu_map *map) |
---|
306 | | -{ |
---|
307 | | - if (map && refcount_dec_and_test(&map->refcnt)) |
---|
308 | | - cpu_map__delete(map); |
---|
309 | 96 | } |
---|
310 | 97 | |
---|
311 | 98 | static int cpu__get_topology_int(int cpu, const char *name, int *value) |
---|
.. | .. |
---|
324 | 111 | return ret ?: value; |
---|
325 | 112 | } |
---|
326 | 113 | |
---|
327 | | -int cpu_map__get_socket(struct cpu_map *map, int idx, void *data __maybe_unused) |
---|
| 114 | +int cpu_map__get_socket(struct perf_cpu_map *map, int idx, void *data __maybe_unused) |
---|
328 | 115 | { |
---|
329 | 116 | int cpu; |
---|
330 | 117 | |
---|
.. | .. |
---|
341 | 128 | return *(int *)a - *(int *)b; |
---|
342 | 129 | } |
---|
343 | 130 | |
---|
344 | | -int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, |
---|
345 | | - int (*f)(struct cpu_map *map, int cpu, void *data), |
---|
| 131 | +int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res, |
---|
| 132 | + int (*f)(struct perf_cpu_map *map, int cpu, void *data), |
---|
346 | 133 | void *data) |
---|
347 | 134 | { |
---|
348 | | - struct cpu_map *c; |
---|
| 135 | + struct perf_cpu_map *c; |
---|
349 | 136 | int nr = cpus->nr; |
---|
350 | 137 | int cpu, s1, s2; |
---|
351 | 138 | |
---|
.. | .. |
---|
373 | 160 | return 0; |
---|
374 | 161 | } |
---|
375 | 162 | |
---|
| 163 | +int cpu_map__get_die_id(int cpu) |
---|
| 164 | +{ |
---|
| 165 | + int value, ret = cpu__get_topology_int(cpu, "die_id", &value); |
---|
| 166 | + |
---|
| 167 | + return ret ?: value; |
---|
| 168 | +} |
---|
| 169 | + |
---|
| 170 | +int cpu_map__get_die(struct perf_cpu_map *map, int idx, void *data) |
---|
| 171 | +{ |
---|
| 172 | + int cpu, die_id, s; |
---|
| 173 | + |
---|
| 174 | + if (idx > map->nr) |
---|
| 175 | + return -1; |
---|
| 176 | + |
---|
| 177 | + cpu = map->map[idx]; |
---|
| 178 | + |
---|
| 179 | + die_id = cpu_map__get_die_id(cpu); |
---|
| 180 | + /* There is no die_id on legacy system. */ |
---|
| 181 | + if (die_id == -1) |
---|
| 182 | + die_id = 0; |
---|
| 183 | + |
---|
| 184 | + s = cpu_map__get_socket(map, idx, data); |
---|
| 185 | + if (s == -1) |
---|
| 186 | + return -1; |
---|
| 187 | + |
---|
| 188 | + /* |
---|
| 189 | + * Encode socket in bit range 15:8 |
---|
| 190 | + * die_id is relative to socket, and |
---|
| 191 | + * we need a global id. So we combine |
---|
| 192 | + * socket + die id |
---|
| 193 | + */ |
---|
| 194 | + if (WARN_ONCE(die_id >> 8, "The die id number is too big.\n")) |
---|
| 195 | + return -1; |
---|
| 196 | + |
---|
| 197 | + if (WARN_ONCE(s >> 8, "The socket id number is too big.\n")) |
---|
| 198 | + return -1; |
---|
| 199 | + |
---|
| 200 | + return (s << 8) | (die_id & 0xff); |
---|
| 201 | +} |
---|
| 202 | + |
---|
376 | 203 | int cpu_map__get_core_id(int cpu) |
---|
377 | 204 | { |
---|
378 | 205 | int value, ret = cpu__get_topology_int(cpu, "core_id", &value); |
---|
379 | 206 | return ret ?: value; |
---|
380 | 207 | } |
---|
381 | 208 | |
---|
382 | | -int cpu_map__get_core(struct cpu_map *map, int idx, void *data) |
---|
| 209 | +int cpu_map__get_node_id(int cpu) |
---|
383 | 210 | { |
---|
384 | | - int cpu, s; |
---|
| 211 | + return cpu__get_node(cpu); |
---|
| 212 | +} |
---|
| 213 | + |
---|
| 214 | +int cpu_map__get_core(struct perf_cpu_map *map, int idx, void *data) |
---|
| 215 | +{ |
---|
| 216 | + int cpu, s_die; |
---|
385 | 217 | |
---|
386 | 218 | if (idx > map->nr) |
---|
387 | 219 | return -1; |
---|
.. | .. |
---|
390 | 222 | |
---|
391 | 223 | cpu = cpu_map__get_core_id(cpu); |
---|
392 | 224 | |
---|
393 | | - s = cpu_map__get_socket(map, idx, data); |
---|
394 | | - if (s == -1) |
---|
| 225 | + /* s_die is the combination of socket + die id */ |
---|
| 226 | + s_die = cpu_map__get_die(map, idx, data); |
---|
| 227 | + if (s_die == -1) |
---|
395 | 228 | return -1; |
---|
396 | 229 | |
---|
397 | 230 | /* |
---|
398 | | - * encode socket in upper 16 bits |
---|
399 | | - * core_id is relative to socket, and |
---|
| 231 | + * encode socket in bit range 31:24 |
---|
| 232 | + * encode die id in bit range 23:16 |
---|
| 233 | + * core_id is relative to socket and die, |
---|
400 | 234 | * we need a global id. So we combine |
---|
401 | | - * socket+ core id |
---|
| 235 | + * socket + die id + core id |
---|
402 | 236 | */ |
---|
403 | | - return (s << 16) | (cpu & 0xffff); |
---|
| 237 | + if (WARN_ONCE(cpu >> 16, "The core id number is too big.\n")) |
---|
| 238 | + return -1; |
---|
| 239 | + |
---|
| 240 | + return (s_die << 16) | (cpu & 0xffff); |
---|
404 | 241 | } |
---|
405 | 242 | |
---|
406 | | -int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp) |
---|
| 243 | +int cpu_map__get_node(struct perf_cpu_map *map, int idx, void *data __maybe_unused) |
---|
| 244 | +{ |
---|
| 245 | + if (idx < 0 || idx >= map->nr) |
---|
| 246 | + return -1; |
---|
| 247 | + |
---|
| 248 | + return cpu_map__get_node_id(map->map[idx]); |
---|
| 249 | +} |
---|
| 250 | + |
---|
| 251 | +int cpu_map__build_socket_map(struct perf_cpu_map *cpus, struct perf_cpu_map **sockp) |
---|
407 | 252 | { |
---|
408 | 253 | return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL); |
---|
409 | 254 | } |
---|
410 | 255 | |
---|
411 | | -int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep) |
---|
| 256 | +int cpu_map__build_die_map(struct perf_cpu_map *cpus, struct perf_cpu_map **diep) |
---|
| 257 | +{ |
---|
| 258 | + return cpu_map__build_map(cpus, diep, cpu_map__get_die, NULL); |
---|
| 259 | +} |
---|
| 260 | + |
---|
| 261 | +int cpu_map__build_core_map(struct perf_cpu_map *cpus, struct perf_cpu_map **corep) |
---|
412 | 262 | { |
---|
413 | 263 | return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL); |
---|
| 264 | +} |
---|
| 265 | + |
---|
| 266 | +int cpu_map__build_node_map(struct perf_cpu_map *cpus, struct perf_cpu_map **numap) |
---|
| 267 | +{ |
---|
| 268 | + return cpu_map__build_map(cpus, numap, cpu_map__get_node, NULL); |
---|
414 | 269 | } |
---|
415 | 270 | |
---|
416 | 271 | /* setup simple routines to easily access node numbers given a cpu number */ |
---|
.. | .. |
---|
620 | 475 | return 0; |
---|
621 | 476 | } |
---|
622 | 477 | |
---|
623 | | -bool cpu_map__has(struct cpu_map *cpus, int cpu) |
---|
| 478 | +bool cpu_map__has(struct perf_cpu_map *cpus, int cpu) |
---|
624 | 479 | { |
---|
625 | | - return cpu_map__idx(cpus, cpu) != -1; |
---|
| 480 | + return perf_cpu_map__idx(cpus, cpu) != -1; |
---|
626 | 481 | } |
---|
627 | 482 | |
---|
628 | | -int cpu_map__idx(struct cpu_map *cpus, int cpu) |
---|
629 | | -{ |
---|
630 | | - int i; |
---|
631 | | - |
---|
632 | | - for (i = 0; i < cpus->nr; ++i) { |
---|
633 | | - if (cpus->map[i] == cpu) |
---|
634 | | - return i; |
---|
635 | | - } |
---|
636 | | - |
---|
637 | | - return -1; |
---|
638 | | -} |
---|
639 | | - |
---|
640 | | -int cpu_map__cpu(struct cpu_map *cpus, int idx) |
---|
| 483 | +int cpu_map__cpu(struct perf_cpu_map *cpus, int idx) |
---|
641 | 484 | { |
---|
642 | 485 | return cpus->map[idx]; |
---|
643 | 486 | } |
---|
644 | 487 | |
---|
645 | | -size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size) |
---|
| 488 | +size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size) |
---|
646 | 489 | { |
---|
647 | 490 | int i, cpu, start = -1; |
---|
648 | 491 | bool first = true; |
---|
.. | .. |
---|
681 | 524 | |
---|
682 | 525 | #undef COMMA |
---|
683 | 526 | |
---|
684 | | - pr_debug("cpumask list: %s\n", buf); |
---|
| 527 | + pr_debug2("cpumask list: %s\n", buf); |
---|
685 | 528 | return ret; |
---|
686 | 529 | } |
---|
687 | 530 | |
---|
.. | .. |
---|
694 | 537 | return '?'; |
---|
695 | 538 | } |
---|
696 | 539 | |
---|
697 | | -size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size) |
---|
| 540 | +size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size) |
---|
698 | 541 | { |
---|
699 | 542 | int i, cpu; |
---|
700 | 543 | char *ptr = buf; |
---|
.. | .. |
---|
733 | 576 | buf[size - 1] = '\0'; |
---|
734 | 577 | return ptr - buf; |
---|
735 | 578 | } |
---|
| 579 | + |
---|
| 580 | +const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */ |
---|
| 581 | +{ |
---|
| 582 | + static const struct perf_cpu_map *online = NULL; |
---|
| 583 | + |
---|
| 584 | + if (!online) |
---|
| 585 | + online = perf_cpu_map__new(NULL); /* from /sys/devices/system/cpu/online */ |
---|
| 586 | + |
---|
| 587 | + return online; |
---|
| 588 | +} |
---|