perf report: Show error message when processing sample fails
Namhyung Kim
maintainerPATCH 1/3 perf report: Show error message when processing sample fails
Currently when perf fails to process samples for some reason, it doesn't show any message about the failure. This is very inconvenient for users especially on TUI as screen is reset after the failure.
--- tools/perf/builtin-report.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/builtin-report.c +9 -3
@@ -513,20 +513,26 @@ static int __cmd_report(struct report *rep)if (rep->cpu_list) { ret =perf_session__cpu_bitmap (session, rep->cpu_list, rep->cpu_bitmap); -if (ret) +if (ret) { +ui__error ("failed to set cpu bitmap\n" );return ret; + } }if (rep->show_threads)perf_read_values_init (&rep->show_threads_values); ret =report__setup_sample_type (rep); -if (ret) +if (ret) { +/* report__setup_sample_type() already showed error message */ return ret; + } ret =perf_session__process_events (session); -if (ret) +if (ret) { +ui__error ("failed to process sample\n" );return ret; + }report__warn_kptr_restrict (rep);
Signature · 1 line
2.6.2
Namhyung Kim
maintainerPATCH 2/3 perf hist: Do not skip elided fields when processing samples
If user gives a filter, perf marks the corresponding column elided and omits the output. But it should process and aggregates samples using the field, otherwise samples will be aggregated as if the column was not there resulted in incorrect output.
For example, I'd like to set a filter on native_write_msr_safe. The original overhead of the function is negligible.
$ perf report | grep native_write_msr_safe
0.00% swapper [kernel.vmlinux] native_write_msr_safe
0.00% perf [kernel.vmlinux] native_write_msr_safeHowever adding -S option gives different output.
$ perf report -S native_write_msr_safe --percentage absolute | \
Quoted 1 line
grep -e swapper -e perf
51.47% swapper [kernel.vmlinux]
4.14% perf [kernel.vmlinux]Since it aggregated samples using comm and dso only. In fact, the above values are same when it sorts with -s comm,dso.
$ perf report -s comm,dso | grep -e swapper -e perf
51.47% swapper [kernel.vmlinux]
4.14% perf [kernel.vmlinux]This resulted in TUI failure with -ERANGE since it tries to increase sample hit count for annotation with wrong symbols due to incorrect aggregation.
This patch fixes it not to skip elided fields when comparing samples in order to insert them to the hists.
--- tools/perf/util/hist.c | 6 ------ 1 file changed, 6 deletions(-)
tools/perf/util/hist.c +0 -6
@@ -924,9 +924,6 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)int64_t cmp =0 ;perf_hpp__for_each_sort_list (fmt) { -if (perf_hpp__should_skip (fmt)) -continue ; - cmp = fmt->cmp (fmt, left, right);if (cmp)break ;
@@ -942,9 +939,6 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)int64_t cmp =0 ;perf_hpp__for_each_sort_list (fmt) { -if (perf_hpp__should_skip (fmt)) -continue ; - cmp = fmt->collapse (fmt, left, right);if (cmp)break ;
Signature · 1 line
2.6.2
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf hist: Do not skip elided fields when processing samples
Em Sat, Nov 28, 2015 at 02:32:38AM +0900, Namhyung Kim escreveu:
Quoted 4 lines
If user gives a filter, perf marks the corresponding column elided and omits the output. But it should process and aggregates samples using the field, otherwise samples will be aggregated as if the column was not there resulted in incorrect output.
Thanks, applied, I've tested it and it now seems to work in both the --stdio and --tui interfaces, good job!
- Arnaldo
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf hists: Do not skip elided fields when processing samples
In reply to Namhyung Kimperf hists: Do not skip elided fields when processing samples
Commit-ID: e72655d97d24fff559b4ab59de791c3741a74c8c Gitweb: http://git.kernel.org/tip/e72655d97d24fff559b4ab59de791c3741a74c8c Author: Namhyung Kim <[email protected]> AuthorDate: Sat, 28 Nov 2015 02:32:38 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 27 Nov 2015 21:42:13 -0300
perf hists: Do not skip elided fields when processing samples
If user gives a filter, perf marks the corresponding column elided and omits the output. But it should process and aggregates samples using the field, otherwise samples will be aggregated as if the column was not there resulted in incorrect output.
For example, I'd like to set a filter on native_write_msr_safe. The original overhead of the function is negligible.
$ perf report | grep native_write_msr_safe
0.00% swapper [kernel.vmlinux] native_write_msr_safe
0.00% perf [kernel.vmlinux] native_write_msr_safeHowever adding -S option gives different output.
$ perf report -S native_write_msr_safe --percentage absolute | \
Quoted 1 line
grep -e swapper -e perf
51.47% swapper [kernel.vmlinux]
4.14% perf [kernel.vmlinux]Since it aggregated samples using comm and dso only. In fact, the above values are same when it sorts with -s comm,dso.
$ perf report -s comm,dso | grep -e swapper -e perf
51.47% swapper [kernel.vmlinux]
4.14% perf [kernel.vmlinux]This resulted in TUI failure with -ERANGE since it tries to increase sample hit count for annotation with wrong symbols due to incorrect aggregation.
This patch fixes it not to skip elided fields when comparing samples in order to insert them to the hists.
Commiter note:
After the patch, with a different workloads:
# perf report --show-total-period -S native_write_msr_safe --stdio
#
# symbol: native_write_msr_safe
#
# Samples: 455 of event 'cycles:pp'
# Event count (approx.): 134787489
#
# Overhead Period Command Shared Object
# ........ ...... ............... ................
#
0.22% 293081 qemu-system-x86 [vmlinux]
0.19% 255914 swapper [vmlinux]
0.00% 2054 Timer [vmlinux]
0.00% 1021 firefox [vmlinux]
0.00% 2 perf [vmlinux] # perf report --show-total-period | grep native_write_msr_safe
Failed to open /tmp/perf-14838.map, continuing without symbols
0.22% 293081 qemu-system-x86 [vmlinux] [k] native_write_msr_safe
0.19% 255914 swapper [vmlinux] [k] native_write_msr_safe
0.00% 2054 Timer [vmlinux] [k] native_write_msr_safe
0.00% 1021 firefox [vmlinux] [k] native_write_msr_safe
0.00% 2 perf [vmlinux] [k] native_write_msr_safe
#--- tools/perf/util/hist.c | 6 ------ 1 file changed, 6 deletions(-)
tools/perf/util/hist.c +0 -6
@@ -924,9 +924,6 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)int64_t cmp =0 ;perf_hpp__for_each_sort_list (fmt) { -if (perf_hpp__should_skip (fmt)) -continue ; - cmp = fmt->cmp (fmt, left, right);if (cmp)break ;
@@ -942,9 +939,6 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)int64_t cmp =0 ;perf_hpp__for_each_sort_list (fmt) { -if (perf_hpp__should_skip (fmt)) -continue ; - cmp = fmt->collapse (fmt, left, right);if (cmp)break ;
Namhyung Kim
maintainerPATCH 3/3 perf hists browser: Update nr entries regardless of min percent
In reply to Namhyung KimWhen perf report on TUI was called with -S symbol filter, it should update nr entries even if min_pcnt is 0. IIRC the reason was to update nr entries after applying minimum percent threshold. But if symbol filter was given on command line (with -S option), it should use hists->nr_non_filtered_entries instead of hists->nr_entries.
So this patch fixes a bug of navigating hists browser that the cursor goes beyond the number of entries when -S (or similar) option is used.
--- tools/perf/ui/browsers/hists.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +2 -3
@@ -2055,10 +2055,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,SLang_reset_tty ();SLang_init_tty (0 ,0 ,0 ); -if (min_pcnt) { +if (min_pcnt) browser->min_pcnt = min_pcnt; -hist_browser__update_nr_entries (browser); - } +hist_browser__update_nr_entries (browser); browser->pstack =pstack__new (3 );if (browser->pstack ==NULL )
Signature · 1 line
2.6.2
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 3/3] perf hists browser: Update nr entries regardless of min percent
Em Sat, Nov 28, 2015 at 02:32:39AM +0900, Namhyung Kim escreveu:
Quoted 8 lines
When perf report on TUI was called with -S symbol filter, it should update nr entries even if
min_pcntis 0. IIRC the reason was to update nr entries after applying minimum percent threshold. But if symbol filter was given on command line (with -S option), it should usehists->nr_non_filtered_entriesinstead ofhists->nr_entries.So this patch fixes a bug of navigating hists browser that the cursor goes beyond the number of entries when -S (or similar) option is used.
Thanks, tested and applied.
- Arnaldo
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf hists browser: Update nr entries regardless of min percent
In reply to Namhyung Kimperf hists browser: Update nr entries regardless of min percent
Commit-ID: 039050482573e168690d365b8ea1d4f599ebbbd8 Gitweb: http://git.kernel.org/tip/039050482573e168690d365b8ea1d4f599ebbbd8 Author: Namhyung Kim <[email protected]> AuthorDate: Sat, 28 Nov 2015 02:32:39 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 27 Nov 2015 21:53:33 -0300
perf hists browser: Update nr entries regardless of min percent
When perf report on TUI was called with -S symbol filter, it should update nr entries even if min_pcnt is 0. IIRC the reason was to update nr entries after applying minimum percent threshold. But if symbol filter was given on command line (with -S option), it should use hists->nr_non_filtered_entries instead of hists->nr_entries.
So this patch fixes a bug of navigating hists browser that the cursor goes beyond the number of entries when -S (or similar) option is used.
--- tools/perf/ui/browsers/hists.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +2 -3
@@ -2055,10 +2055,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,SLang_reset_tty ();SLang_init_tty (0 ,0 ,0 ); -if (min_pcnt) { +if (min_pcnt) browser->min_pcnt = min_pcnt; -hist_browser__update_nr_entries (browser); - } +hist_browser__update_nr_entries (browser); browser->pstack =pstack__new (3 );if (browser->pstack ==NULL )
Arnaldo Carvalho de Melo
maintainerEm Sat, Nov 28, 2015 at 02:32:37AM +0900, Namhyung Kim escreveu:
Quoted 14 lines
Currently when perf fails to process samples for some reason, it doesn't show any message about the failure. This is very inconvenient for users especially on TUI as screen is reset after the failure.
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-report.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)tools/perf/builtin-report.c +0
-0
tools/perf/builtin-report.c static int __cmd_report(struct report *rep) · line 517
Quoted 6 lines
tools/perf/builtin-report.c +2
-1@@ -513,20 +513,26 @@ static int __cmd_report(struct report *rep)if (rep->cpu_list) { ret =perf_session__cpu_bitmap (session, rep->cpu_list, rep->cpu_bitmap); -if (ret) +if (ret) { +ui__error ("failed to set cpu bitmap\n" );
Why? See below.
Quoted 10 lines
tools/perf/builtin-report.c +2
-1return ret; + } }if (rep->show_threads)perf_read_values_init (&rep->show_threads_values); ret =report__setup_sample_type (rep); -if (ret) +if (ret) {
tools/perf/builtin-report.c static int __cmd_report(struct report *rep) · line 535
Quoted 10 lines
tools/perf/builtin-report.c +5
-1+/* report__setup_sample_type() already showed error message */ return ret; + } ret =perf_session__process_events (session); -if (ret) +if (ret) { +ui__error ("failed to process sample\n" );return ret; + }
I'm applying this because it removes the potential flash, but would be good to have the reason for this failure shown to the user.
- Arnaldo
Arnaldo Carvalho de Melo
maintainerEm Fri, Nov 27, 2015 at 04:56:27PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sat, Nov 28, 2015 at 02:32:37AM +0900, Namhyung Kim escreveu:
Quoted 5 lines
Currently when perf fails to process samples for some reason, it doesn't show any message about the failure. This is very inconvenient for users especially on TUI as screen is reset after the failure.
Signed-off-by Namhyung Kim <[email protected]>
Ah, I added a :
As this was due to those messages from Ingo, right?
- Arnaldo
Quoted 43 lines
Quoted 9 lines
--- tools/perf/builtin-report.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)tools/perf/builtin-report.c +0
-0tools/perf/builtin-report.c static int __cmd_report(struct report *rep) · line 517
Quoted 6 lines
tools/perf/builtin-report.c +2
-1@@ -513,20 +513,26 @@ static int __cmd_report(struct report *rep)if (rep->cpu_list) { ret =perf_session__cpu_bitmap (session, rep->cpu_list, rep->cpu_bitmap); -if (ret) +if (ret) { +ui__error ("failed to set cpu bitmap\n" );Why? See below.
Quoted 10 lines
tools/perf/builtin-report.c +2
-1return ret; + } }if (rep->show_threads)perf_read_values_init (&rep->show_threads_values); ret =report__setup_sample_type (rep); -if (ret) +if (ret) {tools/perf/builtin-report.c static int __cmd_report(struct report *rep) · line 535
Quoted 10 lines
tools/perf/builtin-report.c +5
-1+/* report__setup_sample_type() already showed error message */ return ret; + } ret =perf_session__process_events (session); -if (ret) +if (ret) { +ui__error ("failed to process sample\n" );return ret; + }I'm applying this because it removes the potential flash, but would be good to have the reason for this failure shown to the user.
- Arnaldo
Namhyung Kim
maintainerHi Arnaldo,
Quoted 6 lines · Arnaldo Carvalho de Melo
Em Fri, Nov 27, 2015 at 04:56:27PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 5 lines
Em Sat, Nov 28, 2015 at 02:32:37AM +0900, Namhyung Kim escreveu:
Quoted 4 lines
Currently when perf fails to process samples for some reason, it doesn't show any message about the failure. This is very inconvenient for users especially on TUI as screen is reset after the failure.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Namhyung Kim <[email protected]>Ah, I added a :
Reported-by Ingo Molnar <[email protected]>As this was due to those messages from Ingo, right?
Right.
Quoted 33 lines
Quoted 33 lines
Quoted 10 lines
--- tools/perf/builtin-report.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)tools/perf/builtin-report.c +0
-0tools/perf/builtin-report.c static int __cmd_report(struct report *rep) · line 517
Quoted 6 lines
tools/perf/builtin-report.c +2
-1@@ -513,20 +513,26 @@ static int __cmd_report(struct report *rep)if (rep->cpu_list) { ret =perf_session__cpu_bitmap (session, rep->cpu_list, rep->cpu_bitmap); -if (ret) +if (ret) { +ui__error ("failed to set cpu bitmap\n" );Why? See below.
Quoted 14 lines
tools/perf/builtin-report.c +4
-1return ret; + } }if (rep->show_threads)perf_read_values_init (&rep->show_threads_values); ret =report__setup_sample_type (rep); -if (ret) +if (ret) { +/* report__setup_sample_type() already showed error message */ return ret; + }
Quoted 9 lines
Quoted 9 lines
tools/perf/builtin-report.c static int __cmd_report(struct report *rep) · line 535
Quoted 6 lines
tools/perf/builtin-report.c +3
-1ret =perf_session__process_events (session); -if (ret) +if (ret) { +ui__error ("failed to process sample\n" );return ret; + }I'm applying this because it removes the potential flash, but would be good to have the reason for this failure shown to the user.
Yes, but at least the last error/warning will be shown in the bottom.
Thanks,
Namhyung
tip-bot for Namhyung Kim
merge botperf report: Show error message when processing sample fails
Commit-ID: 25b1606be1a910a63a23c3d1006581c9aad4e6e3 Gitweb: http://git.kernel.org/tip/25b1606be1a910a63a23c3d1006581c9aad4e6e3 Author: Namhyung Kim <[email protected]> AuthorDate: Sat, 28 Nov 2015 02:32:37 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 27 Nov 2015 16:56:32 -0300
perf report: Show error message when processing sample fails
Currently when perf fails to process samples for some reason, it doesn't show any message about the failure. This is very inconvenient for users especially on TUI as screen is reset after the failure.
--- tools/perf/builtin-report.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/builtin-report.c +9 -3
@@ -513,20 +513,26 @@ static int __cmd_report(struct report *rep)if (rep->cpu_list) { ret =perf_session__cpu_bitmap (session, rep->cpu_list, rep->cpu_bitmap); -if (ret) +if (ret) { +ui__error ("failed to set cpu bitmap\n" );return ret; + } }if (rep->show_threads)perf_read_values_init (&rep->show_threads_values); ret =report__setup_sample_type (rep); -if (ret) +if (ret) { +/* report__setup_sample_type() already showed error message */ return ret; + } ret =perf_session__process_events (session); -if (ret) +if (ret) { +ui__error ("failed to process sample\n" );return ret; + }report__warn_kptr_restrict (rep);