perf tools: Assorted fixes and changes on perf top/report
Namhyung Kim
maintainercover perf tools: Assorted fixes and changes on perf top/report
Hi,
This patchset is a collection of 3 changes on perf top and report tools. I wanted to make them independent, but failed due to laziness. :)
Patch 1 is a fix for -E option handling in perf top. IIUC it only shows a given number of entries. Patch 2 is a simple fix.
Patch 3-5 remove a set of _threaded() functions and also remove unnecessary locking on perf report path. It leads to a small performance gain.
Patch 6-9 implement a long-requested --percent-limit option. I preserve the default value to 0 but an user can set it to a different value using the .perfconfig file.
You can get it from 'perf/top-v1' branch on my tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
Any comments are welcome, thanks.
Namhyung
Namhyung Kim (9):
perf top: Fix -E option behavior
perf top: Fix percent output when no samples collected perf top: Get rid of *_threaded() functions
perf hists: Move locking to its call-sites
perf report: Don't be bothered with locking when adding hist entries perf report: Add --percent-limit option
perf top: Add --percent-limit option
perf report: Add report.percent-limit config variable perf top: Reuse report.percent-limit config variable
tools/perf/Documentation/perf-report.txt | 4 ++ tools/perf/Documentation/perf-top.txt | 4 ++ tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 50 +++++++++++------ tools/perf/builtin-top.c | 73 ++++++++++++++++-------- tools/perf/ui/browsers/hists.c | 95 +++++++++++++++++++++++++++----- tools/perf/ui/gtk/hists.c | 13 ++++- tools/perf/ui/stdio/hist.c | 7 ++- tools/perf/util/hist.c | 50 +++-------------- tools/perf/util/hist.h | 14 ++--- tools/perf/util/top.c | 23 ++++++-- tools/perf/util/top.h | 1 + 12 files changed, 222 insertions(+), 114 deletions(-)
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 1/9 perf top: Fix -E option behavior
From: Namhyung Kim <[email protected]>
The -E/--entries option controls how many lines to be printed on stdio output but it doesn't work as it should be:
If -E option is specified, print that many lines regardless of current window size, if not automatically adjust number of lines printed to fit into the window size.
--- tools/perf/builtin-top.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
tools/perf/builtin-top.c +5 -12
@@ -70,10 +70,11 @@static volatile int done; +#define HEADER_LINE_NR 5 +static void perf_top__update_print_entries (struct perf_top *top) { -if (top->print_entries >9 ) - top->print_entries -=9 ; + top->print_entries = top->winsize.ws_row -HEADER_LINE_NR ; } static void perf_top__sig_winch(int sig __maybe_unused,
@@ -82,13 +83,6 @@ static void perf_top__sig_winch(int sig __maybe_unused,struct perf_top *top = arg;get_term_dimensions (&top->winsize); -if (!top->print_entries - || (top->print_entries+4 ) > top->winsize.ws_row) { - top->print_entries = top->winsize.ws_row; - }else { - top->print_entries +=4 ; - top->winsize.ws_row = top->print_entries; - }perf_top__update_print_entries (top); }
@@ -296,10 +290,10 @@ static void perf_top__print_sym_table(struct perf_top *top) top->hide_user_symbols, top->hide_kernel_symbols);hists__output_recalc_col_len (&top->sym_evsel->hists, - top->winsize.ws_row -3 ); + top->print_entries - printed);putchar ('\n' );hists__fprintf (&top->sym_evsel->hists, false, - top->winsize.ws_row -4 - printed, win_width, stdout); + top->print_entries - printed, win_width, stdout); }static void prompt_integer (int *target,const char *msg)
@@ -477,7 +471,6 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)perf_top__sig_winch (SIGWINCH ,NULL , top);sigaction (SIGWINCH , &act,NULL ); }else { -perf_top__sig_winch (SIGWINCH ,NULL , top);signal (SIGWINCH ,SIG_DFL ); }break ;
Signature · 1 line
1.7.11.7
Re: [PATCH 1/9] perf top: Fix -E option behavior
Quoted 11 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
The -E/--entries option controls how many lines to be printed on stdio output but it doesn't work as it should be:
If -E option is specified, print that many lines regardless of current window size, if not automatically adjust number of lines printed to fit into the window size.
Reported-by Minchan Kim <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
jirka
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf top: Fix -E option behavior
In reply to Namhyung Kimperf top: Fix -E option behavior
Commit-ID: 933cbb1c6c617a6ae167538c2fa503efc9c4a832 Gitweb: http://git.kernel.org/tip/933cbb1c6c617a6ae167538c2fa503efc9c4a832 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:08:59 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:23:59 +0300
perf top: Fix -E option behavior
The -E/--entries option controls how many lines to be printed on stdio output but it doesn't work as it should be:
If -E option is specified, print that many lines regardless of current window size, if not automatically adjust number of lines printed to fit into the window size.
--- tools/perf/builtin-top.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
tools/perf/builtin-top.c +5 -12
@@ -70,10 +70,11 @@static volatile int done; +#define HEADER_LINE_NR 5 +static void perf_top__update_print_entries (struct perf_top *top) { -if (top->print_entries >9 ) - top->print_entries -=9 ; + top->print_entries = top->winsize.ws_row -HEADER_LINE_NR ; } static void perf_top__sig_winch(int sig __maybe_unused,
@@ -82,13 +83,6 @@ static void perf_top__sig_winch(int sig __maybe_unused,struct perf_top *top = arg;get_term_dimensions (&top->winsize); -if (!top->print_entries - || (top->print_entries+4 ) > top->winsize.ws_row) { - top->print_entries = top->winsize.ws_row; - }else { - top->print_entries +=4 ; - top->winsize.ws_row = top->print_entries; - }perf_top__update_print_entries (top); }
@@ -296,10 +290,10 @@ static void perf_top__print_sym_table(struct perf_top *top) top->hide_user_symbols, top->hide_kernel_symbols);hists__output_recalc_col_len (&top->sym_evsel->hists, - top->winsize.ws_row -3 ); + top->print_entries - printed);putchar ('\n' );hists__fprintf (&top->sym_evsel->hists, false, - top->winsize.ws_row -4 - printed, win_width, stdout); + top->print_entries - printed, win_width, stdout); }static void prompt_integer (int *target,const char *msg)
@@ -477,7 +471,6 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)perf_top__sig_winch (SIGWINCH ,NULL , top);sigaction (SIGWINCH , &act,NULL ); }else { -perf_top__sig_winch (SIGWINCH ,NULL , top);signal (SIGWINCH ,SIG_DFL ); }break ;
Namhyung Kim
maintainerPATCH 2/9 perf top: Fix percent output when no samples collected
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
If there's no sample, kernel and exact percent output at the header looked like "-nan%".
--- tools/perf/util/top.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
tools/perf/util/top.c +17 -6
@@ -23,20 +23,31 @@size_t perf_top__header_snprintf (struct perf_top *top,char *bf,size_t size) { -float samples_per_sec = top->samples / top->delay_secs; -float ksamples_per_sec = top->kernel_samples / top->delay_secs; -float esamples_percent = (100.0 * top->exact_samples) / top->samples; +float samples_per_sec; +float ksamples_per_sec; +float esamples_percent;struct perf_record_opts *opts = &top->record_opts;struct perf_target *target = &opts->target;size_t ret =0 ; +if (top->samples) { + samples_per_sec = top->samples / top->delay_secs; + ksamples_per_sec = top->kernel_samples / top->delay_secs; + esamples_percent = (100.0 * top->exact_samples) / top->samples; + }else { + samples_per_sec = ksamples_per_sec = esamples_percent =0.0 ; + } +if (!perf_guest) { +float ksamples_percent =0.0 ; + +if (samples_per_sec) + ksamples_percent = (100.0 * ksamples_per_sec) / + samples_per_sec; ret =SNPRINTF (bf, size," PerfTop:%8.0f irqs/sec kernel:%4.1f%%" " exact: %4.1f%% [" , samples_per_sec, -100.0 - (100.0 * ((samples_per_sec - ksamples_per_sec) / - samples_per_sec)), - esamples_percent); + ksamples_percent, esamples_percent); }else {float us_samples_per_sec = top->us_samples / top->delay_secs;float guest_kernel_samples_per_sec = top->guest_kernel_samples / top->delay_secs;
Signature · 1 line
1.7.11.7
Re: [PATCH 2/9] perf top: Fix percent output when no samples collected
Quoted 10 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
If there's no sample, kernel and exact percent output at the header looked like "-nan%".
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/top.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
jirka
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf top: Fix percent output when no samples collected
In reply to Namhyung Kimperf top: Fix percent output when no samples collected
Commit-ID: 6f29097f45f6c375f2f6a76c589577575c7feb52 Gitweb: http://git.kernel.org/tip/6f29097f45f6c375f2f6a76c589577575c7feb52 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:00 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:23:59 +0300
perf top: Fix percent output when no samples collected
If there's no sample, kernel and exact percent output at the header looked like "-nan%".
--- tools/perf/util/top.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
tools/perf/util/top.c +17 -6
@@ -23,20 +23,31 @@size_t perf_top__header_snprintf (struct perf_top *top,char *bf,size_t size) { -float samples_per_sec = top->samples / top->delay_secs; -float ksamples_per_sec = top->kernel_samples / top->delay_secs; -float esamples_percent = (100.0 * top->exact_samples) / top->samples; +float samples_per_sec; +float ksamples_per_sec; +float esamples_percent;struct perf_record_opts *opts = &top->record_opts;struct perf_target *target = &opts->target;size_t ret =0 ; +if (top->samples) { + samples_per_sec = top->samples / top->delay_secs; + ksamples_per_sec = top->kernel_samples / top->delay_secs; + esamples_percent = (100.0 * top->exact_samples) / top->samples; + }else { + samples_per_sec = ksamples_per_sec = esamples_percent =0.0 ; + } +if (!perf_guest) { +float ksamples_percent =0.0 ; + +if (samples_per_sec) + ksamples_percent = (100.0 * ksamples_per_sec) / + samples_per_sec; ret =SNPRINTF (bf, size," PerfTop:%8.0f irqs/sec kernel:%4.1f%%" " exact: %4.1f%% [" , samples_per_sec, -100.0 - (100.0 * ((samples_per_sec - ksamples_per_sec) / - samples_per_sec)), - esamples_percent); + ksamples_percent, esamples_percent); }else {float us_samples_per_sec = top->us_samples / top->delay_secs;float guest_kernel_samples_per_sec = top->guest_kernel_samples / top->delay_secs;
Namhyung Kim
maintainerPATCH 3/9 perf top: Get rid of *_threaded() functions
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Those _threaded() functions are needed to make hist tree handling thread-safe, but AFAICS the only thing it does is forcing it to use the intermediate 'collapsed' tree. It can be acheived by setting sort__need_collapse to 1 in cmd_top() so no need to keep those _threaded() variants.
--- tools/perf/builtin-top.c | 23 +++++++++++++---------- tools/perf/util/hist.c | 44 ++++++-------------------------------------- tools/perf/util/hist.h | 4 ---- 3 files changed, 19 insertions(+), 52 deletions(-)
tools/perf/builtin-top.c +13 -10
@@ -284,11 +284,11 @@ static void perf_top__print_sym_table(struct perf_top *top)return ; } -hists__collapse_resort_threaded (&top->sym_evsel->hists); -hists__output_resort_threaded (&top->sym_evsel->hists); -hists__decay_entries_threaded (&top->sym_evsel->hists, - top->hide_user_symbols, - top->hide_kernel_symbols); +hists__collapse_resort (&top->sym_evsel->hists); +hists__output_resort (&top->sym_evsel->hists); +hists__decay_entries (&top->sym_evsel->hists, + top->hide_user_symbols, + top->hide_kernel_symbols);hists__output_recalc_col_len (&top->sym_evsel->hists, top->print_entries - printed);putchar ('\n' );
@@ -549,11 +549,11 @@ static void perf_top__sort_new_samples(void *arg)if (t->evlist->selected !=NULL ) t->sym_evsel = t->evlist->selected; -hists__collapse_resort_threaded (&t->sym_evsel->hists); -hists__output_resort_threaded (&t->sym_evsel->hists); -hists__decay_entries_threaded (&t->sym_evsel->hists, - t->hide_user_symbols, - t->hide_kernel_symbols); +hists__collapse_resort (&t->sym_evsel->hists); +hists__output_resort (&t->sym_evsel->hists); +hists__decay_entries (&t->sym_evsel->hists, + t->hide_user_symbols, + t->hide_kernel_symbols); }static void *display_thread_tui (void *arg)
@@ -1126,6 +1126,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)if (setup_sorting () <0 )usage_with_options (top_usage, options); +/* display thread wants entries to be collapsed in a different tree */ + sort__need_collapse =1 ; +if (top.use_stdio) use_browser =0 ;else if (top.use_tui)
tools/perf/util/hist.c +6 -38
97 lines not on this page · raw message
tools/perf/util/hist.h +0 -4
@@ -104,13 +104,9 @@ struct hist_entry *__hists__add_mem_entry(struct hists *self, u64 weight);void hists__output_resort (struct hists *self); -void hists__output_resort_threaded (struct hists *hists);void hists__collapse_resort (struct hists *self); -void hists__collapse_resort_threaded (struct hists *hists);void hists__decay_entries (struct hists *hists,bool zap_user,bool zap_kernel); -void hists__decay_entries_threaded (struct hists *hists,bool zap_user, -bool zap_kernel);void hists__output_recalc_col_len (struct hists *hists,int max_rows);void hists__inc_nr_entries (struct hists *hists,struct hist_entry *h);
Signature · 1 line
1.7.11.7
Re: [PATCH 3/9] perf top: Get rid of *_threaded() functions
Quoted 8 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Those
_threaded()functions are needed to make hist tree handling thread-safe, but AFAICS the only thing it does is forcing it to use the intermediate 'collapsed' tree. It can be acheived by settingsort__need_collapseto 1 incmd_top()so no need to keep those_threaded()variants.
Quoted 6 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-top.c | 23 +++++++++++++---------- tools/perf/util/hist.c | 44 ++++++-------------------------------------- tools/perf/util/hist.h | 4 ---- 3 files changed, 19 insertions(+), 52 deletions(-)
jirka
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf top: Get rid of *_threaded() functions
In reply to Namhyung Kimperf top: Get rid of *_threaded() functions
Commit-ID: 3a5714f8b58913ded4d9e90abdd30e7e5993f863 Gitweb: http://git.kernel.org/tip/3a5714f8b58913ded4d9e90abdd30e7e5993f863 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:01 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:23:59 +0300
perf top: Get rid of *_threaded() functions
Those _threaded() functions are needed to make hist tree handling thread-safe, but AFAICS the only thing it does is forcing it to use the intermediate 'collapsed' tree.
This can be acheived by setting sort__need_collapse to 1 in cmd_top() so no need to keep those _threaded() variants.
--- tools/perf/builtin-top.c | 23 +++++++++++++---------- tools/perf/util/hist.c | 44 ++++++-------------------------------------- tools/perf/util/hist.h | 4 ---- 3 files changed, 19 insertions(+), 52 deletions(-)
tools/perf/builtin-top.c +13 -10
@@ -284,11 +284,11 @@ static void perf_top__print_sym_table(struct perf_top *top)return ; } -hists__collapse_resort_threaded (&top->sym_evsel->hists); -hists__output_resort_threaded (&top->sym_evsel->hists); -hists__decay_entries_threaded (&top->sym_evsel->hists, - top->hide_user_symbols, - top->hide_kernel_symbols); +hists__collapse_resort (&top->sym_evsel->hists); +hists__output_resort (&top->sym_evsel->hists); +hists__decay_entries (&top->sym_evsel->hists, + top->hide_user_symbols, + top->hide_kernel_symbols);hists__output_recalc_col_len (&top->sym_evsel->hists, top->print_entries - printed);putchar ('\n' );
@@ -549,11 +549,11 @@ static void perf_top__sort_new_samples(void *arg)if (t->evlist->selected !=NULL ) t->sym_evsel = t->evlist->selected; -hists__collapse_resort_threaded (&t->sym_evsel->hists); -hists__output_resort_threaded (&t->sym_evsel->hists); -hists__decay_entries_threaded (&t->sym_evsel->hists, - t->hide_user_symbols, - t->hide_kernel_symbols); +hists__collapse_resort (&t->sym_evsel->hists); +hists__output_resort (&t->sym_evsel->hists); +hists__decay_entries (&t->sym_evsel->hists, + t->hide_user_symbols, + t->hide_kernel_symbols); }static void *display_thread_tui (void *arg)
@@ -1126,6 +1126,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)if (setup_sorting () <0 )usage_with_options (top_usage, options); +/* display thread wants entries to be collapsed in a different tree */ + sort__need_collapse =1 ; +if (top.use_stdio) use_browser =0 ;else if (top.use_tui)
tools/perf/util/hist.c +6 -38
97 lines not on this page · raw message
tools/perf/util/hist.h +0 -4
@@ -104,13 +104,9 @@ struct hist_entry *__hists__add_mem_entry(struct hists *self, u64 weight);void hists__output_resort (struct hists *self); -void hists__output_resort_threaded (struct hists *hists);void hists__collapse_resort (struct hists *self); -void hists__collapse_resort_threaded (struct hists *hists);void hists__decay_entries (struct hists *hists,bool zap_user,bool zap_kernel); -void hists__decay_entries_threaded (struct hists *hists,bool zap_user, -bool zap_kernel);void hists__output_recalc_col_len (struct hists *hists,int max_rows);void hists__inc_nr_entries (struct hists *hists,struct hist_entry *h);
Namhyung Kim
maintainerPATCH 4/9 perf hists: Move locking to its call-sites
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
It's a preparation patch to eliminate unneeded locking in the perf report path.
--- tools/perf/builtin-report.c | 26 ++++++++++++++------------ tools/perf/builtin-top.c | 3 +++ tools/perf/util/hist.c | 6 +----- 3 files changed, 18 insertions(+), 17 deletions(-)
tools/perf/builtin-report.c +14 -12
@@ -297,6 +297,7 @@ static int process_sample_event(struct perf_tool *tool, { struct perf_report *rep = container_of(tool, struct perf_report, tool);struct addr_location al; +int ret;if (perf_event__preprocess_sample (event, machine, &al, sample, rep->annotate_init) <0 ) {
@@ -311,28 +312,29 @@ static int process_sample_event(struct perf_tool *tool,if (rep->cpu_list && !test_bit (sample->cpu, rep->cpu_bitmap))return 0 ; +pthread_mutex_lock (&evsel->hists.lock); +if (sort__mode ==SORT_MODE__BRANCH ) { -if (perf_report__add_branch_hist_entry (tool, &al, sample, - evsel, machine)) { + ret =perf_report__add_branch_hist_entry (tool, &al, sample, + evsel, machine); +if (ret <0 )pr_debug ("problem adding lbr entry, skipping event\n" ); -return -1 ; - } }else if (rep->mem_mode ==1 ) { -if (perf_report__add_mem_hist_entry (tool, &al, sample, - evsel, machine, event)) { + ret =perf_report__add_mem_hist_entry (tool, &al, sample, + evsel, machine, event); +if (ret <0 )pr_debug ("problem adding mem entry, skipping event\n" ); -return -1 ; - } }else {if (al.map !=NULL ) al.map->dso->hit =1 ; -if (perf_evsel__add_hist_entry (evsel, &al, sample, machine)) { + ret =perf_evsel__add_hist_entry (evsel, &al, sample, machine); +if (ret <0 )pr_debug ("problem incrementing symbol period, skipping event\n" ); -return -1 ; - } } -return 0 ; +pthread_mutex_unlock (&evsel->hists.lock); + +return ret; } static int process_read_event(struct perf_tool *tool,
tools/perf/builtin-top.c +3 -0
@@ -245,8 +245,11 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel, {struct hist_entry *he; +pthread_mutex_lock (&evsel->hists.lock); he =__hists__add_entry (&evsel->hists, al,NULL , sample->period, sample->weight); +pthread_mutex_unlock (&evsel->hists.lock); +if (he ==NULL )return NULL ;
tools/perf/util/hist.c +1 -5
@@ -347,8 +347,6 @@ static struct hist_entry *add_hist_entry(struct hists *hists,struct hist_entry *he;int cmp; -pthread_mutex_lock (&hists->lock); - p = &hists->entries_in->rb_node;while (*p !=NULL ) {
@@ -394,14 +392,12 @@ static struct hist_entry *add_hist_entry(struct hists *hists, he =hist_entry__new (entry);if (!he) - goto out_unlock; +return NULL ;rb_link_node (&he->rb_node_in, parent, p);rb_insert_color (&he->rb_node_in, hists->entries_in); out:hist_entry__add_cpumode_period (he, al->cpumode, period); -out_unlock: -pthread_mutex_unlock (&hists->lock);return he; }
Signature · 1 line
1.7.11.7
Re: [PATCH 4/9] perf hists: Move locking to its call-sites
Quoted 11 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
It's a preparation patch to eliminate unneeded locking in the perf report path.
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-report.c | 26 ++++++++++++++------------ tools/perf/builtin-top.c | 3 +++ tools/perf/util/hist.c | 6 +----- 3 files changed, 18 insertions(+), 17 deletions(-)
jirka
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf hists: Move locking to its call-sites
In reply to Namhyung Kimperf hists: Move locking to its call-sites
Commit-ID: 27a0dcb7adb52473dd98d285a46b764b9219d303 Gitweb: http://git.kernel.org/tip/27a0dcb7adb52473dd98d285a46b764b9219d303 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:02 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:24:00 +0300
perf hists: Move locking to its call-sites
It's a preparation patch to eliminate unneeded locking in the perf report path.
--- tools/perf/builtin-report.c | 26 ++++++++++++++------------ tools/perf/builtin-top.c | 3 +++ tools/perf/util/hist.c | 6 +----- 3 files changed, 18 insertions(+), 17 deletions(-)
tools/perf/builtin-report.c +14 -12
@@ -297,6 +297,7 @@ static int process_sample_event(struct perf_tool *tool, { struct perf_report *rep = container_of(tool, struct perf_report, tool);struct addr_location al; +int ret;if (perf_event__preprocess_sample (event, machine, &al, sample, rep->annotate_init) <0 ) {
@@ -311,28 +312,29 @@ static int process_sample_event(struct perf_tool *tool,if (rep->cpu_list && !test_bit (sample->cpu, rep->cpu_bitmap))return 0 ; +pthread_mutex_lock (&evsel->hists.lock); +if (sort__mode ==SORT_MODE__BRANCH ) { -if (perf_report__add_branch_hist_entry (tool, &al, sample, - evsel, machine)) { + ret =perf_report__add_branch_hist_entry (tool, &al, sample, + evsel, machine); +if (ret <0 )pr_debug ("problem adding lbr entry, skipping event\n" ); -return -1 ; - } }else if (rep->mem_mode ==1 ) { -if (perf_report__add_mem_hist_entry (tool, &al, sample, - evsel, machine, event)) { + ret =perf_report__add_mem_hist_entry (tool, &al, sample, + evsel, machine, event); +if (ret <0 )pr_debug ("problem adding mem entry, skipping event\n" ); -return -1 ; - } }else {if (al.map !=NULL ) al.map->dso->hit =1 ; -if (perf_evsel__add_hist_entry (evsel, &al, sample, machine)) { + ret =perf_evsel__add_hist_entry (evsel, &al, sample, machine); +if (ret <0 )pr_debug ("problem incrementing symbol period, skipping event\n" ); -return -1 ; - } } -return 0 ; +pthread_mutex_unlock (&evsel->hists.lock); + +return ret; } static int process_read_event(struct perf_tool *tool,
tools/perf/builtin-top.c +3 -0
@@ -245,8 +245,11 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel, {struct hist_entry *he; +pthread_mutex_lock (&evsel->hists.lock); he =__hists__add_entry (&evsel->hists, al,NULL , sample->period, sample->weight); +pthread_mutex_unlock (&evsel->hists.lock); +if (he ==NULL )return NULL ;
tools/perf/util/hist.c +1 -5
@@ -347,8 +347,6 @@ static struct hist_entry *add_hist_entry(struct hists *hists,struct hist_entry *he;int cmp; -pthread_mutex_lock (&hists->lock); - p = &hists->entries_in->rb_node;while (*p !=NULL ) {
@@ -394,14 +392,12 @@ static struct hist_entry *add_hist_entry(struct hists *hists, he =hist_entry__new (entry);if (!he) - goto out_unlock; +return NULL ;rb_link_node (&he->rb_node_in, parent, p);rb_insert_color (&he->rb_node_in, hists->entries_in); out:hist_entry__add_cpumode_period (he, al->cpumode, period); -out_unlock: -pthread_mutex_unlock (&hists->lock);return he; }
Namhyung Kim
maintainerPATCH 5/9 perf report: Don't be bothered with locking when adding hist entries
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The perf report is single-threaded, so no need to grab a lock. Although the fast path of pthread_mutex_[un]lock() is very fast, there's ~3% gain by eliminating it when we have huge sample data.
$ perf record -a -F 100000 -o perf.data.bench -- perf bench sched all $ perf record -e cycles:upp -o perf.data.before -- \
Quoted 1 line
perf report -i perf.data.bench --stdio >
/dev/null
... apply this patch ...
$ perf record -e cycles:upp -o perf.data.after -- \
Quoted 1 line
perf report -i perf.data.bench --stdio >
/dev/null
$ perf diff perf.data.{before,after} | grep pthread
+0.02% libpthread-2.15.so [.] _pthread_cleanup_push_defer
+0.02% libpthread-2.15.so [.] _pthread_cleanup_pop_restore
0.05% -0.05% perf [.] pthread_mutex_unlock@plt
0.05% -0.05% perf [.] pthread_mutex_lock@plt
1.01% -1.01% libpthread-2.15.so [.] pthread_mutex_lock
1.68% -1.68% libpthread-2.15.so [.] __pthread_mutex_unlock_usercnt
0.05% -0.05% libpthread-2.15.so [.] pthread_mutex_unlock--- tools/perf/builtin-report.c | 4 ---- 1 file changed, 4 deletions(-)
tools/perf/builtin-report.c +0 -4
@@ -312,8 +312,6 @@ static int process_sample_event(struct perf_tool *tool,if (rep->cpu_list && !test_bit (sample->cpu, rep->cpu_bitmap))return 0 ; -pthread_mutex_lock (&evsel->hists.lock); -if (sort__mode ==SORT_MODE__BRANCH ) { ret =perf_report__add_branch_hist_entry (tool, &al, sample, evsel, machine);
@@ -332,8 +330,6 @@ static int process_sample_event(struct perf_tool *tool,if (ret <0 )pr_debug ("problem incrementing symbol period, skipping event\n" ); } -pthread_mutex_unlock (&evsel->hists.lock); -return ret; }
Signature · 1 line
1.7.11.7
Re: [PATCH 5/9] perf report: Don't be bothered with locking when adding hist entries
Quoted 21 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
The perf report is single-threaded, so no need to grab a lock. Although the fast path of pthread_mutex_[un]lock() is very fast, there's ~3% gain by eliminating it when we have huge sample data.
$ perf record -a -F 100000 -o perf.data.bench -- perf bench sched all $ perf record -e cycles:upp -o perf.data.before -- \Quoted 1 line
perf report -i perf.data.bench --stdio >
/dev/null... apply this patch ...
$ perf record -e cycles:upp -o perf.data.after -- \Quoted 1 line
perf report -i perf.data.bench --stdio >
/dev/null$ perf diff perf.data.{before,after} | grep pthread +0.02% libpthread-2.15.so [.] _pthread_cleanup_push_defer +0.02% libpthread-2.15.so [.] _pthread_cleanup_pop_restore 0.05% -0.05% perf [.] pthread_mutex_unlock@plt 0.05% -0.05% perf [.] pthread_mutex_lock@plt 1.01% -1.01% libpthread-2.15.so [.] pthread_mutex_lock 1.68% -1.68% libpthread-2.15.so [.] __pthread_mutex_unlock_usercnt 0.05% -0.05% libpthread-2.15.so [.] pthread_mutex_unlock
Quoted 4 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-report.c | 4 ---- 1 file changed, 4 deletions(-)
nice :)
jirka
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf report: Don' t bother locking when adding hist entries
In reply to Namhyung Kimperf report: Don't bother locking when adding hist entries
Commit-ID: f3dd19817e5bbcae81e96571a3d42aa30a1581fb Gitweb: http://git.kernel.org/tip/f3dd19817e5bbcae81e96571a3d42aa30a1581fb Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:03 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:24:00 +0300
perf report: Don't bother locking when adding hist entries
The 'perf report'command is single-threaded, so no need to grab a lock.
Although the fast path of pthread_mutex_[un]lock() is very fast, there's a ~3% gain by eliminating it when we have huge sample data.
$ perf record -a -F 100000 -o perf.data.bench -- perf bench sched all $ perf record -e cycles:upp -o perf.data.before -- \
Quoted 1 line
perf report -i perf.data.bench --stdio >
/dev/null
... apply this patch ...
$ perf record -e cycles:upp -o perf.data.after -- \
Quoted 1 line
perf report -i perf.data.bench --stdio >
/dev/null
$ perf diff perf.data.{before,after} | grep pthread
+0.02% libpthread-2.15.so [.] _pthread_cleanup_push_defer
+0.02% libpthread-2.15.so [.] _pthread_cleanup_pop_restore
0.05% -0.05% perf [.] pthread_mutex_unlock@plt
0.05% -0.05% perf [.] pthread_mutex_lock@plt
1.01% -1.01% libpthread-2.15.so [.] pthread_mutex_lock
1.68% -1.68% libpthread-2.15.so [.] __pthread_mutex_unlock_usercnt
0.05% -0.05% libpthread-2.15.so [.] pthread_mutex_unlock--- tools/perf/builtin-report.c | 4 ---- 1 file changed, 4 deletions(-)
tools/perf/builtin-report.c +0 -4
@@ -312,8 +312,6 @@ static int process_sample_event(struct perf_tool *tool,if (rep->cpu_list && !test_bit (sample->cpu, rep->cpu_bitmap))return 0 ; -pthread_mutex_lock (&evsel->hists.lock); -if (sort__mode ==SORT_MODE__BRANCH ) { ret =perf_report__add_branch_hist_entry (tool, &al, sample, evsel, machine);
@@ -332,8 +330,6 @@ static int process_sample_event(struct perf_tool *tool,if (ret <0 )pr_debug ("problem incrementing symbol period, skipping event\n" ); } -pthread_mutex_unlock (&evsel->hists.lock); -return ret; }
Namhyung Kim
maintainerPATCH 6/9 perf report: Add --percent-limit option
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The --percent-limit option is for not showing small overheaded entries in the output. Maybe we want to set a certain default value like 0.1.
--- tools/perf/Documentation/perf-report.txt | 4 ++ tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 21 +++++++-- tools/perf/builtin-top.c | 4 +- tools/perf/ui/browsers/hists.c | 79 +++++++++++++++++++++++++++----- tools/perf/ui/gtk/hists.c | 13 ++++-- tools/perf/ui/stdio/hist.c | 7 ++- tools/perf/util/hist.h | 10 ++-- 8 files changed, 115 insertions(+), 25 deletions(-)
tools/perf/Documentation/perf-report.txt +4 -0
@@ -210,6 +210,10 @@ OPTIONS Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle. +--percent-limit:: + Do not show entries which have an overhead under that percent. + (Default: 0). + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-annotate[1]
tools/perf/builtin-diff.c +1 -1
@@ -457,7 +457,7 @@ static void hists__process(struct hists *old, struct hists *new)hists__output_resort (new); } -hists__fprintf (new, true,0 ,0 , stdout); +hists__fprintf (new, true,0 ,0 ,0 , stdout); }static int __cmd_diff (void )
tools/perf/builtin-report.c +17 -4
@@ -52,6 +52,7 @@ struct perf_report {symbol_filter_t annotate_init;const char *cpu_list;const char *symbol_filter_str; +float min_percent;DECLARE_BITMAP (cpu_bitmap,MAX_NR_CPUS ); };
@@ -456,7 +457,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,continue ;hists__fprintf_nr_sample_events (rep, hists, evname, stdout); -hists__fprintf (hists, true,0 ,0 , stdout); +hists__fprintf (hists, true,0 ,0 , rep->min_percent, stdout);fprintf (stdout,"\n\n" ); }
@@ -575,8 +576,8 @@ static int __cmd_report(struct perf_report *rep)if (use_browser >0 ) {if (use_browser ==1 ) { ret =perf_evlist__tui_browse_hists (session->evlist, - help, -NULL , + help,NULL , + rep->min_percent, &session->header.env);/* * Usually "ret" is the last pressed key, and we only
@@ -587,7 +588,7 @@ static int __cmd_report(struct perf_report *rep) }else if (use_browser ==2 ) {perf_evlist__gtk_browse_hists (session->evlist, help, -NULL ); +NULL , rep->min_percent); } }else perf_evlist__tty_browse_hists (session->evlist, rep, help);
@@ -698,6 +699,16 @@ parse_branch_mode(const struct option *opt __maybe_unused,return 0 ; } +static int +parse_percent_limit (const struct option *opt,const char *str, +int unset__maybe_unused ) +{ +struct perf_report *rep = opt->value; + + rep->min_percent =strtof (str,NULL ); +return 0 ; +} +int cmd_report (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_session *session;
@@ -807,6 +818,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"demangle" , &symbol_conf.demangle,"Disable symbol demangling" ),OPT_BOOLEAN (0 ,"mem-mode" , &report.mem_mode,"mem access profile" ), +OPT_CALLBACK (0 ,"percent-limit" , &report,"percent" , +"Don't show entries under that percent" , parse_percent_limit), OPT_END() };
tools/perf/builtin-top.c +2 -2
@@ -296,7 +296,7 @@ static void perf_top__print_sym_table(struct perf_top *top) top->print_entries - printed);putchar ('\n' );hists__fprintf (&top->sym_evsel->hists, false, - top->print_entries - printed, win_width, stdout); + top->print_entries - printed, win_width,0 , stdout); }static void prompt_integer (int *target,const char *msg)
@@ -580,7 +580,7 @@ static void *display_thread_tui(void *arg)list_for_each_entry (pos, &top->evlist->entries, node) pos->hists.uid_filter_str = top->record_opts.target.uid_str; -perf_evlist__tui_browse_hists (top->evlist, help, &hbt, +perf_evlist__tui_browse_hists (top->evlist, help, &hbt,0 , &top->session->header.env); done =1 ;
tools/perf/ui/browsers/hists.c +68 -11
217 lines not on this page · raw message
tools/perf/ui/gtk/hists.c +10 -3
@@ -124,7 +124,8 @@ void perf_gtk__init_hpp(void) perf_gtk__hpp_color_overhead_guest_us; } -static void perf_gtk__show_hists (GtkWidget *window,struct hists *hists) +static void perf_gtk__show_hists (GtkWidget *window,struct hists *hists, +float min_pcnt) {struct perf_hpp_fmt *fmt;GType col_types[MAX_COLUMNS ];
@@ -189,10 +190,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)for (nd =rb_first (&hists->entries); nd; nd =rb_next (nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);GtkTreeIter iter; +float percent = h->stat.period *100.0 / + hists->stats.total_period;if (h->filtered)continue ; +if (percent < min_pcnt) +continue ; +gtk_list_store_append (store, &iter); col_idx =0 ;
@@ -222,7 +228,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -struct hist_browser_timer *hbt__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt) {struct perf_evsel *pos;GtkWidget *vbox;
@@ -286,7 +293,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC); -perf_gtk__show_hists (scrolled_window, hists); +perf_gtk__show_hists (scrolled_window, hists, min_pcnt); tab_label =gtk_label_new (evname);
tools/perf/ui/stdio/hist.c +6 -1
@@ -334,7 +334,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, }size_t hists__fprintf (struct hists *hists,bool show_header,int max_rows, -int max_cols,FILE *fp) +int max_cols,float min_pcnt,FILE *fp) {struct perf_hpp_fmt *fmt;struct sort_entry *se;
@@ -440,10 +440,15 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, print_entries:for (nd =rb_first (&hists->entries); nd; nd =rb_next (nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); +float percent = h->stat.period *100.0 / + hists->stats.total_period;if (h->filtered)continue ; +if (percent < min_pcnt) +continue ; + ret +=hist_entry__fprintf (h, max_cols, hists, fp);if (max_rows && ++nr_rows >= max_rows)
tools/perf/util/hist.h +7 -3
@@ -115,7 +115,7 @@ void events_stats__inc(struct events_stats *stats, u32 type);size_t events_stats__fprintf (struct events_stats *stats,FILE *fp);size_t hists__fprintf (struct hists *self,bool show_header,int max_rows, -int max_cols,FILE *fp); +int max_cols,float min_pcnt,FILE *fp);int hist_entry__inc_addr_samples (struct hist_entry *self,int evidx,u64 addr);int hist_entry__annotate (struct hist_entry *self,size_t privsize);
@@ -195,6 +195,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help,struct hist_browser_timer *hbt, +float min_pcnt,struct perf_session_env *env);int script_browse (const char *script_opt);#else
@@ -202,6 +203,7 @@ static inlineint perf_evlist__tui_browse_hists (struct perf_evlist *evlist__maybe_unused ,const char *help__maybe_unused ,struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt__maybe_unused ,struct perf_session_env *env__maybe_unused ) {return 0 ;
@@ -229,12 +231,14 @@ static inline int script_browse(const char *script_opt __maybe_unused)#ifdef GTK2_SUPPORT int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -struct hist_browser_timer *hbt__maybe_unused ); +struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt);#else static inline int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist__maybe_unused ,const char *help__maybe_unused , -struct hist_browser_timer *hbt__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt__maybe_unused ) {return 0 ; }
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf report: Add --percent-limit option
perf report: Add --percent-limit option
Commit-ID: 064f19815c4e99e8b22bc3c5f4d7f4e0b96d226a Gitweb: http://git.kernel.org/tip/064f19815c4e99e8b22bc3c5f4d7f4e0b96d226a Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:04 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:24:01 +0300
perf report: Add --percent-limit option
The --percent-limit option is for not showing small overhead entries in the output. Maybe we want to set a certain default value like 0.1.
--- tools/perf/Documentation/perf-report.txt | 4 ++ tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 21 +++++++-- tools/perf/builtin-top.c | 4 +- tools/perf/ui/browsers/hists.c | 79 +++++++++++++++++++++++++++----- tools/perf/ui/gtk/hists.c | 13 ++++-- tools/perf/ui/stdio/hist.c | 7 ++- tools/perf/util/hist.h | 10 ++-- 8 files changed, 115 insertions(+), 25 deletions(-)
tools/perf/Documentation/perf-report.txt +4 -0
@@ -210,6 +210,10 @@ OPTIONS Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle. +--percent-limit:: + Do not show entries which have an overhead under that percent. + (Default: 0). + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-annotate[1]
tools/perf/builtin-diff.c +1 -1
@@ -457,7 +457,7 @@ static void hists__process(struct hists *old, struct hists *new)hists__output_resort (new); } -hists__fprintf (new, true,0 ,0 , stdout); +hists__fprintf (new, true,0 ,0 ,0 , stdout); }static int __cmd_diff (void )
tools/perf/builtin-report.c +17 -4
@@ -52,6 +52,7 @@ struct perf_report {symbol_filter_t annotate_init;const char *cpu_list;const char *symbol_filter_str; +float min_percent;DECLARE_BITMAP (cpu_bitmap,MAX_NR_CPUS ); };
@@ -456,7 +457,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,continue ;hists__fprintf_nr_sample_events (rep, hists, evname, stdout); -hists__fprintf (hists, true,0 ,0 , stdout); +hists__fprintf (hists, true,0 ,0 , rep->min_percent, stdout);fprintf (stdout,"\n\n" ); }
@@ -575,8 +576,8 @@ static int __cmd_report(struct perf_report *rep)if (use_browser >0 ) {if (use_browser ==1 ) { ret =perf_evlist__tui_browse_hists (session->evlist, - help, -NULL , + help,NULL , + rep->min_percent, &session->header.env);/* * Usually "ret" is the last pressed key, and we only
@@ -587,7 +588,7 @@ static int __cmd_report(struct perf_report *rep) }else if (use_browser ==2 ) {perf_evlist__gtk_browse_hists (session->evlist, help, -NULL ); +NULL , rep->min_percent); } }else perf_evlist__tty_browse_hists (session->evlist, rep, help);
@@ -698,6 +699,16 @@ parse_branch_mode(const struct option *opt __maybe_unused,return 0 ; } +static int +parse_percent_limit (const struct option *opt,const char *str, +int unset__maybe_unused ) +{ +struct perf_report *rep = opt->value; + + rep->min_percent =strtof (str,NULL ); +return 0 ; +} +int cmd_report (int argc,const char **argv,const char *prefix__maybe_unused ) {struct perf_session *session;
@@ -807,6 +818,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"demangle" , &symbol_conf.demangle,"Disable symbol demangling" ),OPT_BOOLEAN (0 ,"mem-mode" , &report.mem_mode,"mem access profile" ), +OPT_CALLBACK (0 ,"percent-limit" , &report,"percent" , +"Don't show entries under that percent" , parse_percent_limit), OPT_END() };
tools/perf/builtin-top.c +2 -2
@@ -296,7 +296,7 @@ static void perf_top__print_sym_table(struct perf_top *top) top->print_entries - printed);putchar ('\n' );hists__fprintf (&top->sym_evsel->hists, false, - top->print_entries - printed, win_width, stdout); + top->print_entries - printed, win_width,0 , stdout); }static void prompt_integer (int *target,const char *msg)
@@ -580,7 +580,7 @@ static void *display_thread_tui(void *arg)list_for_each_entry (pos, &top->evlist->entries, node) pos->hists.uid_filter_str = top->record_opts.target.uid_str; -perf_evlist__tui_browse_hists (top->evlist, help, &hbt, +perf_evlist__tui_browse_hists (top->evlist, help, &hbt,0 , &top->session->header.env); done =1 ;
tools/perf/ui/browsers/hists.c +68 -11
217 lines not on this page · raw message
tools/perf/ui/gtk/hists.c +10 -3
@@ -124,7 +124,8 @@ void perf_gtk__init_hpp(void) perf_gtk__hpp_color_overhead_guest_us; } -static void perf_gtk__show_hists (GtkWidget *window,struct hists *hists) +static void perf_gtk__show_hists (GtkWidget *window,struct hists *hists, +float min_pcnt) {struct perf_hpp_fmt *fmt;GType col_types[MAX_COLUMNS ];
@@ -189,10 +190,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)for (nd =rb_first (&hists->entries); nd; nd =rb_next (nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);GtkTreeIter iter; +float percent = h->stat.period *100.0 / + hists->stats.total_period;if (h->filtered)continue ; +if (percent < min_pcnt) +continue ; +gtk_list_store_append (store, &iter); col_idx =0 ;
@@ -222,7 +228,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -struct hist_browser_timer *hbt__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt) {struct perf_evsel *pos;GtkWidget *vbox;
@@ -286,7 +293,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC); -perf_gtk__show_hists (scrolled_window, hists); +perf_gtk__show_hists (scrolled_window, hists, min_pcnt); tab_label =gtk_label_new (evname);
tools/perf/ui/stdio/hist.c +6 -1
@@ -334,7 +334,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, }size_t hists__fprintf (struct hists *hists,bool show_header,int max_rows, -int max_cols,FILE *fp) +int max_cols,float min_pcnt,FILE *fp) {struct perf_hpp_fmt *fmt;struct sort_entry *se;
@@ -440,10 +440,15 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, print_entries:for (nd =rb_first (&hists->entries); nd; nd =rb_next (nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); +float percent = h->stat.period *100.0 / + hists->stats.total_period;if (h->filtered)continue ; +if (percent < min_pcnt) +continue ; + ret +=hist_entry__fprintf (h, max_cols, hists, fp);if (max_rows && ++nr_rows >= max_rows)
tools/perf/util/hist.h +7 -3
@@ -115,7 +115,7 @@ void events_stats__inc(struct events_stats *stats, u32 type);size_t events_stats__fprintf (struct events_stats *stats,FILE *fp);size_t hists__fprintf (struct hists *self,bool show_header,int max_rows, -int max_cols,FILE *fp); +int max_cols,float min_pcnt,FILE *fp);int hist_entry__inc_addr_samples (struct hist_entry *self,int evidx,u64 addr);int hist_entry__annotate (struct hist_entry *self,size_t privsize);
@@ -195,6 +195,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,int perf_evlist__tui_browse_hists (struct perf_evlist *evlist,const char *help,struct hist_browser_timer *hbt, +float min_pcnt,struct perf_session_env *env);int script_browse (const char *script_opt);#else
@@ -202,6 +203,7 @@ static inlineint perf_evlist__tui_browse_hists (struct perf_evlist *evlist__maybe_unused ,const char *help__maybe_unused ,struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt__maybe_unused ,struct perf_session_env *env__maybe_unused ) {return 0 ;
@@ -229,12 +231,14 @@ static inline int script_browse(const char *script_opt __maybe_unused)#ifdef GTK2_SUPPORT int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help, -struct hist_browser_timer *hbt__maybe_unused ); +struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt);#else static inline int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist__maybe_unused ,const char *help__maybe_unused , -struct hist_browser_timer *hbt__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused , +float min_pcnt__maybe_unused ) {return 0 ; }
Namhyung Kim
maintainerPATCH 7/9 perf top: Add --percent-limit option
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The --percent-limit option is for not showing small overheaded entries in the output.
--- tools/perf/Documentation/perf-top.txt | 4 ++++ tools/perf/builtin-top.c | 17 +++++++++++++++-- tools/perf/ui/browsers/hists.c | 16 ++++++++++++++-- tools/perf/util/top.h | 1 + 4 files changed, 34 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-top.txt +4 -0
@@ -155,6 +155,10 @@ Default is to monitor all CPUS. Default: fractal,0.5,callee. +--percent-limit:: + Do not show entries which have an overhead under that percent. + (Default: 0). + INTERACTIVE PROMPTING KEYS --------------------------
tools/perf/builtin-top.c +15 -2
@@ -296,7 +296,8 @@ static void perf_top__print_sym_table(struct perf_top *top) top->print_entries - printed);putchar ('\n' );hists__fprintf (&top->sym_evsel->hists, false, - top->print_entries - printed, win_width,0 , stdout); + top->print_entries - printed, win_width, + top->min_percent, stdout); }static void prompt_integer (int *target,const char *msg)
@@ -580,7 +581,7 @@ static void *display_thread_tui(void *arg)list_for_each_entry (pos, &top->evlist->entries, node) pos->hists.uid_filter_str = top->record_opts.target.uid_str; -perf_evlist__tui_browse_hists (top->evlist, help, &hbt,0 , +perf_evlist__tui_browse_hists (top->evlist, help, &hbt, top->min_percent, &top->session->header.env); done =1 ;
@@ -1021,6 +1022,16 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)return record_parse_callchain_opt (opt, arg, unset); } +static int +parse_percent_limit (const struct option *opt,const char *arg, +int unset__maybe_unused ) +{ +struct perf_top *top = opt->value; + + top->min_percent =strtof (arg,NULL ); +return 0 ; +} +int cmd_top (int argc,const char **argv,const char *prefix__maybe_unused ) {int status;
@@ -1106,6 +1117,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)OPT_STRING ('M' ,"disassembler-style" , &disassembler_style,"disassembler style" ,"Specify disassembler style (e.g. -M intel for intel syntax)" ),OPT_STRING ('u' ,"uid" , &target->uid_str,"user" ,"user to profile" ), +OPT_CALLBACK (0 ,"percent-limit" , &top,"percent" , +"Don't show entries under that percent" , parse_percent_limit),OPT_END () }; const char * const top_usage[] = {
tools/perf/ui/browsers/hists.c +14 -2
@@ -310,6 +310,8 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) "Or reduce the sampling frequency."); } +static void hist_browser__update_pcnt_entries (struct hist_browser *hb); +static int hist_browser__run (struct hist_browser *browser,const char *ev_name,struct hist_browser_timer *hbt) {
@@ -333,9 +335,18 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name, key =ui_browser__run (&browser->b, delay_secs);switch (key) { -case K_TIMER : +case K_TIMER : { +u64 nr_entries; hbt->timer (hbt->arg); -ui_browser__update_nr_entries (&browser->b, browser->hists->nr_entries); + +if (browser->min_pcnt) { +hist_browser__update_pcnt_entries (browser); + nr_entries = browser->nr_pcnt_entries; + }else { + nr_entries = browser->hists->nr_entries; + } + +ui_browser__update_nr_entries (&browser->b, nr_entries);if (browser->hists->stats.nr_lost_warned != browser->hists->stats.nr_events[PERF_RECORD_LOST ]) {
@@ -347,6 +358,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name,hists__browser_title (browser->hists, title,sizeof (title), ev_name);ui_browser__show_title (&browser->b, title);continue ; + }case 'D' : {/* Debug */ static int seq; struct hist_entry *h = rb_entry(browser->b.top,
tools/perf/util/top.h +1 -0
@@ -36,6 +36,7 @@ struct perf_top {int realtime_prio;int sym_pcnt_filter;const char *sym_filter; +float min_percent; };size_t perf_top__header_snprintf (struct perf_top *top,char *bf,size_t size);
Signature · 1 line
1.7.11.7
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf top: Add --percent-limit option
perf top: Add --percent-limit option
Commit-ID: fa5df94350510571cbe825f333996f57223b3cd2 Gitweb: http://git.kernel.org/tip/fa5df94350510571cbe825f333996f57223b3cd2 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:05 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:24:01 +0300
perf top: Add --percent-limit option
The --percent-limit option is for not showing small overhead entries in the output.
--- tools/perf/Documentation/perf-top.txt | 4 ++++ tools/perf/builtin-top.c | 17 +++++++++++++++-- tools/perf/ui/browsers/hists.c | 16 ++++++++++++++-- tools/perf/util/top.h | 1 + 4 files changed, 34 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-top.txt +4 -0
@@ -155,6 +155,10 @@ Default is to monitor all CPUS. Default: fractal,0.5,callee. +--percent-limit:: + Do not show entries which have an overhead under that percent. + (Default: 0). + INTERACTIVE PROMPTING KEYS --------------------------
tools/perf/builtin-top.c +15 -2
@@ -296,7 +296,8 @@ static void perf_top__print_sym_table(struct perf_top *top) top->print_entries - printed);putchar ('\n' );hists__fprintf (&top->sym_evsel->hists, false, - top->print_entries - printed, win_width,0 , stdout); + top->print_entries - printed, win_width, + top->min_percent, stdout); }static void prompt_integer (int *target,const char *msg)
@@ -580,7 +581,7 @@ static void *display_thread_tui(void *arg)list_for_each_entry (pos, &top->evlist->entries, node) pos->hists.uid_filter_str = top->record_opts.target.uid_str; -perf_evlist__tui_browse_hists (top->evlist, help, &hbt,0 , +perf_evlist__tui_browse_hists (top->evlist, help, &hbt, top->min_percent, &top->session->header.env); done =1 ;
@@ -1021,6 +1022,16 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)return record_parse_callchain_opt (opt, arg, unset); } +static int +parse_percent_limit (const struct option *opt,const char *arg, +int unset__maybe_unused ) +{ +struct perf_top *top = opt->value; + + top->min_percent =strtof (arg,NULL ); +return 0 ; +} +int cmd_top (int argc,const char **argv,const char *prefix__maybe_unused ) {int status;
@@ -1106,6 +1117,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)OPT_STRING ('M' ,"disassembler-style" , &disassembler_style,"disassembler style" ,"Specify disassembler style (e.g. -M intel for intel syntax)" ),OPT_STRING ('u' ,"uid" , &target->uid_str,"user" ,"user to profile" ), +OPT_CALLBACK (0 ,"percent-limit" , &top,"percent" , +"Don't show entries under that percent" , parse_percent_limit),OPT_END () }; const char * const top_usage[] = {
tools/perf/ui/browsers/hists.c +14 -2
@@ -310,6 +310,8 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) "Or reduce the sampling frequency."); } +static void hist_browser__update_pcnt_entries (struct hist_browser *hb); +static int hist_browser__run (struct hist_browser *browser,const char *ev_name,struct hist_browser_timer *hbt) {
@@ -333,9 +335,18 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name, key =ui_browser__run (&browser->b, delay_secs);switch (key) { -case K_TIMER : +case K_TIMER : { +u64 nr_entries; hbt->timer (hbt->arg); -ui_browser__update_nr_entries (&browser->b, browser->hists->nr_entries); + +if (browser->min_pcnt) { +hist_browser__update_pcnt_entries (browser); + nr_entries = browser->nr_pcnt_entries; + }else { + nr_entries = browser->hists->nr_entries; + } + +ui_browser__update_nr_entries (&browser->b, nr_entries);if (browser->hists->stats.nr_lost_warned != browser->hists->stats.nr_events[PERF_RECORD_LOST ]) {
@@ -347,6 +358,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name,hists__browser_title (browser->hists, title,sizeof (title), ev_name);ui_browser__show_title (&browser->b, title);continue ; + }case 'D' : {/* Debug */ static int seq; struct hist_entry *h = rb_entry(browser->b.top,
tools/perf/util/top.h +1 -0
@@ -36,6 +36,7 @@ struct perf_top {int realtime_prio;int sym_pcnt_filter;const char *sym_filter; +float min_percent; };size_t perf_top__header_snprintf (struct perf_top *top,char *bf,size_t size);
Namhyung Kim
maintainerPATCH 8/9 perf report: Add report.percent-limit config variable
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Now an user can set a default value of --percent-limit option into the perfconfig file.
$ cat ~/.perfconfig [report] percent-limit = 0.1
--- tools/perf/builtin-report.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +6 -1
@@ -62,6 +62,11 @@ static int perf_report_config(const char *var, const char *value, void *cb) symbol_conf.event_group =perf_config_bool (var, value);return 0 ; } +if (!strcmp (var,"report.percent-limit" )) { +struct perf_report *rep = cb; + rep->min_percent =strtof (value,NULL ); +return 0 ; + }return perf_default_config (var, value, cb); }
@@ -823,7 +828,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) OPT_END() }; -perf_config (perf_report_config,NULL ); +perf_config (perf_report_config, &report); argc =parse_options (argc, argv, options, report_usage,0 );
Signature · 1 line
1.7.11.7
Re: [PATCH 8/9] perf report: Add report.percent-limit config variable
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Now an user can set a default value of --percent-limit option into the perfconfig file.
Quoted 7 lines
$ cat ~/.perfconfig [report] percent-limit = 0.1Cc Andi Kleen <[email protected]>Cc Pekka Enberg <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
I'm not totally convinced this is useful. The limit is about "what is significant" and that depends on what you are trying to measure. There's an (absolute) lower limit somewhere between 0.1 and 1.0 but I think we can just pick a reasonable default and let people use the command line switch if they want to override it.
Pekka
Namhyung Kim
maintainerRe: [PATCH 8/9] perf report: Add report.percent-limit config variable
Hi Pekka,
Quoted 14 lines · Pekka Enberg
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Now an user can set a default value of --percent-limit option into the perfconfig file.
Quoted 7 lines
$ cat ~/.perfconfig [report] percent-limit = 0.1Cc Andi Kleen <[email protected]>Cc Pekka Enberg <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Quoted 5 lines
I'm not totally convinced this is useful. The limit is about "what is significant" and that depends on what you are trying to measure. There's an (absolute) lower limit somewhere between 0.1 and 1.0 but I think we can just pick a reasonable default and let people use the command line switch if they want to override it.
If the limit depends on what is measured, what should be the reasonable default value? I just don't know..
I agree that we should pick a default but the config variable doesn't harm anything in this case too. Some users might not agree with our default for their cases and want to use other value.
But I'm not insist on it so strongly, I just gave another way.. ;)
Thanks,
Namhyung
Pekka Enberg
Acked-byRe: [PATCH 8/9] perf report: Add report.percent-limit config variable
Quoted 23 lines · Namhyung Kim
Hi Pekka,
Quoted 14 lines · Pekka Enberg
Quoted 5 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Now an user can set a default value of --percent-limit option into the perfconfig file.
Quoted 7 lines
$ cat ~/.perfconfig [report] percent-limit = 0.1Cc Andi Kleen <[email protected]>Cc Pekka Enberg <[email protected]>Signed-off-by Namhyung Kim <[email protected]>Quoted 5 lines
I'm not totally convinced this is useful. The limit is about "what is significant" and that depends on what you are trying to measure. There's an (absolute) lower limit somewhere between 0.1 and 1.0 but I think we can just pick a reasonable default and let people use the command line switch if they want to override it.
Quoted 8 lines
If the limit depends on what is measured, what should be the reasonable default value? I just don't know..
I agree that we should pick a default but the config variable doesn't harm anything in this case too. Some users might not agree with our default for their cases and want to use other value.
But I'm not insist on it so strongly, I just gave another way.. ;)
I'd go for default value of 1.0 first and if people complain, drop it to 0.1. But I guess it's safer to add your config option thingy just in case:
Pekka
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf report: Add report.percent-limit config variable
In reply to Namhyung Kimperf report: Add report.percent-limit config variable
Commit-ID: eec574e6bc3ee4558d4a282e0e3e1bd6dd0ad67b Gitweb: http://git.kernel.org/tip/eec574e6bc3ee4558d4a282e0e3e1bd6dd0ad67b Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 14 May 2013 11:09:06 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2013 16:24:02 +0300
perf report: Add report.percent-limit config variable
Now an user can set a default value of --percent-limit option into the perfconfig file.
$ cat ~/.perfconfig [report] percent-limit = 0.1
--- tools/perf/builtin-report.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +6 -1
@@ -62,6 +62,11 @@ static int perf_report_config(const char *var, const char *value, void *cb) symbol_conf.event_group =perf_config_bool (var, value);return 0 ; } +if (!strcmp (var,"report.percent-limit" )) { +struct perf_report *rep = cb; + rep->min_percent =strtof (value,NULL ); +return 0 ; + }return perf_default_config (var, value, cb); }
@@ -823,7 +828,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) OPT_END() }; -perf_config (perf_report_config,NULL ); +perf_config (perf_report_config, &report); argc =parse_options (argc, argv, options, report_usage,0 );
Namhyung Kim
maintainerPATCH 9/9 perf top: Reuse report.percent-limit config variable
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Make the config variable also works for perf top.
--- tools/perf/builtin-top.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/perf/builtin-top.c +15 -0
@@ -1032,6 +1032,19 @@ parse_percent_limit(const struct option *opt, const char *arg,return 0 ; } +static int perf_top_config (const char *var,const char *value,void *cb) +{ +/* share report config variables */ +if (!strcmp (var,"report.percent-limit" )) { +struct perf_top *top = cb; + + top->min_percent =strtof (value,NULL ); +return 0 ; + } + +return perf_default_config (var, value, cb); +} +int cmd_top (int argc,const char **argv,const char *prefix__maybe_unused ) {int status;
@@ -1132,6 +1145,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) symbol_conf.exclude_other = false; +perf_config (perf_top_config, &top); + argc =parse_options (argc, argv, options, top_usage,0 );if (argc)usage_with_options (top_usage, options);
Signature · 1 line
1.7.11.7