diff options
-rw-r--r-- | tools/perf/Documentation/perf-top.txt | 38 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 10 | ||||
-rw-r--r-- | tools/perf/util/top.h | 2 |
3 files changed, 49 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index cfea87c6f38e..5596129a71cf 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt | |||
@@ -266,6 +266,44 @@ Default is to monitor all CPUS. | |||
266 | Record events of type PERF_RECORD_NAMESPACES and display it with the | 266 | Record events of type PERF_RECORD_NAMESPACES and display it with the |
267 | 'cgroup_id' sort key. | 267 | 'cgroup_id' sort key. |
268 | 268 | ||
269 | --switch-on EVENT_NAME:: | ||
270 | Only consider events after this event is found. | ||
271 | |||
272 | E.g.: | ||
273 | |||
274 | Find out where broadcast packets are handled | ||
275 | |||
276 | perf probe -L icmp_rcv | ||
277 | |||
278 | Insert a probe there: | ||
279 | |||
280 | perf probe icmp_rcv:59 | ||
281 | |||
282 | Start perf top and ask it to only consider the cycles events when a | ||
283 | broadcast packet arrives This will show a menu with two entries and | ||
284 | will start counting when a broadcast packet arrives: | ||
285 | |||
286 | perf top -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv | ||
287 | |||
288 | Alternatively one can ask for --group and then two overhead columns | ||
289 | will appear, the first for cycles and the second for the switch-on event. | ||
290 | |||
291 | perf top --group -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv | ||
292 | |||
293 | This may be interesting to measure a workload only after some initialization | ||
294 | phase is over, i.e. insert a perf probe at that point and use the above | ||
295 | examples replacing probe:icmp_rcv with the just-after-init probe. | ||
296 | |||
297 | --switch-off EVENT_NAME:: | ||
298 | Stop considering events after this event is found. | ||
299 | |||
300 | --show-on-off-events:: | ||
301 | Show the --switch-on/off events too. This has no effect in 'perf top' now | ||
302 | but probably we'll make the default not to show the switch-on/off events | ||
303 | on the --group mode and if there is only one event besides the off/on ones, | ||
304 | go straight to the histogram browser, just like 'perf top' with no events | ||
305 | explicitely specified does. | ||
306 | |||
269 | 307 | ||
270 | INTERACTIVE PROMPTING KEYS | 308 | INTERACTIVE PROMPTING KEYS |
271 | -------------------------- | 309 | -------------------------- |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 78e7efc597a6..5970723cd55a 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -1148,8 +1148,11 @@ static int deliver_event(struct ordered_events *qe, | |||
1148 | evsel = perf_evlist__id2evsel(session->evlist, sample.id); | 1148 | evsel = perf_evlist__id2evsel(session->evlist, sample.id); |
1149 | assert(evsel != NULL); | 1149 | assert(evsel != NULL); |
1150 | 1150 | ||
1151 | if (event->header.type == PERF_RECORD_SAMPLE) | 1151 | if (event->header.type == PERF_RECORD_SAMPLE) { |
1152 | if (evswitch__discard(&top->evswitch, evsel)) | ||
1153 | return 0; | ||
1152 | ++top->samples; | 1154 | ++top->samples; |
1155 | } | ||
1153 | 1156 | ||
1154 | switch (sample.cpumode) { | 1157 | switch (sample.cpumode) { |
1155 | case PERF_RECORD_MISC_USER: | 1158 | case PERF_RECORD_MISC_USER: |
@@ -1534,6 +1537,7 @@ int cmd_top(int argc, const char **argv) | |||
1534 | "number of thread to run event synthesize"), | 1537 | "number of thread to run event synthesize"), |
1535 | OPT_BOOLEAN(0, "namespaces", &opts->record_namespaces, | 1538 | OPT_BOOLEAN(0, "namespaces", &opts->record_namespaces, |
1536 | "Record namespaces events"), | 1539 | "Record namespaces events"), |
1540 | OPTS_EVSWITCH(&top.evswitch), | ||
1537 | OPT_END() | 1541 | OPT_END() |
1538 | }; | 1542 | }; |
1539 | struct evlist *sb_evlist = NULL; | 1543 | struct evlist *sb_evlist = NULL; |
@@ -1567,6 +1571,10 @@ int cmd_top(int argc, const char **argv) | |||
1567 | goto out_delete_evlist; | 1571 | goto out_delete_evlist; |
1568 | } | 1572 | } |
1569 | 1573 | ||
1574 | status = evswitch__init(&top.evswitch, top.evlist, stderr); | ||
1575 | if (status) | ||
1576 | goto out_delete_evlist; | ||
1577 | |||
1570 | if (symbol_conf.report_hierarchy) { | 1578 | if (symbol_conf.report_hierarchy) { |
1571 | /* disable incompatible options */ | 1579 | /* disable incompatible options */ |
1572 | symbol_conf.event_group = false; | 1580 | symbol_conf.event_group = false; |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 2023e0bf6165..dc4bb6e52a83 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #define __PERF_TOP_H 1 | 3 | #define __PERF_TOP_H 1 |
4 | 4 | ||
5 | #include "tool.h" | 5 | #include "tool.h" |
6 | #include "evswitch.h" | ||
6 | #include "annotate.h" | 7 | #include "annotate.h" |
7 | #include <linux/types.h> | 8 | #include <linux/types.h> |
8 | #include <stddef.h> | 9 | #include <stddef.h> |
@@ -18,6 +19,7 @@ struct perf_top { | |||
18 | struct evlist *evlist; | 19 | struct evlist *evlist; |
19 | struct record_opts record_opts; | 20 | struct record_opts record_opts; |
20 | struct annotation_options annotation_opts; | 21 | struct annotation_options annotation_opts; |
22 | struct evswitch evswitch; | ||
21 | /* | 23 | /* |
22 | * Symbols will be added here in perf_event__process_sample and will | 24 | * Symbols will be added here in perf_event__process_sample and will |
23 | * get out after decayed. | 25 | * get out after decayed. |