aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorBrice Goglin <Brice.Goglin@inria.fr>2009-08-07 07:55:24 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-09 07:04:20 -0400
commit8d51327090ac025d7f4ce6c059786b5e93513321 (patch)
tree32576a197af970ac698c7888c67235e8f723fa67 /tools/perf/builtin-report.c
parent30dd568c912602b7dbd609a45d053e01b13422bb (diff)
perf report: Fix and improve the displaying of per-thread event counters
Improve and fix the handling of per-thread counter stats recorded via perf record -s. Previously we only displayed it in debug printouts (-D) and even that output was hard to disambiguate. I moved everything to utils/values.[ch] so that we may reuse it in perf stat. We get something like this now: # PID TID cache-misses cache-references 4658 4659 495581 3238779 4658 4662 498246 3236823 4658 4663 499531 3243162 Then it'll be easy to add --pretty=raw to display a single line per thread/event. By the way, -S was also used for --symbol... So I used -T/--thread here. perf report: Add -T/--threads to display per-thread counter values We get something like this now: # PID TID cache-misses cache-references 4658 4659 495581 3238779 4658 4662 498246 3236823 4658 4663 499531 3243162 Per-thread arrays of counter values are managed in utils/values.[ch] Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: paulus@samba.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 99274cec0adb..41639182fb3f 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -17,6 +17,7 @@
17#include "util/string.h" 17#include "util/string.h"
18#include "util/callchain.h" 18#include "util/callchain.h"
19#include "util/strlist.h" 19#include "util/strlist.h"
20#include "util/values.h"
20 21
21#include "perf.h" 22#include "perf.h"
22#include "util/header.h" 23#include "util/header.h"
@@ -53,6 +54,9 @@ static int modules;
53static int full_paths; 54static int full_paths;
54static int show_nr_samples; 55static int show_nr_samples;
55 56
57static int show_threads;
58static struct perf_read_values show_threads_values;
59
56static unsigned long page_size; 60static unsigned long page_size;
57static unsigned long mmap_window = 32; 61static unsigned long mmap_window = 32;
58 62
@@ -1473,6 +1477,9 @@ print_entries:
1473 1477
1474 free(rem_sq_bracket); 1478 free(rem_sq_bracket);
1475 1479
1480 if (show_threads)
1481 perf_read_values_display(fp, &show_threads_values);
1482
1476 return ret; 1483 return ret;
1477} 1484}
1478 1485
@@ -1758,6 +1765,16 @@ process_read_event(event_t *event, unsigned long offset, unsigned long head)
1758{ 1765{
1759 struct perf_counter_attr *attr = perf_header__find_attr(event->read.id); 1766 struct perf_counter_attr *attr = perf_header__find_attr(event->read.id);
1760 1767
1768 if (show_threads) {
1769 char *name = attr ? __event_name(attr->type, attr->config)
1770 : "unknown";
1771 perf_read_values_add_value(&show_threads_values,
1772 event->read.pid, event->read.tid,
1773 event->read.id,
1774 name,
1775 event->read.value);
1776 }
1777
1761 dprintf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n", 1778 dprintf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n",
1762 (void *)(offset + head), 1779 (void *)(offset + head),
1763 (void *)(long)(event->header.size), 1780 (void *)(long)(event->header.size),
@@ -1839,6 +1856,9 @@ static int __cmd_report(void)
1839 1856
1840 register_idle_thread(); 1857 register_idle_thread();
1841 1858
1859 if (show_threads)
1860 perf_read_values_init(&show_threads_values);
1861
1842 input = open(input_name, O_RDONLY); 1862 input = open(input_name, O_RDONLY);
1843 if (input < 0) { 1863 if (input < 0) {
1844 fprintf(stderr, " failed to open file: %s", input_name); 1864 fprintf(stderr, " failed to open file: %s", input_name);
@@ -1993,6 +2013,9 @@ done:
1993 output__resort(total); 2013 output__resort(total);
1994 output__fprintf(stdout, total); 2014 output__fprintf(stdout, total);
1995 2015
2016 if (show_threads)
2017 perf_read_values_destroy(&show_threads_values);
2018
1996 return rc; 2019 return rc;
1997} 2020}
1998 2021
@@ -2066,6 +2089,8 @@ static const struct option options[] = {
2066 "load module symbols - WARNING: use only with -k and LIVE kernel"), 2089 "load module symbols - WARNING: use only with -k and LIVE kernel"),
2067 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples, 2090 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
2068 "Show a column with the number of samples"), 2091 "Show a column with the number of samples"),
2092 OPT_BOOLEAN('T', "threads", &show_threads,
2093 "Show per-thread event counters"),
2069 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 2094 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
2070 "sort by key(s): pid, comm, dso, symbol, parent"), 2095 "sort by key(s): pid, comm, dso, symbol, parent"),
2071 OPT_BOOLEAN('P', "full-paths", &full_paths, 2096 OPT_BOOLEAN('P', "full-paths", &full_paths,