aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-02-27 05:21:28 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-02-27 13:52:24 -0500
commit5ef803ee02d67ad0b49f357cb7feb7d5e6b0015d (patch)
tree190db3a59e842d1095995db2a6214a84a6d3f9cf
parent705750f2d6e283ba2856ba8eda60dce2d405b387 (diff)
perf list: Extend raw-dump to certain kind of events
Extend 'perf list --raw-dump' to 'perf list --raw-dump [hw|sw|cache |tracepoint|pmu|event_glob]' in order to show the raw-dump of a certain kind of events rather than all of the events. Example: Before this patch: $ perf list --raw-dump hw branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions stalled-cycles-backend stalled-cycles-frontend alignment-faults context-switches cpu-clock cpu-migrations emulation-faults major-faults minor-faults page-faults task-clock ... ... writeback:writeback_thread_start writeback:writeback_thread_stop writeback:writeback_wait_iff_congested writeback:writeback_wake_background writeback:writeback_wake_thread As shown above, all of the events are printed. After this patch: $ perf list --raw-dump hw branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions stalled-cycles-backend stalled-cycles-frontend As shown above, only the hw events are printed. Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1425032491-20224-5-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-list.txt6
-rw-r--r--tools/perf/builtin-list.c21
2 files changed, 14 insertions, 13 deletions
diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index 3e2aec94f806..4692d277980b 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -127,6 +127,12 @@ To limit the list use:
127One or more types can be used at the same time, listing the events for the 127One or more types can be used at the same time, listing the events for the
128types specified. 128types specified.
129 129
130Support raw format:
131
132. '--raw-dump', shows the raw-dump of all the events.
133. '--raw-dump [hw|sw|cache|tracepoint|pmu|event_glob]', shows the raw-dump of
134 a certain kind of events.
135
130SEE ALSO 136SEE ALSO
131-------- 137--------
132linkperf:perf-stat[1], linkperf:perf-top[1], 138linkperf:perf-stat[1], linkperf:perf-top[1],
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 8b323e015458..af5bd0514108 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -36,41 +36,36 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
36 36
37 setup_pager(); 37 setup_pager();
38 38
39 if (raw_dump) {
40 print_events(NULL, true);
41 return 0;
42 }
43
44 if (!raw_dump) 39 if (!raw_dump)
45 printf("\nList of pre-defined events (to be used in -e):\n\n"); 40 printf("\nList of pre-defined events (to be used in -e):\n\n");
46 41
47 if (argc == 0) { 42 if (argc == 0) {
48 print_events(NULL, false); 43 print_events(NULL, raw_dump);
49 return 0; 44 return 0;
50 } 45 }
51 46
52 for (i = 0; i < argc; ++i) { 47 for (i = 0; i < argc; ++i) {
53 if (strcmp(argv[i], "tracepoint") == 0) 48 if (strcmp(argv[i], "tracepoint") == 0)
54 print_tracepoint_events(NULL, NULL, false); 49 print_tracepoint_events(NULL, NULL, raw_dump);
55 else if (strcmp(argv[i], "hw") == 0 || 50 else if (strcmp(argv[i], "hw") == 0 ||
56 strcmp(argv[i], "hardware") == 0) 51 strcmp(argv[i], "hardware") == 0)
57 print_symbol_events(NULL, PERF_TYPE_HARDWARE, 52 print_symbol_events(NULL, PERF_TYPE_HARDWARE,
58 event_symbols_hw, PERF_COUNT_HW_MAX, false); 53 event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump);
59 else if (strcmp(argv[i], "sw") == 0 || 54 else if (strcmp(argv[i], "sw") == 0 ||
60 strcmp(argv[i], "software") == 0) 55 strcmp(argv[i], "software") == 0)
61 print_symbol_events(NULL, PERF_TYPE_SOFTWARE, 56 print_symbol_events(NULL, PERF_TYPE_SOFTWARE,
62 event_symbols_sw, PERF_COUNT_SW_MAX, false); 57 event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
63 else if (strcmp(argv[i], "cache") == 0 || 58 else if (strcmp(argv[i], "cache") == 0 ||
64 strcmp(argv[i], "hwcache") == 0) 59 strcmp(argv[i], "hwcache") == 0)
65 print_hwcache_events(NULL, false); 60 print_hwcache_events(NULL, raw_dump);
66 else if (strcmp(argv[i], "pmu") == 0) 61 else if (strcmp(argv[i], "pmu") == 0)
67 print_pmu_events(NULL, false); 62 print_pmu_events(NULL, raw_dump);
68 else { 63 else {
69 char *sep = strchr(argv[i], ':'), *s; 64 char *sep = strchr(argv[i], ':'), *s;
70 int sep_idx; 65 int sep_idx;
71 66
72 if (sep == NULL) { 67 if (sep == NULL) {
73 print_events(argv[i], false); 68 print_events(argv[i], raw_dump);
74 continue; 69 continue;
75 } 70 }
76 sep_idx = sep - argv[i]; 71 sep_idx = sep - argv[i];
@@ -79,7 +74,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
79 return -1; 74 return -1;
80 75
81 s[sep_idx] = '\0'; 76 s[sep_idx] = '\0';
82 print_tracepoint_events(s, s + sep_idx + 1, false); 77 print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
83 free(s); 78 free(s);
84 } 79 }
85 } 80 }