diff options
-rw-r--r-- | tools/perf/builtin-stat.c | 14 | ||||
-rw-r--r-- | tools/perf/tests/topology.c | 4 | ||||
-rw-r--r-- | tools/perf/util/cpumap.c | 15 | ||||
-rw-r--r-- | tools/perf/util/cpumap.h | 7 | ||||
-rw-r--r-- | tools/perf/util/stat.c | 2 |
5 files changed, 27 insertions, 15 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index abeb15aebd12..91e793a76929 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -944,6 +944,16 @@ static int stat__set_big_num(const struct option *opt __maybe_unused, | |||
944 | return 0; | 944 | return 0; |
945 | } | 945 | } |
946 | 946 | ||
947 | static int perf_stat__get_socket(struct cpu_map *map, int cpu) | ||
948 | { | ||
949 | return cpu_map__get_socket(map, cpu, NULL); | ||
950 | } | ||
951 | |||
952 | static int perf_stat__get_core(struct cpu_map *map, int cpu) | ||
953 | { | ||
954 | return cpu_map__get_core(map, cpu, NULL); | ||
955 | } | ||
956 | |||
947 | static int perf_stat_init_aggr_mode(void) | 957 | static int perf_stat_init_aggr_mode(void) |
948 | { | 958 | { |
949 | switch (stat_config.aggr_mode) { | 959 | switch (stat_config.aggr_mode) { |
@@ -952,14 +962,14 @@ static int perf_stat_init_aggr_mode(void) | |||
952 | perror("cannot build socket map"); | 962 | perror("cannot build socket map"); |
953 | return -1; | 963 | return -1; |
954 | } | 964 | } |
955 | aggr_get_id = cpu_map__get_socket; | 965 | aggr_get_id = perf_stat__get_socket; |
956 | break; | 966 | break; |
957 | case AGGR_CORE: | 967 | case AGGR_CORE: |
958 | if (cpu_map__build_core_map(evsel_list->cpus, &aggr_map)) { | 968 | if (cpu_map__build_core_map(evsel_list->cpus, &aggr_map)) { |
959 | perror("cannot build core map"); | 969 | perror("cannot build core map"); |
960 | return -1; | 970 | return -1; |
961 | } | 971 | } |
962 | aggr_get_id = cpu_map__get_core; | 972 | aggr_get_id = perf_stat__get_core; |
963 | break; | 973 | break; |
964 | case AGGR_NONE: | 974 | case AGGR_NONE: |
965 | case AGGR_GLOBAL: | 975 | case AGGR_GLOBAL: |
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c index c3aff53a976a..f5bb096c3bd9 100644 --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c | |||
@@ -73,10 +73,10 @@ static int check_cpu_topology(char *path, struct cpu_map *map) | |||
73 | 73 | ||
74 | for (i = 0; i < map->nr; i++) { | 74 | for (i = 0; i < map->nr; i++) { |
75 | TEST_ASSERT_VAL("Core ID doesn't match", | 75 | TEST_ASSERT_VAL("Core ID doesn't match", |
76 | (session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core(map, i) & 0xffff))); | 76 | (session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core(map, i, NULL) & 0xffff))); |
77 | 77 | ||
78 | TEST_ASSERT_VAL("Socket ID doesn't match", | 78 | TEST_ASSERT_VAL("Socket ID doesn't match", |
79 | (session->header.env.cpu[map->map[i]].socket_id == cpu_map__get_socket(map, i))); | 79 | (session->header.env.cpu[map->map[i]].socket_id == cpu_map__get_socket(map, i, NULL))); |
80 | } | 80 | } |
81 | 81 | ||
82 | perf_session__delete(session); | 82 | perf_session__delete(session); |
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 70ec8d031f9d..b36845347f01 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c | |||
@@ -241,7 +241,7 @@ int cpu_map__get_socket_id(int cpu) | |||
241 | return ret ?: value; | 241 | return ret ?: value; |
242 | } | 242 | } |
243 | 243 | ||
244 | int cpu_map__get_socket(struct cpu_map *map, int idx) | 244 | int cpu_map__get_socket(struct cpu_map *map, int idx, void *data __maybe_unused) |
245 | { | 245 | { |
246 | int cpu; | 246 | int cpu; |
247 | 247 | ||
@@ -259,7 +259,8 @@ static int cmp_ids(const void *a, const void *b) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, | 261 | int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, |
262 | int (*f)(struct cpu_map *map, int cpu)) | 262 | int (*f)(struct cpu_map *map, int cpu, void *data), |
263 | void *data) | ||
263 | { | 264 | { |
264 | struct cpu_map *c; | 265 | struct cpu_map *c; |
265 | int nr = cpus->nr; | 266 | int nr = cpus->nr; |
@@ -271,7 +272,7 @@ int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, | |||
271 | return -1; | 272 | return -1; |
272 | 273 | ||
273 | for (cpu = 0; cpu < nr; cpu++) { | 274 | for (cpu = 0; cpu < nr; cpu++) { |
274 | s1 = f(cpus, cpu); | 275 | s1 = f(cpus, cpu, data); |
275 | for (s2 = 0; s2 < c->nr; s2++) { | 276 | for (s2 = 0; s2 < c->nr; s2++) { |
276 | if (s1 == c->map[s2]) | 277 | if (s1 == c->map[s2]) |
277 | break; | 278 | break; |
@@ -295,7 +296,7 @@ int cpu_map__get_core_id(int cpu) | |||
295 | return ret ?: value; | 296 | return ret ?: value; |
296 | } | 297 | } |
297 | 298 | ||
298 | int cpu_map__get_core(struct cpu_map *map, int idx) | 299 | int cpu_map__get_core(struct cpu_map *map, int idx, void *data) |
299 | { | 300 | { |
300 | int cpu, s; | 301 | int cpu, s; |
301 | 302 | ||
@@ -306,7 +307,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx) | |||
306 | 307 | ||
307 | cpu = cpu_map__get_core_id(cpu); | 308 | cpu = cpu_map__get_core_id(cpu); |
308 | 309 | ||
309 | s = cpu_map__get_socket(map, idx); | 310 | s = cpu_map__get_socket(map, idx, data); |
310 | if (s == -1) | 311 | if (s == -1) |
311 | return -1; | 312 | return -1; |
312 | 313 | ||
@@ -321,12 +322,12 @@ int cpu_map__get_core(struct cpu_map *map, int idx) | |||
321 | 322 | ||
322 | int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp) | 323 | int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp) |
323 | { | 324 | { |
324 | return cpu_map__build_map(cpus, sockp, cpu_map__get_socket); | 325 | return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL); |
325 | } | 326 | } |
326 | 327 | ||
327 | int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep) | 328 | int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep) |
328 | { | 329 | { |
329 | return cpu_map__build_map(cpus, corep, cpu_map__get_core); | 330 | return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL); |
330 | } | 331 | } |
331 | 332 | ||
332 | /* setup simple routines to easily access node numbers given a cpu number */ | 333 | /* setup simple routines to easily access node numbers given a cpu number */ |
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index 6e36fc35eca6..f1bcd2cfa164 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h | |||
@@ -19,9 +19,9 @@ struct cpu_map *cpu_map__dummy_new(void); | |||
19 | struct cpu_map *cpu_map__read(FILE *file); | 19 | struct cpu_map *cpu_map__read(FILE *file); |
20 | size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp); | 20 | size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp); |
21 | int cpu_map__get_socket_id(int cpu); | 21 | int cpu_map__get_socket_id(int cpu); |
22 | int cpu_map__get_socket(struct cpu_map *map, int idx); | 22 | int cpu_map__get_socket(struct cpu_map *map, int idx, void *data); |
23 | int cpu_map__get_core_id(int cpu); | 23 | int cpu_map__get_core_id(int cpu); |
24 | int cpu_map__get_core(struct cpu_map *map, int idx); | 24 | int cpu_map__get_core(struct cpu_map *map, int idx, void *data); |
25 | int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp); | 25 | int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp); |
26 | int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep); | 26 | int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep); |
27 | 27 | ||
@@ -88,5 +88,6 @@ static inline int cpu__get_node(int cpu) | |||
88 | } | 88 | } |
89 | 89 | ||
90 | int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, | 90 | int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, |
91 | int (*f)(struct cpu_map *map, int cpu)); | 91 | int (*f)(struct cpu_map *map, int cpu, void *data), |
92 | void *data); | ||
92 | #endif /* __PERF_CPUMAP_H */ | 93 | #endif /* __PERF_CPUMAP_H */ |
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 837374181ec7..2d9d8306dbd3 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -230,7 +230,7 @@ static int check_per_pkg(struct perf_evsel *counter, | |||
230 | if (!(vals->run && vals->ena)) | 230 | if (!(vals->run && vals->ena)) |
231 | return 0; | 231 | return 0; |
232 | 232 | ||
233 | s = cpu_map__get_socket(cpus, cpu); | 233 | s = cpu_map__get_socket(cpus, cpu, NULL); |
234 | if (s < 0) | 234 | if (s < 0) |
235 | return -1; | 235 | return -1; |
236 | 236 | ||