From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753356AbbFRISX (ORCPT ); Thu, 18 Jun 2015 04:18:23 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57304 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754138AbbFRISM (ORCPT ); Thu, 18 Jun 2015 04:18:12 -0400 Date: Thu, 18 Jun 2015 01:17:56 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, dzickus@redhat.com, bp@suse.de, hpa@zytor.com, namhyung@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@redhat.com, tglx@linutronix.de, fweisbec@gmail.com, eranian@google.com, adrian.hunter@intel.com, dsahern@gmail.com Reply-To: jolsa@redhat.com, tglx@linutronix.de, fweisbec@gmail.com, adrian.hunter@intel.com, eranian@google.com, dsahern@gmail.com, acme@redhat.com, bp@suse.de, dzickus@redhat.com, hpa@zytor.com, namhyung@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf top: Allow disabling/ enabling events dynamicly Git-Commit-ID: 5d484f99aed547e235f2229653c95392a1bc3692 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5d484f99aed547e235f2229653c95392a1bc3692 Gitweb: http://git.kernel.org/tip/5d484f99aed547e235f2229653c95392a1bc3692 Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 17 Jun 2015 16:50:52 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 17 Jun 2015 16:50:52 -0300 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 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 Cc: Adrian Hunter Cc: Borislav Petkov Cc: David Ahern Cc: Don Zickus Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-zq7tnh5462blt2yda0bcxh5b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-top.c | 52 +++++++++++++++++++++++++++++------------- 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 6b98742..72d8a7a 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) more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, 0, top->sym_pcnt_filter, top->print_entries, 4); - if (top->zero) - symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx); - else - symbol__annotate_decay_histogram(symbol, top->sym_evsel->idx); + + if (top->evlist->enabled) { + if (top->zero) + symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx); + else + symbol__annotate_decay_histogram(symbol, top->sym_evsel->idx); + } if (more != 0) printf("%d lines not displayed, maybe increase display entries [e]\n", more); out_unlock: @@ -276,11 +279,13 @@ static void perf_top__print_sym_table(struct perf_top *top) return; } - if (top->zero) { - hists__delete_entries(hists); - } else { - hists__decay_entries(hists, top->hide_user_symbols, - top->hide_kernel_symbols); + if (top->evlist->enabled) { + if (top->zero) { + hists__delete_entries(hists); + } else { + hists__decay_entries(hists, top->hide_user_symbols, + top->hide_kernel_symbols); + } } hists__collapse_resort(hists, NULL); @@ -545,11 +550,13 @@ static void perf_top__sort_new_samples(void *arg) hists = evsel__hists(t->sym_evsel); - if (t->zero) { - hists__delete_entries(hists); - } else { - hists__decay_entries(hists, t->hide_user_symbols, - t->hide_kernel_symbols); + if (t->evlist->enabled) { + if (t->zero) { + hists__delete_entries(hists); + } else { + hists__decay_entries(hists, t->hide_user_symbols, + t->hide_kernel_symbols); + } } hists__collapse_resort(hists, NULL); @@ -579,8 +586,21 @@ static void *display_thread_tui(void *arg) hists->uid_filter_str = top->record_opts.target.uid_str; } - perf_evlist__tui_browse_hists(top->evlist, help, &hbt, top->min_percent, - &top->session->header.env); + while (true) { + int key = perf_evlist__tui_browse_hists(top->evlist, help, &hbt, + top->min_percent, + &top->session->header.env); + + if (key != CTRL('z')) + break; + + perf_evlist__toggle_enable(top->evlist); + /* + * No need to refresh, resort/decay histogram entries + * if we are not collecting samples: + */ + hbt.refresh = top->evlist->enabled ? top->delay_secs : 0; + } done = 1; return NULL; diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index e64893f..8f7c4d4 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, "t Zoom into current Thread\n" "V Verbose (DSO names in callchains, etc)\n" "z Toggle zeroing of samples\n" + "CTRL+z Enable/Disable events\n" "/ Filter symbol by name"; if (browser == NULL) @@ -1900,6 +1901,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, /* Fall thru */ case 'q': case CTRL('c'): + case CTRL('z'): goto out_free_stack; default: continue;