diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-22 13:30:11 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-22 13:30:11 -0400 |
commit | 26252ea675663d1bc6747125fcaa2b7cc4ed8a03 (patch) | |
tree | e34d5c4df4f5e9a7e510df8c6774f913eea19f31 /tools | |
parent | 447a6013e91738c0d4118a7d0c56f235d8623695 (diff) |
perf evlist: Show event attribute details
There was no easy way to see the frequency used, and with the change of
default, we better provide one.
[root@sandy linux]# perf evlist -F
cycles: sample_freq=4000
[root@sandy linux]# perf evlist -v
cycles: sample_freq=4000, size: 80, sample_type: 391, read_format: 7, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
[root@sandy linux]#
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-e1p9poez3nwrgycbmwqmhlsu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-evlist.txt | 8 | ||||
-rw-r--r-- | tools/perf/builtin-evlist.c | 103 |
2 files changed, 100 insertions, 11 deletions
diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt index 0507ec7bad71..15217345c2fa 100644 --- a/tools/perf/Documentation/perf-evlist.txt +++ b/tools/perf/Documentation/perf-evlist.txt | |||
@@ -20,6 +20,14 @@ OPTIONS | |||
20 | --input=:: | 20 | --input=:: |
21 | Input file name. (default: perf.data unless stdin is a fifo) | 21 | Input file name. (default: perf.data unless stdin is a fifo) |
22 | 22 | ||
23 | -F:: | ||
24 | --freq=:: | ||
25 | Show just the sample frequency used for each event. | ||
26 | |||
27 | -v:: | ||
28 | --verbose=:: | ||
29 | Show all fields. | ||
30 | |||
23 | SEE ALSO | 31 | SEE ALSO |
24 | -------- | 32 | -------- |
25 | linkperf:perf-record[1], linkperf:perf-list[1], | 33 | linkperf:perf-record[1], linkperf:perf-list[1], |
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 26760322c4f4..e52d77ec7084 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c | |||
@@ -15,9 +15,40 @@ | |||
15 | #include "util/parse-options.h" | 15 | #include "util/parse-options.h" |
16 | #include "util/session.h" | 16 | #include "util/session.h" |
17 | 17 | ||
18 | static const char *input_name; | 18 | struct perf_attr_details { |
19 | bool freq; | ||
20 | bool verbose; | ||
21 | }; | ||
22 | |||
23 | static int comma_printf(bool *first, const char *fmt, ...) | ||
24 | { | ||
25 | va_list args; | ||
26 | int ret = 0; | ||
27 | |||
28 | if (!*first) { | ||
29 | ret += printf(","); | ||
30 | } else { | ||
31 | ret += printf(":"); | ||
32 | *first = false; | ||
33 | } | ||
34 | |||
35 | va_start(args, fmt); | ||
36 | ret += vprintf(fmt, args); | ||
37 | va_end(args); | ||
38 | return ret; | ||
39 | } | ||
40 | |||
41 | static int __if_print(bool *first, const char *field, u64 value) | ||
42 | { | ||
43 | if (value == 0) | ||
44 | return 0; | ||
45 | |||
46 | return comma_printf(first, " %s: %" PRIu64, field, value); | ||
47 | } | ||
48 | |||
49 | #define if_print(field) __if_print(&first, #field, pos->attr.field) | ||
19 | 50 | ||
20 | static int __cmd_evlist(void) | 51 | static int __cmd_evlist(const char *input_name, struct perf_attr_details *details) |
21 | { | 52 | { |
22 | struct perf_session *session; | 53 | struct perf_session *session; |
23 | struct perf_evsel *pos; | 54 | struct perf_evsel *pos; |
@@ -26,8 +57,52 @@ static int __cmd_evlist(void) | |||
26 | if (session == NULL) | 57 | if (session == NULL) |
27 | return -ENOMEM; | 58 | return -ENOMEM; |
28 | 59 | ||
29 | list_for_each_entry(pos, &session->evlist->entries, node) | 60 | list_for_each_entry(pos, &session->evlist->entries, node) { |
30 | printf("%s\n", event_name(pos)); | 61 | bool first = true; |
62 | |||
63 | printf("%s", event_name(pos)); | ||
64 | |||
65 | if (details->verbose || details->freq) { | ||
66 | comma_printf(&first, " sample_freq=%" PRIu64, | ||
67 | (u64)pos->attr.sample_freq); | ||
68 | } | ||
69 | |||
70 | if (details->verbose) { | ||
71 | if_print(type); | ||
72 | if_print(config); | ||
73 | if_print(config1); | ||
74 | if_print(config2); | ||
75 | if_print(size); | ||
76 | if_print(sample_type); | ||
77 | if_print(read_format); | ||
78 | if_print(disabled); | ||
79 | if_print(inherit); | ||
80 | if_print(pinned); | ||
81 | if_print(exclusive); | ||
82 | if_print(exclude_user); | ||
83 | if_print(exclude_kernel); | ||
84 | if_print(exclude_hv); | ||
85 | if_print(exclude_idle); | ||
86 | if_print(mmap); | ||
87 | if_print(comm); | ||
88 | if_print(freq); | ||
89 | if_print(inherit_stat); | ||
90 | if_print(enable_on_exec); | ||
91 | if_print(task); | ||
92 | if_print(watermark); | ||
93 | if_print(precise_ip); | ||
94 | if_print(mmap_data); | ||
95 | if_print(sample_id_all); | ||
96 | if_print(exclude_host); | ||
97 | if_print(exclude_guest); | ||
98 | if_print(__reserved_1); | ||
99 | if_print(wakeup_events); | ||
100 | if_print(bp_type); | ||
101 | if_print(branch_sample_type); | ||
102 | } | ||
103 | |||
104 | putchar('\n'); | ||
105 | } | ||
31 | 106 | ||
32 | perf_session__delete(session); | 107 | perf_session__delete(session); |
33 | return 0; | 108 | return 0; |
@@ -38,17 +113,23 @@ static const char * const evlist_usage[] = { | |||
38 | NULL | 113 | NULL |
39 | }; | 114 | }; |
40 | 115 | ||
41 | static const struct option options[] = { | ||
42 | OPT_STRING('i', "input", &input_name, "file", | ||
43 | "input file name"), | ||
44 | OPT_END() | ||
45 | }; | ||
46 | |||
47 | int cmd_evlist(int argc, const char **argv, const char *prefix __used) | 116 | int cmd_evlist(int argc, const char **argv, const char *prefix __used) |
48 | { | 117 | { |
118 | struct perf_attr_details details = { .verbose = false, }; | ||
119 | const char *input_name; | ||
120 | const struct option options[] = { | ||
121 | OPT_STRING('i', "input", &input_name, "file", | ||
122 | "Input file name"), | ||
123 | OPT_BOOLEAN('F', "freq", &details.freq, | ||
124 | "Show the sample frequency"), | ||
125 | OPT_BOOLEAN('v', "verbose", &details.verbose, | ||
126 | "Show all event attr details"), | ||
127 | OPT_END() | ||
128 | }; | ||
129 | |||
49 | argc = parse_options(argc, argv, options, evlist_usage, 0); | 130 | argc = parse_options(argc, argv, options, evlist_usage, 0); |
50 | if (argc) | 131 | if (argc) |
51 | usage_with_options(evlist_usage, options); | 132 | usage_with_options(evlist_usage, options); |
52 | 133 | ||
53 | return __cmd_evlist(); | 134 | return __cmd_evlist(input_name, &details); |
54 | } | 135 | } |