diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-17 15:50:52 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-17 15:50:52 -0400 |
commit | 5d484f99aed547e235f2229653c95392a1bc3692 (patch) | |
tree | 49989d6b2eea50b9c6610d051ed7c1df700755d3 | |
parent | 2b56bcfb6f4bb0aa0813b6ee1dde8f5b23fce5d4 (diff) |
perf top: Allow disabling/enabling events dynamicly
Now it is possible to press CTRL+z at anytime and that will disable the
events being monitored, essentially turning 'top' into 'report', with
pressing CTRL+z again making it enable the events again, returning to
the 'top' behaviour, i.e. dynamic + decaying of older samples.
One may want, for instance, play with:
-d, --delay <n> number of seconds to delay between refreshes
and:
-z, --zero zero history across updates
Plus CTRL+z to see only the events since last zeroing, etc.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-zq7tnh5462blt2yda0bcxh5b@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-top.c | 52 | ||||
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 2 |
2 files changed, 38 insertions, 16 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 6b987424d015..72d8a7ae5986 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -235,10 +235,13 @@ static void perf_top__show_details(struct perf_top *top) | |||
235 | 235 | ||
236 | more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, | 236 | more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, |
237 | 0, top->sym_pcnt_filter, top->print_entries, 4); | 237 | 0, top->sym_pcnt_filter, top->print_entries, 4); |
238 | if (top->zero) | 238 | |
239 | symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx); | 239 | if (top->evlist->enabled) { |
240 | else | 240 | if (top->zero) |
241 | symbol__annotate_decay_histogram(symbol, top->sym_evsel->idx); | 241 | symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx); |
242 | else | ||
243 | symbol__annotate_decay_histogram(symbol, top->sym_evsel->idx); | ||
244 | } | ||
242 | if (more != 0) | 245 | if (more != 0) |
243 | printf("%d lines not displayed, maybe increase display entries [e]\n", more); | 246 | printf("%d lines not displayed, maybe increase display entries [e]\n", more); |
244 | out_unlock: | 247 | out_unlock: |
@@ -276,11 +279,13 @@ static void perf_top__print_sym_table(struct perf_top *top) | |||
276 | return; | 279 | return; |
277 | } | 280 | } |
278 | 281 | ||
279 | if (top->zero) { | 282 | if (top->evlist->enabled) { |
280 | hists__delete_entries(hists); | 283 | if (top->zero) { |
281 | } else { | 284 | hists__delete_entries(hists); |
282 | hists__decay_entries(hists, top->hide_user_symbols, | 285 | } else { |
283 | top->hide_kernel_symbols); | 286 | hists__decay_entries(hists, top->hide_user_symbols, |
287 | top->hide_kernel_symbols); | ||
288 | } | ||
284 | } | 289 | } |
285 | 290 | ||
286 | hists__collapse_resort(hists, NULL); | 291 | hists__collapse_resort(hists, NULL); |
@@ -545,11 +550,13 @@ static void perf_top__sort_new_samples(void *arg) | |||
545 | 550 | ||
546 | hists = evsel__hists(t->sym_evsel); | 551 | hists = evsel__hists(t->sym_evsel); |
547 | 552 | ||
548 | if (t->zero) { | 553 | if (t->evlist->enabled) { |
549 | hists__delete_entries(hists); | 554 | if (t->zero) { |
550 | } else { | 555 | hists__delete_entries(hists); |
551 | hists__decay_entries(hists, t->hide_user_symbols, | 556 | } else { |
552 | t->hide_kernel_symbols); | 557 | hists__decay_entries(hists, t->hide_user_symbols, |
558 | t->hide_kernel_symbols); | ||
559 | } | ||
553 | } | 560 | } |
554 | 561 | ||
555 | hists__collapse_resort(hists, NULL); | 562 | hists__collapse_resort(hists, NULL); |
@@ -579,8 +586,21 @@ static void *display_thread_tui(void *arg) | |||
579 | hists->uid_filter_str = top->record_opts.target.uid_str; | 586 | hists->uid_filter_str = top->record_opts.target.uid_str; |
580 | } | 587 | } |
581 | 588 | ||
582 | perf_evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent, | 589 | while (true) { |
583 | &top->session->header.env); | 590 | int key = perf_evlist__tui_browse_hists(top->evlist, help, &hbt, |
591 | top->min_percent, | ||
592 | &top->session->header.env); | ||
593 | |||
594 | if (key != CTRL('z')) | ||
595 | break; | ||
596 | |||
597 | perf_evlist__toggle_enable(top->evlist); | ||
598 | /* | ||
599 | * No need to refresh, resort/decay histogram entries | ||
600 | * if we are not collecting samples: | ||
601 | */ | ||
602 | hbt.refresh = top->evlist->enabled ? top->delay_secs : 0; | ||
603 | } | ||
584 | 604 | ||
585 | done = 1; | 605 | done = 1; |
586 | return NULL; | 606 | return NULL; |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index e64893f2fd7f..8f7c4d49d327 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1736,6 +1736,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1736 | "t Zoom into current Thread\n" | 1736 | "t Zoom into current Thread\n" |
1737 | "V Verbose (DSO names in callchains, etc)\n" | 1737 | "V Verbose (DSO names in callchains, etc)\n" |
1738 | "z Toggle zeroing of samples\n" | 1738 | "z Toggle zeroing of samples\n" |
1739 | "CTRL+z Enable/Disable events\n" | ||
1739 | "/ Filter symbol by name"; | 1740 | "/ Filter symbol by name"; |
1740 | 1741 | ||
1741 | if (browser == NULL) | 1742 | if (browser == NULL) |
@@ -1900,6 +1901,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1900 | /* Fall thru */ | 1901 | /* Fall thru */ |
1901 | case 'q': | 1902 | case 'q': |
1902 | case CTRL('c'): | 1903 | case CTRL('c'): |
1904 | case CTRL('z'): | ||
1903 | goto out_free_stack; | 1905 | goto out_free_stack; |
1904 | default: | 1906 | default: |
1905 | continue; | 1907 | continue; |