diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-stat.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 45bf4d2caebe..39d0c30f0f59 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -346,6 +346,38 @@ static int perf_stat_synthesize_config(void) | |||
346 | return 0; | 346 | return 0; |
347 | } | 347 | } |
348 | 348 | ||
349 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | ||
350 | |||
351 | static int __store_counter_ids(struct perf_evsel *counter, | ||
352 | struct cpu_map *cpus, | ||
353 | struct thread_map *threads) | ||
354 | { | ||
355 | int cpu, thread; | ||
356 | |||
357 | for (cpu = 0; cpu < cpus->nr; cpu++) { | ||
358 | for (thread = 0; thread < threads->nr; thread++) { | ||
359 | int fd = FD(counter, cpu, thread); | ||
360 | |||
361 | if (perf_evlist__id_add_fd(evsel_list, counter, | ||
362 | cpu, thread, fd) < 0) | ||
363 | return -1; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | return 0; | ||
368 | } | ||
369 | |||
370 | static int store_counter_ids(struct perf_evsel *counter) | ||
371 | { | ||
372 | struct cpu_map *cpus = counter->cpus; | ||
373 | struct thread_map *threads = counter->threads; | ||
374 | |||
375 | if (perf_evsel__alloc_id(counter, cpus->nr, threads->nr)) | ||
376 | return -ENOMEM; | ||
377 | |||
378 | return __store_counter_ids(counter, cpus, threads); | ||
379 | } | ||
380 | |||
349 | static int __run_perf_stat(int argc, const char **argv) | 381 | static int __run_perf_stat(int argc, const char **argv) |
350 | { | 382 | { |
351 | int interval = stat_config.interval; | 383 | int interval = stat_config.interval; |
@@ -410,6 +442,9 @@ static int __run_perf_stat(int argc, const char **argv) | |||
410 | l = strlen(counter->unit); | 442 | l = strlen(counter->unit); |
411 | if (l > unit_width) | 443 | if (l > unit_width) |
412 | unit_width = l; | 444 | unit_width = l; |
445 | |||
446 | if (STAT_RECORD && store_counter_ids(counter)) | ||
447 | return -1; | ||
413 | } | 448 | } |
414 | 449 | ||
415 | if (perf_evlist__apply_filters(evsel_list, &counter)) { | 450 | if (perf_evlist__apply_filters(evsel_list, &counter)) { |