perf tools: A small random cleanup and fixups
Namhyung Kim
maintainercover perf tools: A small random cleanup and fixups
Hello,
This is a just random collection of small cleanup and fixes that was needed (or found) for my work. I'd like to share it before posting the real work as it's independent change and the work can be quite large.. ;-)
Thanks,
Namhyung
Namhyung Kim (7):
perf report: Get rid of report__inc_stat()
perf report: Show progress bar for output resorting perf ui/tui: Print backtrace symbols when segfault occurred perf diff: Fix to sort by baseline field by default perf diff: Get rid of hists__compute_resort() perf tools: Append callchains only when requested perf tools: Set attr.task bit for a tracking event
tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 84 +++++++++++++++++++-------------------- tools/perf/builtin-report.c | 40 ++++++++++++------- tools/perf/builtin-top.c | 4 +- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_output.c | 10 ++--- tools/perf/ui/tui/setup.c | 26 +++++++++++- tools/perf/util/evsel.c | 1 + tools/perf/util/hist.c | 19 +++++++-- tools/perf/util/hist.h | 2 +- 11 files changed, 116 insertions(+), 76 deletions(-)
Signature · 1 line
2.1.3
Namhyung Kim
maintainerPATCH 1/7 perf report: Get rid of report__inc_stat()
The report__inc_stat() is to collect number of hist entries in the session in order to calculate the max size of progess bar. It'd be better if it does during addition of hist entries so that it can be used by other places too.
--- tools/perf/builtin-report.c | 16 +++------------- tools/perf/util/hist.c | 2 ++ 2 files changed, 5 insertions(+), 13 deletions(-)
tools/perf/builtin-report.c +3 -13
@@ -86,17 +86,6 @@ static int report__config(const char *var, const char *value, void *cb)return perf_default_config (var, value, cb); } -static void report__inc_stats (struct report *rep,struct hist_entry *he) -{ -/* -* The @he is either of a newly created one or an existing one -* merging current sample. We only want to count a new one so -* checking ->nr_events being 1. -*/ -if (he->stat.nr_events ==1 ) - rep->nr_entries++; -} -static int hist_iter__report_callback (struct hist_entry_iter *iter,struct addr_location *al,bool single,void *arg)
@@ -108,8 +97,6 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,struct mem_info *mi;struct branch_info *bi; -report__inc_stats (rep, he); -if (!ui__has_annotation ())return 0 ;
@@ -486,6 +473,9 @@ static int __cmd_report(struct report *rep)report__warn_kptr_restrict (rep); +evlist__for_each (session->evlist, pos) + rep->nr_entries +=evsel__hists (pos)->nr_entries; +if (use_browser ==0 ) {if (verbose >3 )perf_session__fprintf (session, stdout);
tools/perf/util/hist.c +2 -0
@@ -428,6 +428,8 @@ static struct hist_entry *add_hist_entry(struct hists *hists,if (!he)return NULL ; + hists->nr_entries++; +rb_link_node (&he->rb_node_in, parent, p);rb_insert_color (&he->rb_node_in, hists->entries_in); out:
Signature · 1 line
2.1.3
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf report: Get rid of report__inc_stat()
perf report: Get rid of report__inc_stat()
Commit-ID: 590cd344e2099c7b040b29d3a711b4c26358def5 Gitweb: http://git.kernel.org/tip/590cd344e2099c7b040b29d3a711b4c26358def5 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 22 Dec 2014 13:44:09 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 21 Jan 2015 13:24:32 -0300
perf report: Get rid of report__inc_stat()
The report__inc_stat() function collects the number of hist entries in the session in order to calculate the max size of the progess bar.
It'd be better if it does it during the addition of hist entries so that it can be used by other places too.
--- tools/perf/builtin-report.c | 16 +++------------- tools/perf/util/hist.c | 2 ++ 2 files changed, 5 insertions(+), 13 deletions(-)
tools/perf/builtin-report.c +3 -13
@@ -86,17 +86,6 @@ static int report__config(const char *var, const char *value, void *cb)return perf_default_config (var, value, cb); } -static void report__inc_stats (struct report *rep,struct hist_entry *he) -{ -/* -* The @he is either of a newly created one or an existing one -* merging current sample. We only want to count a new one so -* checking ->nr_events being 1. -*/ -if (he->stat.nr_events ==1 ) - rep->nr_entries++; -} -static int hist_iter__report_callback (struct hist_entry_iter *iter,struct addr_location *al,bool single,void *arg)
@@ -108,8 +97,6 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,struct mem_info *mi;struct branch_info *bi; -report__inc_stats (rep, he); -if (!ui__has_annotation ())return 0 ;
@@ -499,6 +486,9 @@ static int __cmd_report(struct report *rep)report__warn_kptr_restrict (rep); +evlist__for_each (session->evlist, pos) + rep->nr_entries +=evsel__hists (pos)->nr_entries; +if (use_browser ==0 ) {if (verbose >3 )perf_session__fprintf (session, stdout);
tools/perf/util/hist.c +2 -0
@@ -429,6 +429,8 @@ static struct hist_entry *add_hist_entry(struct hists *hists,if (!he)return NULL ; + hists->nr_entries++; +rb_link_node (&he->rb_node_in, parent, p);rb_insert_color (&he->rb_node_in, hists->entries_in); out:
Namhyung Kim
maintainerPATCH 2/7 perf report: Show progress bar for output resorting
In reply to Namhyung KimSometimes it takes a time to resort hist entries for output in case of a large data file. Show a progress bar window and inform user.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 24 ++++++++++++++++++++++-- tools/perf/builtin-top.c | 4 ++-- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_output.c | 10 +++++----- tools/perf/util/hist.c | 10 +++++++++- tools/perf/util/hist.h | 2 +- 9 files changed, 43 insertions(+), 15 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -232,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann)if (nr_samples >0 ) { total_nr_samples += nr_samples;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (symbol_conf.event_group && !perf_evsel__is_group_leader (pos))
tools/perf/builtin-diff.c +1 -1
@@ -605,7 +605,7 @@ static void hists__process(struct hists *hists)hists__precompute (hists);hists__compute_resort (hists); }else { -hists__output_resort (hists); +hists__output_resort (hists,NULL ); }hists__fprintf (hists, true,0 ,0 ,0 , stdout);
tools/perf/builtin-report.c +22 -2
@@ -444,6 +444,19 @@ static void report__collapse_hists(struct report *rep)ui_progress__finish (); } +static void report__output_resort (struct report *rep) +{ +struct ui_progress prog; +struct perf_evsel *pos; + +ui_progress__init (&prog, rep->nr_entries,"Sorting events for output..." ); + +evlist__for_each (rep->session->evlist, pos) +hists__output_resort (evsel__hists (pos), &prog); + +ui_progress__finish (); +} +static int __cmd_report (struct report *rep) {int ret;
@@ -495,13 +508,20 @@ static int __cmd_report(struct report *rep)if (session_done ())return 0 ; +/* +* recalculate number of entries after collapsing since it +* might be changed during the collapse phase. +*/ + rep->nr_entries =0 ; +evlist__for_each (session->evlist, pos) + rep->nr_entries +=evsel__hists (pos)->nr_entries; +if (rep->nr_entries ==0 ) {ui__error ("The %s file has no samples!\n" , file->path);return 0 ; } -evlist__for_each (session->evlist, pos) -hists__output_resort (evsel__hists (pos)); +report__output_resort (rep);return report__browse_hists (rep); }
tools/perf/builtin-top.c +2 -2
@@ -285,7 +285,7 @@ static void perf_top__print_sym_table(struct perf_top *top) }hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );hists__output_recalc_col_len (hists, top->print_entries - printed);putchar ('\n' );
@@ -554,7 +554,7 @@ static void perf_top__sort_new_samples(void *arg) }hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL ); }static void *display_thread_tui (void *arg)
tools/perf/tests/hists_cumulate.c +1 -1
@@ -187,7 +187,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec* function since TEST_ASSERT_VAL() returns in case of failure. */ hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) { pr_info("use callchain: %d, cumulate callchain: %d\n",
tools/perf/tests/hists_filter.c +1 -1
@@ -138,7 +138,7 @@ int test__hists_filter(void)struct hists *hists =evsel__hists (evsel);hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("Normal histogram\n" );
tools/perf/tests/hists_output.c +5 -5
@@ -152,7 +152,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -252,7 +252,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -306,7 +306,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -384,7 +384,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -487,7 +487,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
tools/perf/util/hist.c +9 -1
@@ -6,6 +6,7 @@#include "evlist.h" #include "evsel.h" #include "annotate.h" +#include "ui/progress.h" #include <math.h> static bool hists__filter_entry_by_dso(struct hists *hists,
@@ -985,6 +986,7 @@ static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,else p = &(*p)->rb_right; } + hists->nr_entries++;rb_link_node (&he->rb_node_in, parent, p);rb_insert_color (&he->rb_node_in, root);
@@ -1022,7 +1024,10 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)if (!sort__need_collapse)return ; + hists->nr_entries =0 ; + root =hists__get_rotate_entries_in (hists); + next =rb_first (root);while (next) {
@@ -1117,7 +1122,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,rb_insert_color (&he->rb_node, entries); } -void hists__output_resort (struct hists *hists) +void hists__output_resort (struct hists *hists,struct ui_progress *prog) {struct rb_root *root;struct rb_node *next;
@@ -1146,6 +1151,9 @@ void hists__output_resort(struct hists *hists)if (!n->filtered)hists__calc_col_len (hists, n); + +if (prog) +ui_progress__update (prog,1 ); } }
tools/perf/util/hist.h +1 -1
@@ -121,7 +121,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size, struct hists *hists);void hist_entry__delete (struct hist_entry *he); -void hists__output_resort (struct hists *hists); +void hists__output_resort (struct hists *hists,struct ui_progress *prog);void hists__collapse_resort (struct hists *hists,struct ui_progress *prog);void hists__decay_entries (struct hists *hists,bool zap_user,bool zap_kernel);
Signature · 1 line
2.1.3
tip-bot for Namhyung Kim
merge bot[tip:perf/urgent] perf report: Show progress bar for output resorting
perf report: Show progress bar for output resorting
Commit-ID: 740b97f9509ac5a015278940747178af4eb0900d Gitweb: http://git.kernel.org/tip/740b97f9509ac5a015278940747178af4eb0900d Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 22 Dec 2014 13:44:10 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Dec 2014 12:01:37 -0300
perf report: Show progress bar for output resorting
Sometimes it takes a long time to resort hist entries for output in case of a large data file. Show a progress bar window and inform user.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 24 ++++++++++++++++++++++-- tools/perf/builtin-top.c | 4 ++-- tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_output.c | 10 +++++----- tools/perf/util/hist.c | 10 +++++++++- tools/perf/util/hist.h | 2 +- 9 files changed, 43 insertions(+), 15 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -232,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann)if (nr_samples >0 ) { total_nr_samples += nr_samples;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (symbol_conf.event_group && !perf_evsel__is_group_leader (pos))
tools/perf/builtin-diff.c +1 -1
@@ -605,7 +605,7 @@ static void hists__process(struct hists *hists)hists__precompute (hists);hists__compute_resort (hists); }else { -hists__output_resort (hists); +hists__output_resort (hists,NULL ); }hists__fprintf (hists, true,0 ,0 ,0 , stdout);
tools/perf/builtin-report.c +22 -2
@@ -457,6 +457,19 @@ static void report__collapse_hists(struct report *rep)ui_progress__finish (); } +static void report__output_resort (struct report *rep) +{ +struct ui_progress prog; +struct perf_evsel *pos; + +ui_progress__init (&prog, rep->nr_entries,"Sorting events for output..." ); + +evlist__for_each (rep->session->evlist, pos) +hists__output_resort (evsel__hists (pos), &prog); + +ui_progress__finish (); +} +static int __cmd_report (struct report *rep) {int ret;
@@ -505,13 +518,20 @@ static int __cmd_report(struct report *rep)if (session_done ())return 0 ; +/* +* recalculate number of entries after collapsing since it +* might be changed during the collapse phase. +*/ + rep->nr_entries =0 ; +evlist__for_each (session->evlist, pos) + rep->nr_entries +=evsel__hists (pos)->nr_entries; +if (rep->nr_entries ==0 ) {ui__error ("The %s file has no samples!\n" , file->path);return 0 ; } -evlist__for_each (session->evlist, pos) -hists__output_resort (evsel__hists (pos)); +report__output_resort (rep);return report__browse_hists (rep); }
tools/perf/builtin-top.c +2 -2
@@ -285,7 +285,7 @@ static void perf_top__print_sym_table(struct perf_top *top) }hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );hists__output_recalc_col_len (hists, top->print_entries - printed);putchar ('\n' );
@@ -554,7 +554,7 @@ static void perf_top__sort_new_samples(void *arg) }hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL ); }static void *display_thread_tui (void *arg)
tools/perf/tests/hists_cumulate.c +1 -1
@@ -187,7 +187,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec* function since TEST_ASSERT_VAL() returns in case of failure. */ hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) { pr_info("use callchain: %d, cumulate callchain: %d\n",
tools/perf/tests/hists_filter.c +1 -1
@@ -138,7 +138,7 @@ int test__hists_filter(void)struct hists *hists =evsel__hists (evsel);hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("Normal histogram\n" );
tools/perf/tests/hists_output.c +5 -5
@@ -152,7 +152,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -252,7 +252,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -306,7 +306,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -384,7 +384,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
@@ -487,7 +487,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine) goto out;hists__collapse_resort (hists,NULL ); -hists__output_resort (hists); +hists__output_resort (hists,NULL );if (verbose >2 ) {pr_info ("[fields = %s, sort = %s]\n" , field_order, sort_order);
tools/perf/util/hist.c +9 -1
@@ -6,6 +6,7 @@#include "evlist.h" #include "evsel.h" #include "annotate.h" +#include "ui/progress.h" #include <math.h> static bool hists__filter_entry_by_dso(struct hists *hists,
@@ -987,6 +988,7 @@ static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,else p = &(*p)->rb_right; } + hists->nr_entries++;rb_link_node (&he->rb_node_in, parent, p);rb_insert_color (&he->rb_node_in, root);
@@ -1024,7 +1026,10 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)if (!sort__need_collapse)return ; + hists->nr_entries =0 ; + root =hists__get_rotate_entries_in (hists); + next =rb_first (root);while (next) {
@@ -1119,7 +1124,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,rb_insert_color (&he->rb_node, entries); } -void hists__output_resort (struct hists *hists) +void hists__output_resort (struct hists *hists,struct ui_progress *prog) {struct rb_root *root;struct rb_node *next;
@@ -1148,6 +1153,9 @@ void hists__output_resort(struct hists *hists)if (!n->filtered)hists__calc_col_len (hists, n); + +if (prog) +ui_progress__update (prog,1 ); } }
tools/perf/util/hist.h +1 -1
@@ -121,7 +121,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size, struct hists *hists);void hist_entry__free (struct hist_entry *); -void hists__output_resort (struct hists *hists); +void hists__output_resort (struct hists *hists,struct ui_progress *prog);void hists__collapse_resort (struct hists *hists,struct ui_progress *prog);void hists__decay_entries (struct hists *hists,bool zap_user,bool zap_kernel);
Namhyung Kim
maintainerPATCH 3/7 perf ui/tui: Print backtrace symbols when segfault occurred
In reply to Namhyung KimThe output will look like below. (I added an error into ui__init() for the test).
$ perf report perf: Segmentation fault -------- backtrace -------- perf[0x503781] /usr/lib/libc.so.6(+0x33b20)[0x7f1a14f04b20] perf(ui__init+0xd5)[0x503645] perf(setup_browser+0x97)[0x4ce4e7] perf(cmd_report+0xcea)[0x4392ba] perf[0x428493] perf(main+0x60a)[0x427c0a] /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f1a14ef1040] perf[0x427d29] [0x0]
--- tools/perf/ui/tui/setup.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
tools/perf/ui/tui/setup.c +24 -2
@@ -1,5 +1,8 @@#include <signal.h> #include <stdbool.h> +#ifdef HAVE_BACKTRACE_SUPPORT +#include <execinfo.h> +#endif #include "../../util/cache.h" #include "../../util/debug.h"
@@ -88,6 +91,25 @@ int ui__getch(int delay_secs)return SLkp_getkey (); } +#ifdef HAVE_BACKTRACE_SUPPORT +static void ui__signal_backtrace (int sig) +{ +void *stackdump[32 ]; +size_t size; + +ui__exit (false); +psignal (sig,"perf" ); + +printf ("-------- backtrace --------\n" ); + size =backtrace (stackdump,ARRAY_SIZE (stackdump)); +backtrace_symbols_fd (stackdump, size,STDOUT_FILENO ); + +exit (0 ); +} +#else +# define ui__signal_backtrace ui__signal +#endif +static void ui__signal (int sig) {ui__exit (false);
@@ -122,8 +144,8 @@ int ui__init(void)ui_browser__init ();tui_progress__init (); -signal (SIGSEGV , ui__signal); -signal (SIGFPE , ui__signal); +signal (SIGSEGV , ui__signal_backtrace); +signal (SIGFPE , ui__signal_backtrace);signal (SIGINT , ui__signal);signal (SIGQUIT , ui__signal);signal (SIGTERM , ui__signal);
Signature · 1 line
2.1.3
tip-bot for Namhyung Kim
merge bot[tip:perf/urgent] perf ui/tui: Print backtrace symbols when segfault occurs
perf ui/tui: Print backtrace symbols when segfault occurs
Commit-ID: b11bc8e28f4829f693ef6c0178fe1811386ac828 Gitweb: http://git.kernel.org/tip/b11bc8e28f4829f693ef6c0178fe1811386ac828 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 22 Dec 2014 13:44:11 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Dec 2014 12:05:59 -0300
perf ui/tui: Print backtrace symbols when segfault occurs
The output will look like below. (I added an error into ui__init() for the test).
$ perf report perf: Segmentation fault -------- backtrace -------- perf[0x503781] /usr/lib/libc.so.6(+0x33b20)[0x7f1a14f04b20] perf(ui__init+0xd5)[0x503645] perf(setup_browser+0x97)[0x4ce4e7] perf(cmd_report+0xcea)[0x4392ba] perf[0x428493] perf(main+0x60a)[0x427c0a] /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f1a14ef1040] perf[0x427d29] [0x0]
--- tools/perf/ui/tui/setup.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
tools/perf/ui/tui/setup.c +24 -2
@@ -1,5 +1,8 @@#include <signal.h> #include <stdbool.h> +#ifdef HAVE_BACKTRACE_SUPPORT +#include <execinfo.h> +#endif #include "../../util/cache.h" #include "../../util/debug.h"
@@ -88,6 +91,25 @@ int ui__getch(int delay_secs)return SLkp_getkey (); } +#ifdef HAVE_BACKTRACE_SUPPORT +static void ui__signal_backtrace (int sig) +{ +void *stackdump[32 ]; +size_t size; + +ui__exit (false); +psignal (sig,"perf" ); + +printf ("-------- backtrace --------\n" ); + size =backtrace (stackdump,ARRAY_SIZE (stackdump)); +backtrace_symbols_fd (stackdump, size,STDOUT_FILENO ); + +exit (0 ); +} +#else +# define ui__signal_backtrace ui__signal +#endif +static void ui__signal (int sig) {ui__exit (false);
@@ -122,8 +144,8 @@ int ui__init(void)ui_browser__init ();tui_progress__init (); -signal (SIGSEGV , ui__signal); -signal (SIGFPE , ui__signal); +signal (SIGSEGV , ui__signal_backtrace); +signal (SIGFPE , ui__signal_backtrace);signal (SIGINT , ui__signal);signal (SIGQUIT , ui__signal);signal (SIGTERM , ui__signal);
Namhyung Kim
maintainerPATCH 4/7 perf diff: Fix to sort by baseline field by default
In reply to Namhyung KimThe currently perf diff didn't add the baseline and delta (or other compute) fields to the sort list so output will be sorted by other fields like alphabetical order of DSO or symbol as below example.
Fix it by adding hpp formats for the fields and provides default compare functions.
Before:
$ perf diff
# Event 'cycles'
#
# Baseline Delta Shared Object Symbol
# ........ ....... .................. ...............................
#
[bridge] [k] ip_sabotage_in
[btrfs] [k] __etree_search.constprop.47
0.01% [btrfs] [k] btrfs_file_mmap
0.01% -0.01% [btrfs] [k] btrfs_getattr
[e1000e] [k] e1000_watchdog
0.00% [kernel.vmlinux] [k] PageHuge
0.00% [kernel.vmlinux] [k] __acct_update_integrals
0.00% [kernel.vmlinux] [k] __activate_page
[kernel.vmlinux] [k] __alloc_fd
0.02% +0.02% [kernel.vmlinux] [k] __alloc_pages_nodemask
...After:
# Baseline Delta Shared Object Symbol
# ........ ....... .................. ................................
#
24.73% -4.62% perf [.] append_chain_children
7.96% -1.29% perf [.] dso__find_symbol
6.97% -2.07% libc-2.20.so [.] vfprintf
4.61% +0.88% libc-2.20.so [.] __fprintf_chk
4.41% +2.43% perf [.] sort__comm_cmp
4.10% -0.16% perf [.] comm__str
4.03% -0.93% perf [.] machine__findnew_thread_time
3.82% +3.09% perf [.] __hists__add_entry
2.95% -0.18% perf [.] sort__dso_cmp
...--- tools/perf/builtin-diff.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tools/perf/builtin-diff.c +44 -0
@@ -545,6 +545,42 @@ hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,return __hist_entry__cmp_compute (p_left, p_right, c); } +static int64_t +hist_entry__cmp_nop (struct hist_entry *left__maybe_unused , +struct hist_entry *right__maybe_unused ) +{ +return 0 ; +} + +static int64_t +hist_entry__cmp_baseline (struct hist_entry *left,struct hist_entry *right) +{ +if (sort_compute) +return 0 ; + +if (left->stat.period == right->stat.period) +return 0 ; +return left->stat.period > right->stat.period ?1 :-1 ; +} + +static int64_t +hist_entry__cmp_delta (struct hist_entry *left,struct hist_entry *right) +{ +return hist_entry__cmp_compute (right, left,COMPUTE_DELTA ); +} + +static int64_t +hist_entry__cmp_ratio (struct hist_entry *left,struct hist_entry *right) +{ +return hist_entry__cmp_compute (right, left,COMPUTE_RATIO ); +} + +static int64_t +hist_entry__cmp_wdiff (struct hist_entry *left,struct hist_entry *right) +{ +return hist_entry__cmp_compute (right, left,COMPUTE_WEIGHTED_DIFF ); +} +static void insert_hist_entry_by_compute (struct rb_root *root,struct hist_entry *he,int c)
@@ -1038,27 +1074,35 @@ static void data__hpp_register(struct data__file *d, int idx) fmt->header = hpp__header; fmt->width = hpp__width; fmt->entry = hpp__entry_global; + fmt->cmp = hist_entry__cmp_nop; + fmt->collapse = hist_entry__cmp_nop;/* TODO more colors */ switch (idx) {case PERF_HPP_DIFF__BASELINE : fmt->color = hpp__color_baseline; + fmt->sort = hist_entry__cmp_baseline;break ;case PERF_HPP_DIFF__DELTA : fmt->color = hpp__color_delta; + fmt->sort = hist_entry__cmp_delta;break ;case PERF_HPP_DIFF__RATIO : fmt->color = hpp__color_ratio; + fmt->sort = hist_entry__cmp_ratio;break ;case PERF_HPP_DIFF__WEIGHTED_DIFF : fmt->color = hpp__color_wdiff; + fmt->sort = hist_entry__cmp_wdiff;break ;default : + fmt->sort = hist_entry__cmp_nop;break ; }init_header (d, dfmt);perf_hpp__column_register (fmt); +perf_hpp__register_sort_field (fmt); }static void ui_init (void )
Signature · 1 line
2.1.3
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 4/7] perf diff: Fix to sort by baseline field by default
Em Mon, Dec 22, 2014 at 01:44:12PM +0900, Namhyung Kim escreveu:
Quoted 29 lines
The currently perf diff didn't add the baseline and delta (or other compute) fields to the sort list so output will be sorted by other fields like alphabetical order of DSO or symbol as below example.
Fix it by adding hpp formats for the fields and provides default compare functions.
Before:
$ perf diff # Event 'cycles' # # Baseline Delta Shared Object Symbol # ........ ....... .................. ............................... # [bridge] [k] ip_sabotage_in [btrfs] [k] __etree_search.constprop.47 0.01% [btrfs] [k] btrfs_file_mmap 0.01% -0.01% [btrfs] [k] btrfs_getattr [e1000e] [k] e1000_watchdog 0.00% [kernel.vmlinux] [k] PageHuge 0.00% [kernel.vmlinux] [k] __acct_update_integrals 0.00% [kernel.vmlinux] [k] __activate_page [kernel.vmlinux] [k] __alloc_fd 0.02% +0.02% [kernel.vmlinux] [k] __alloc_pages_nodemask ...After:
Quoted 13 lines
# Baseline Delta Shared Object Symbol
# ........ ....... .................. ................................
#
24.73% -4.62% perf [.] append_chain_children
7.96% -1.29% perf [.] dso__find_symbol
6.97% -2.07% libc-2.20.so [.] vfprintf
4.61% +0.88% libc-2.20.so [.] __fprintf_chk
4.41% +2.43% perf [.] sort__comm_cmp
4.10% -0.16% perf [.] comm__str
4.03% -0.93% perf [.] machine__findnew_thread_time
3.82% +3.09% perf [.] __hists__add_entry
2.95% -0.18% perf [.] sort__dso_cmp
...Looks better, here I tried running 'perf record usleep 1' in quick succession to then run 'perf diff' before and after this patch, got:
Before:
[ssdandy ~]$ cat /tmp/before
# Event 'cycles'
#
# Baseline Delta Shared Object Symbol
# ........ ....... ................ ..............................
#
+36.29% [kernel.vmlinux] [k] __split_vma.isra.31
34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled
+2.45% [kernel.vmlinux] [k] local_clock
0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe
2.12% [kernel.vmlinux] [k] perf_event_comm_output
+61.13% [kernel.vmlinux] [k] unmap_page_range
63.22% libc-2.17.so [.] 0x000000000007c3e0 [acme@ssdandy ~]$
After:
[acme@ssdandy linux]$ perf diff
# Event 'cycles'
#
# Baseline Delta Shared Object Symbol
# ........ ....... ................ ..............................
#
63.22% libc-2.17.so [.] 0x000000000007c3e0
34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled
2.12% [kernel.vmlinux] [k] perf_event_comm_output
0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe
+36.29% [kernel.vmlinux] [k] __split_vma.isra.31
+2.45% [kernel.vmlinux] [k] local_clock
+61.13% [kernel.vmlinux] [k] unmap_page_range [acme@ssdandy linux]$
Which was ok up to the point where symbols that only appeared on the second run were not sorted by delta, can you fix that?
Please let me know if it is better to apply this one then a followup to sort the deltas or if a combined patch to achieve both is best.
I.e.:
[acme@ssdandy linux]$ perf diff
# Event 'cycles'
#
# Baseline Delta Shared Object Symbol
# ........ ....... ................ ..............................
#
63.22% libc-2.17.so [.] 0x000000000007c3e0
34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled
2.12% [kernel.vmlinux] [k] perf_event_comm_output
0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe
+61.13% [kernel.vmlinux] [k] unmap_page_range
+36.29% [kernel.vmlinux] [k] __split_vma.isra.31
+2.45% [kernel.vmlinux] [k] local_clock [acme@ssdandy linux]$
Humm, but then wouldn't we be more interested in sorting _everything_ by delta?
- Arnaldo
Namhyung Kim
maintainerRe: [PATCH 4/7] perf diff: Fix to sort by baseline field by default
Quoted 35 lines · Arnaldo Carvalho de Melo
Looks better, here I tried running 'perf record usleep 1' in quick succession to then run 'perf diff' before and after this patch, got:
Before:
[ssdandy ~]$ cat
/tmp/before
# Event 'cycles'
## Baseline Delta Shared Object Symbol # ........ ....... ................ .............................. # +36.29% [kernel.vmlinux] [k] __split_vma.isra.31 34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled +2.45% [kernel.vmlinux] [k] local_clock 0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe 2.12% [kernel.vmlinux] [k] perf_event_comm_output +61.13% [kernel.vmlinux] [k] unmap_page_range 63.22% libc-2.17.so [.] 0x000000000007c3e0[acme@ssdandy ~]$
After:
[acme@ssdandy linux]$ perf diff
# Event 'cycles'
## Baseline Delta Shared Object Symbol # ........ ....... ................ .............................. # 63.22% libc-2.17.so [.] 0x000000000007c3e0 34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled 2.12% [kernel.vmlinux] [k] perf_event_comm_output 0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe +36.29% [kernel.vmlinux] [k] __split_vma.isra.31 +2.45% [kernel.vmlinux] [k] local_clock +61.13% [kernel.vmlinux] [k] unmap_page_range
Quoted 4 lines
[acme@ssdandy linux]$
Which was ok up to the point where symbols that only appeared on the second run were not sorted by delta, can you fix that?
I'll do that later.
Quoted 3 lines
Please let me know if it is better to apply this one then a followup to sort the deltas or if a combined patch to achieve both is best.
I prefer applying this for now and then improve sorting later..
Quoted 17 lines
I.e.:
[acme@ssdandy linux]$ perf diff
# Event 'cycles'
## Baseline Delta Shared Object Symbol # ........ ....... ................ .............................. # 63.22% libc-2.17.so [.] 0x000000000007c3e0 34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled 2.12% [kernel.vmlinux] [k] perf_event_comm_output 0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe +61.13% [kernel.vmlinux] [k] unmap_page_range +36.29% [kernel.vmlinux] [k] __split_vma.isra.31 +2.45% [kernel.vmlinux] [k] local_clock
Quoted 4 lines
[acme@ssdandy linux]$
Humm, but then wouldn't we be more interested in sorting _everything_ by delta?
I don't understand whay you said.. what do you mean by 'everything be delta'? Is that something other than perf diff -o 1 ?
Thanks,
Namhyung
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 4/7] perf diff: Fix to sort by baseline field by default
Em Tue, Dec 23, 2014 at 01:12:13PM +0900, Namhyung Kim escreveu:
Quoted 38 lines · Arnaldo Carvalho de Melo
Quoted 37 lines
Looks better, here I tried running 'perf record usleep 1' in quick succession to then run 'perf diff' before and after this patch, got:
Before:
[ssdandy ~]$ cat
/tmp/before
# Event 'cycles'
## Baseline Delta Shared Object Symbol # ........ ....... ................ .............................. # +36.29% [kernel.vmlinux] [k] __split_vma.isra.31 34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled +2.45% [kernel.vmlinux] [k] local_clock 0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe 2.12% [kernel.vmlinux] [k] perf_event_comm_output +61.13% [kernel.vmlinux] [k] unmap_page_range 63.22% libc-2.17.so [.] 0x000000000007c3e0[acme@ssdandy ~]$
After:
[acme@ssdandy linux]$ perf diff
# Event 'cycles'
## Baseline Delta Shared Object Symbol # ........ ....... ................ .............................. # 63.22% libc-2.17.so [.] 0x000000000007c3e0 34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled 2.12% [kernel.vmlinux] [k] perf_event_comm_output 0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe +36.29% [kernel.vmlinux] [k] __split_vma.isra.31 +2.45% [kernel.vmlinux] [k] local_clock +61.13% [kernel.vmlinux] [k] unmap_page_range[acme@ssdandy linux]$
Quoted 4 lines
Quoted 2 lines
Which was ok up to the point where symbols that only appeared on the second run were not sorted by delta, can you fix that?
I'll do that later.
Ok, thanks for considering doing that!
Quoted 4 lines
Quoted 2 lines
Please let me know if it is better to apply this one then a followup to sort the deltas or if a combined patch to achieve both is best.
I prefer applying this for now and then improve sorting later..
Ok, will apply it, thanks for checking.
Quoted 16 lines
Quoted 15 lines
I.e.:
[acme@ssdandy linux]$ perf diff
# Event 'cycles'
## Baseline Delta Shared Object Symbol # ........ ....... ................ .............................. # 63.22% libc-2.17.so [.] 0x000000000007c3e0 34.55% [kernel.vmlinux] [k] copy_user_generic_unrolled 2.12% [kernel.vmlinux] [k] perf_event_comm_output 0.11% +0.02% [kernel.vmlinux] [k] native_write_msr_safe +61.13% [kernel.vmlinux] [k] unmap_page_range +36.29% [kernel.vmlinux] [k] __split_vma.isra.31 +2.45% [kernel.vmlinux] [k] local_clock
Quoted 7 lines
Quoted 4 lines
[acme@ssdandy linux]$
Humm, but then wouldn't we be more interested in sorting _everything_ by delta?
I don't understand whay you said.. what do you mean by 'everything be delta'? Is that something other than perf diff -o 1 ?
A-ha, exactly, thanks for educating me! :-)
- Arnaldo
Namhyung Kim
maintainerPATCH 5/7 perf diff: Get rid of hists__compute_resort()
In reply to Namhyung KimThe hists__compute_resort() is to sort output fields based on the given field/criteria. This was done without the sort list but as we added the field to the sort list, we can do it with normal hists__output_resort() using the ->sort callback.
--- tools/perf/builtin-diff.c | 59 +++-------------------------------------------- 1 file changed, 3 insertions(+), 56 deletions(-)
tools/perf/builtin-diff.c +3 -56
@@ -581,68 +581,15 @@ hist_entry__cmp_wdiff(struct hist_entry *left, struct hist_entry *right)return hist_entry__cmp_compute (right, left,COMPUTE_WEIGHTED_DIFF ); } -static void insert_hist_entry_by_compute (struct rb_root *root, -struct hist_entry *he, -int c) -{ -struct rb_node **p = &root->rb_node; -struct rb_node *parent =NULL ; -struct hist_entry *iter; - -while (*p !=NULL ) { - parent = *p; - iter = rb_entry(parent, struct hist_entry, rb_node); -if (hist_entry__cmp_compute (he, iter, c) <0 ) - p = &(*p)->rb_left; -else - p = &(*p)->rb_right; - } - -rb_link_node (&he->rb_node, parent, p); -rb_insert_color (&he->rb_node, root); -} - -static void hists__compute_resort (struct hists *hists) -{ -struct rb_root *root; -struct rb_node *next; - -if (sort__need_collapse) - root = &hists->entries_collapsed; -else - root = hists->entries_in; - - hists->entries =RB_ROOT ; - next =rb_first (root); - -hists__reset_stats (hists); -hists__reset_col_len (hists); - -while (next !=NULL ) { -struct hist_entry *he; - - he = rb_entry(next, struct hist_entry, rb_node_in); - next =rb_next (&he->rb_node_in); - -insert_hist_entry_by_compute (&hists->entries, he, compute); -hists__inc_stats (hists, he); - -if (!he->filtered) -hists__calc_col_len (hists, he); - } -} -static void hists__process (struct hists *hists) {if (show_baseline_only)hists__baseline_only (hists); -if (sort_compute) { +if (sort_compute)hists__precompute (hists); -hists__compute_resort (hists); - }else { -hists__output_resort (hists,NULL ); - } + +hists__output_resort (hists,NULL );hists__fprintf (hists, true,0 ,0 ,0 , stdout); }
Signature · 1 line
2.1.3
Namhyung Kim
maintainerPATCH 6/7 perf tools: Append callchains only when requested
In reply to Namhyung KimThe perf report --children can be called with callchain disabled so no need to append callchains. Actually the root of callchain tree is not initialized properly in this case.
--- tools/perf/util/hist.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/hist.c +4 -3
@@ -300,7 +300,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,size_t callchain_size =0 ;struct hist_entry *he; -if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) +if (symbol_conf.use_callchain) callchain_size =sizeof (struct callchain_root ); he =zalloc (sizeof (*he) + callchain_size);
@@ -735,7 +735,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; -callchain_append (he->callchain, &callchain_cursor, sample->period); +hist_entry__append_callchain (he, sample);/* * We need to re-initialize the cursor since callchain_append()
@@ -808,7 +808,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; -callchain_append (he->callchain, &cursor, sample->period); +if (symbol_conf.use_callchain) +callchain_append (he->callchain, &cursor, sample->period);return 0 ; }
Signature · 1 line
2.1.3
tip-bot for Namhyung Kim
merge bot[tip:perf/urgent] perf callchain: Append callchains only when requested
perf callchain: Append callchains only when requested
Commit-ID: 82aa019e0098a1e0801df94345c0297448323126 Gitweb: http://git.kernel.org/tip/82aa019e0098a1e0801df94345c0297448323126 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 22 Dec 2014 13:44:14 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Dec 2014 12:06:39 -0300
perf callchain: Append callchains only when requested
The perf report --children can be called with callchain disabled so no need to append callchains. Actually the root of callchain tree is not initialized properly in this case.
--- tools/perf/util/hist.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/hist.c +4 -3
@@ -304,7 +304,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,size_t callchain_size =0 ;struct hist_entry *he; -if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) +if (symbol_conf.use_callchain) callchain_size =sizeof (struct callchain_root ); he =zalloc (sizeof (*he) + callchain_size);
@@ -737,7 +737,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; -callchain_append (he->callchain, &callchain_cursor, sample->period); +hist_entry__append_callchain (he, sample);/* * We need to re-initialize the cursor since callchain_append()
@@ -810,7 +810,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; -callchain_append (he->callchain, &cursor, sample->period); +if (symbol_conf.use_callchain) +callchain_append (he->callchain, &cursor, sample->period);return 0 ; }
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 6/7] perf tools: Append callchains only when requested
In reply to Namhyung KimEm Mon, Dec 22, 2014 at 01:44:14PM +0900, Namhyung Kim escreveu:
Quoted 3 lines
The perf report --children can be called with callchain disabled so no need to append callchains. Actually the root of callchain tree is not initialized properly in this case.
Hi Namhyung,
I should have caught this using 'perf test', but it slipped
thru, please try running 'perf test cumulation', I noticed that it fails and that if I revert this changeset it works again, can you please check?
- Arnaldo
Quoted 39 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/hist.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)tools/perf/util/hist.c +4
-3@@ -300,7 +300,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,size_t callchain_size =0 ;struct hist_entry *he; -if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) +if (symbol_conf.use_callchain) callchain_size =sizeof (struct callchain_root ); he =zalloc (sizeof (*he) + callchain_size);@@ -735,7 +735,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; -callchain_append (he->callchain, &callchain_cursor, sample->period); +hist_entry__append_callchain (he, sample);/* * We need to re-initialize the cursor since callchain_append() @@ -808,7 +808,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, iter->he = he; he_cache[iter->curr++] = he; -callchain_append (he->callchain, &cursor, sample->period); +if (symbol_conf.use_callchain) +callchain_append (he->callchain, &cursor, sample->period);return 0 ; }Signature · 1 line
2.1.3
Namhyung Kim
maintainerRe: [PATCH 6/7] perf tools: Append callchains only when requested
Hi Arnaldo,
Quoted 11 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 22, 2014 at 01:44:14PM +0900, Namhyung Kim escreveu:
Quoted 3 lines
The perf report --children can be called with callchain disabled so no need to append callchains. Actually the root of callchain tree is not initialized properly in this case.
Hi Namhyung,
I should have caught this using 'perf test', but it slipped
thru, please try running 'perf test cumulation', I noticed that it fails and that if I revert this changeset it works again, can you please check?
This change should not affect the test result, but I guess the test somehow relied on the undefined behavior. Actually I posted a patch to fix this problem. So please take a look at the link below:
https://lkml.org/lkml/2014/12/22/561
Thanks,
Namhyung
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 6/7] perf tools: Append callchains only when requested
Em Sun, Jan 04, 2015 at 12:01:26AM +0900, Namhyung Kim escreveu:
Quoted 12 lines
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 22, 2014 at 01:44:14PM +0900, Namhyung Kim escreveu:
Quoted 3 lines
The perf report --children can be called with callchain disabled so no need to append callchains. Actually the root of callchain tree is not initialized properly in this case.
I should have caught this using 'perf test', but it slipped
thru, please try running 'perf test cumulation', I noticed that it fails and that if I revert this changeset it works again, can you please check?
Quoted 5 lines
This change should not affect the test result, but I guess the test somehow relied on the undefined behavior. Actually I posted a patch to fix this problem. So please take a look at the link below:
Ok, missed this one, will get it on perf/urgent and look if there are patches pending merging in that pull req.
Thanks,
- Arnaldo
Namhyung Kim
maintainerRe: [PATCH 6/7] perf tools: Append callchains only when requested
Hi Arnaldo,
Quoted 13 lines · Arnaldo Carvalho de Melo
Em Sun, Jan 04, 2015 at 12:01:26AM +0900, Namhyung Kim escreveu:
Quoted 11 lines
Quoted 9 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 22, 2014 at 01:44:14PM +0900, Namhyung Kim escreveu:
Quoted 3 lines
The perf report --children can be called with callchain disabled so no need to append callchains. Actually the root of callchain tree is not initialized properly in this case.
I should have caught this using 'perf test', but it slipped
thru, please try running 'perf test cumulation', I noticed that it fails and that if I revert this changeset it works again, can you please check?
Quoted 8 lines
Quoted 5 lines
This change should not affect the test result, but I guess the test somehow relied on the undefined behavior. Actually I posted a patch to fix this problem. So please take a look at the link below:
Ok, missed this one, will get it on perf/urgent and look if there are patches pending merging in that pull req.
Could please consider applying it below:
https://lkml.org/lkml/2014/12/24/13
Thanks,
Namhyung
Namhyung Kim
maintainerPATCH 7/7 perf tools: Set attr.task bit for a tracking event
In reply to Namhyung KimThe perf_event_attr.task bit is to track task (fork and exit) events but it missed to be set by perf_evsel__config(). While it was not a problem in practice since setting other bits (comm/mmap) ended up being in same result, it'd be good to set it explicitly anyway.
--- tools/perf/util/evsel.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/evsel.c +1 -0
@@ -709,6 +709,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)if (opts->sample_weight)perf_evsel__set_sample_bit (evsel,WEIGHT ); + attr->task = track; attr->mmap = track; attr->mmap2 = track && !perf_missing_features.mmap2; attr->comm = track;
Signature · 1 line
2.1.3
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 7/7] perf tools: Set attr.task bit for a tracking event
Em Mon, Dec 22, 2014 at 01:44:15PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
The perf_event_attr.task bit is to track task (fork and exit) events but it missed to be set by
perf_evsel__config(). While it was not a problem in practice since setting other bits (comm/mmap) ended up being in same result, it'd be good to set it explicitly anyway.
I didn't understand, so this isn't strictly needed? I.e. what is the point of the attr->task bit then?
/me goes to check...
- Arnaldo
Quoted 19 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/evsel.c | 1 + 1 file changed, 1 insertion(+)tools/perf/util/evsel.c +1
-0@@ -709,6 +709,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)if (opts->sample_weight)perf_evsel__set_sample_bit (evsel,WEIGHT ); + attr->task = track; attr->mmap = track; attr->mmap2 = track && !perf_missing_features.mmap2; attr->comm = track;Signature · 1 line
2.1.3
Namhyung Kim
maintainerRe: [PATCH 7/7] perf tools: Set attr.task bit for a tracking event
Quoted 8 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 22, 2014 at 01:44:15PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
The perf_event_attr.task bit is to track task (fork and exit) events but it missed to be set by
perf_evsel__config(). While it was not a problem in practice since setting other bits (comm/mmap) ended up being in same result, it'd be good to set it explicitly anyway.I didn't understand, so this isn't strictly needed? I.e. what is the point of the
attr->taskbit then?
Yes, it's not strictly needed for this case. The attr->task is to track task related events (fork/exit) only but other meta events like comm and mmap[2] also needs the task events. So setting attr->comm and/or attr->mmap causes the kernel emits the task events anyway. So the attr->task is only meaningful when other bits are off but I'd like to set it for completeness.
Thanks,
Namhyung
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 7/7] perf tools: Set attr.task bit for a tracking event
Em Tue, Dec 23, 2014 at 01:06:33PM +0900, Namhyung Kim escreveu:
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 8 lines
Em Mon, Dec 22, 2014 at 01:44:15PM +0900, Namhyung Kim escreveu:
Quoted 4 lines
The perf_event_attr.task bit is to track task (fork and exit) events but it missed to be set by
perf_evsel__config(). While it was not a problem in practice since setting other bits (comm/mmap) ended up being in same result, it'd be good to set it explicitly anyway.I didn't understand, so this isn't strictly needed? I.e. what is the point of the
attr->taskbit then?
Quoted 6 lines
Yes, it's not strictly needed for this case. The
attr->taskis to track task related events (fork/exit) only but other meta events like comm and mmap[2] also needs the task events. So settingattr->command/orattr->mmapcauses the kernel emits the task events anyway. So theattr->taskis only meaningful when other bits are off but I'd like to set it for completeness.
Ok, I will update the changelog comment with this information.
- Arnaldo