perf report: Few fixes
v2 cover perf report: Few fixes
v1: https://lore.kernel.org/r/[email protected]
v1 fixed a segfault when -F phys_daddr is used in perf report without --mem-mode. Arnaldo suggested to bail out the option completely in such case instead of showing 0 values.
Ravi Bangoria (3):
perf hists: Replace pr_err with ui__error
perf report: Make -F more strict like -s
perf report: Error out for mem mode fields if mem info is not
available
tools/perf/builtin-report.c | 8 ++++++++ tools/perf/util/sort.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)
Signature · 1 line
2.21.0
PATCH v2 1/3 perf hists: Replace pr_err with ui__error
pr_err() in tui mode does not print anyting on the screen and just quits. Replace such pr_err with ui__error.
Before:
$ ./perf report -s + $
After:
$ ./perf report -s +
┌─Error:────────────────┐
│Invalid --sort key: `+'│
│ │
│Press any key... │
└───────────────────────┘--- tools/perf/util/sort.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/sort.c +5 -5
@@ -2696,12 +2696,12 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str, ret =sort_dimension__add (list, tok, evlist, level);if (ret == -EINVAL ) {if (!cacheline_size () && !strncasecmp (tok,"dcacheline" ,strlen (tok))) -pr_err ("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system" ); +ui__error ("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system" );else -pr_err ("Invalid --sort key: `%s'" , tok); +ui__error ("Invalid --sort key: `%s'" , tok);break ; }else if (ret == -ESRCH ) { -pr_err ("Unknown --sort key: `%s'" , tok); +ui__error ("Unknown --sort key: `%s'" , tok);break ; } }
@@ -2758,7 +2758,7 @@ static int setup_sort_order(struct evlist *evlist)return 0 ;if (sort_order[1 ] =='\0' ) { -pr_err ("Invalid --sort key: `+'" ); +ui__error ("Invalid --sort key: `+'" );return -EINVAL ; }
@@ -3049,7 +3049,7 @@ static int __setup_output_field(void) strp++;if (!strlen (strp)) { -pr_err ("Invalid --fields key: `+'" ); +ui__error ("Invalid --fields key: `+'" ); goto out; }
Signature · 1 line
2.21.0
Re: [PATCH v2 1/3] perf hists: Replace pr_err with ui__error
Em Thu, Nov 14, 2019 at 06:52:11PM +0530, Ravi Bangoria escreveu:
Quoted 7 lines
pr_err()in tui mode does not print anyting on the screen and just quits. Replace suchpr_errwithui__error.Before:
$ ./perf report -s + $
Quoted 8 lines
After:
$ ./perf report -s +┌─Error:────────────────┐ │Invalid --sort key: `+'│ │ │ │Press any key... │ └───────────────────────┘
Cool, I've seen this before and should have investigated, even today it happened... Thanks for fixing it, tested and applied.
- Arnaldo
Quoted 45 lines
Signed-off-by Ravi Bangoria <[email protected]>--- tools/perf/util/sort.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)tools/perf/util/sort.c +5
-5@@ -2696,12 +2696,12 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str, ret =sort_dimension__add (list, tok, evlist, level);if (ret == -EINVAL ) {if (!cacheline_size () && !strncasecmp (tok,"dcacheline" ,strlen (tok))) -pr_err ("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system" ); +ui__error ("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system" );else -pr_err ("Invalid --sort key: `%s'" , tok); +ui__error ("Invalid --sort key: `%s'" , tok);break ; }else if (ret == -ESRCH ) { -pr_err ("Unknown --sort key: `%s'" , tok); +ui__error ("Unknown --sort key: `%s'" , tok);break ; } }@@ -2758,7 +2758,7 @@ static int setup_sort_order(struct evlist *evlist)return 0 ;if (sort_order[1 ] =='\0' ) { -pr_err ("Invalid --sort key: `+'" ); +ui__error ("Invalid --sort key: `+'" );return -EINVAL ; }@@ -3049,7 +3049,7 @@ static int __setup_output_field(void) strp++;if (!strlen (strp)) { -pr_err ("Invalid --fields key: `+'" ); +ui__error ("Invalid --fields key: `+'" ); goto out; }Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
[tip: perf/urgent] perf report/top TUI: Replace pr_err() with ui__error()
In reply to Ravi BangoriaThe following commit has been merged into the perf/urgent branch of tip:
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: ae87405fb511d6220ce86b9a60807fef92e1a934 Gitweb: https://git.kernel.org/tip/ae87405fb511d6220ce86b9a60807fef92e1a934 Author: Ravi Bangoria <[email protected]> AuthorDate: Thu, 14 Nov 2019 18:52:11 +05:30 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 04 Dec 2019 12:27:14 -03:00
perf report/top TUI: Replace pr_err() with ui__error()
pr_err() in TUI mode does not print anyting on the screen and just quits.
Replace such pr_err() with ui__error().
Before:
$ perf report -s + $
After:
$ perf report -s +
┌─Error:────────────────┐
│Invalid --sort key: `+'│
│ │
│Press any key... │
└───────────────────────┘--- tools/perf/util/sort.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/sort.c +5 -5
@@ -2681,12 +2681,12 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str, ret =sort_dimension__add (list, tok, evlist, level);if (ret == -EINVAL ) {if (!cacheline_size () && !strncasecmp (tok,"dcacheline" ,strlen (tok))) -pr_err ("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system" ); +ui__error ("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system" );else -pr_err ("Invalid --sort key: `%s'" , tok); +ui__error ("Invalid --sort key: `%s'" , tok);break ; }else if (ret == -ESRCH ) { -pr_err ("Unknown --sort key: `%s'" , tok); +ui__error ("Unknown --sort key: `%s'" , tok);break ; } }
@@ -2743,7 +2743,7 @@ static int setup_sort_order(struct evlist *evlist)return 0 ;if (sort_order[1 ] =='\0' ) { -pr_err ("Invalid --sort key: `+'" ); +ui__error ("Invalid --sort key: `+'" );return -EINVAL ; }
@@ -3034,7 +3034,7 @@ static int __setup_output_field(void) strp++;if (!strlen (strp)) { -pr_err ("Invalid --fields key: `+'" ); +ui__error ("Invalid --fields key: `+'" ); goto out; }
PATCH v2 2/3 perf report: Make -F more strict like -s
In reply to Ravi BangoriaCurrently -F allows branch-mode / mem-mode fields with -F even when perf report is not running in that mode. Don't allow that.
--- tools/perf/util/sort.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/sort.c +6 -0
@@ -2974,6 +2974,9 @@ int output_field_add(struct perf_hpp_list *list, char *tok)if (strncasecmp (tok, sd->name,strlen (tok)))continue ; +if (sort__mode !=SORT_MODE__BRANCH ) +return -EINVAL ; +return __sort_dimension__add_output (list, sd); }
@@ -2983,6 +2986,9 @@ int output_field_add(struct perf_hpp_list *list, char *tok)if (strncasecmp (tok, sd->name,strlen (tok)))continue ; +if (sort__mode !=SORT_MODE__MEMORY ) +return -EINVAL ; +return __sort_dimension__add_output (list, sd); }
Signature · 1 line
2.21.0
[tip: perf/urgent] perf report: Make -F more strict like -s
The following commit has been merged into the perf/urgent branch of tip:
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: aa6b3c99236b49a3e842d7272efa2529f15f7d8a Gitweb: https://git.kernel.org/tip/aa6b3c99236b49a3e842d7272efa2529f15f7d8a Author: Ravi Bangoria <[email protected]> AuthorDate: Thu, 14 Nov 2019 18:52:12 +05:30 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 04 Dec 2019 12:32:40 -03:00
perf report: Make -F more strict like -s
Currently -F allows branch-mode / mem-mode fields with -F even when perf report is not running in that mode. Don't allow that.
--- tools/perf/util/sort.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/sort.c +6 -0
@@ -2959,6 +2959,9 @@ int output_field_add(struct perf_hpp_list *list, char *tok)if (strncasecmp (tok, sd->name,strlen (tok)))continue ; +if (sort__mode !=SORT_MODE__MEMORY ) +return -EINVAL ; +return __sort_dimension__add_output (list, sd); }
@@ -2968,6 +2971,9 @@ int output_field_add(struct perf_hpp_list *list, char *tok)if (strncasecmp (tok, sd->name,strlen (tok)))continue ; +if (sort__mode !=SORT_MODE__BRANCH ) +return -EINVAL ; +return __sort_dimension__add_output (list, sd); }
PATCH v2 3/3 perf report: Bail out --mem-mode if mem info is not available
In reply to Ravi BangoriaIf perf.data is recorded without -d, don't allow user to use --mem-mode with perf report. symbol_daddr and phys_daddr can be recorded separately and may be present in the perf.data but at the report time they are associated with mem-mode fields and thus this restriction applies to them as well.
Before:
$ ./perf record ls
$ ./perf report --mem-mode --stdio
# Overhead Local Weight Memory access Symbol
# ........ ............ ............. .......................
55.56% 0 N/A [k] 0xffffffff81a00ae7 After:
$ ./perf report --mem-mode --stdio Error: Selected --mem-mode but no mem data. Did you call perf record without -d?
--- tools/perf/builtin-report.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/perf/builtin-report.c +8 -0
@@ -383,6 +383,14 @@ static int report__setup_sample_type(struct report *rep) } } +if (sort__mode ==SORT_MODE__MEMORY ) { +if (!is_pipe && !(sample_type &PERF_SAMPLE_DATA_SRC )) { +ui__error ("Selected --mem-mode but no mem data. " +"Did you call perf record without -d?\n" ); +return -1 ; + } + } +if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {if ((sample_type &PERF_SAMPLE_REGS_USER ) && (sample_type &PERF_SAMPLE_STACK_USER )) {
Signature · 1 line
2.21.0
[tip: perf/urgent] perf report: Bail out --mem-mode if mem info is not available
The following commit has been merged into the perf/urgent branch of tip:
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: bb30acae4c4dacfa2622387c5ad5563246810583 Gitweb: https://git.kernel.org/tip/bb30acae4c4dacfa2622387c5ad5563246810583 Author: Ravi Bangoria <[email protected]> AuthorDate: Thu, 14 Nov 2019 18:52:13 +05:30 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Wed, 04 Dec 2019 12:34:02 -03:00
perf report: Bail out --mem-mode if mem info is not available
If perf.data is recorded without -d, don't allow user to use --mem-mode with 'perf report'. symbol_daddr and phys_daddr can be recorded separately and may be present in the perf.data but at the report time they are associated with mem-mode fields and thus this restriction applies to them as well.
Before:
$ perf record ls
$ perf report --mem-mode --stdio
# Overhead Local Weight Memory access Symbol
# ........ ............ ............. .......................
55.56% 0 N/A [k] 0xffffffff81a00ae7After:
$ perf report --mem-mode --stdio Error: Selected --mem-mode but no mem data. Did you call perf record without -d?
--- tools/perf/builtin-report.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/perf/builtin-report.c +8 -0
@@ -388,6 +388,14 @@ static int report__setup_sample_type(struct report *rep) } } +if (sort__mode ==SORT_MODE__MEMORY ) { +if (!is_pipe && !(sample_type &PERF_SAMPLE_DATA_SRC )) { +ui__error ("Selected --mem-mode but no mem data. " +"Did you call perf record without -d?\n" ); +return -1 ; + } + } +if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {if ((sample_type &PERF_SAMPLE_REGS_USER ) && (sample_type &PERF_SAMPLE_STACK_USER )) {
Arnaldo, Jiri,
Any feedback?
Ravi
Quoted 16 lines · Ravi Bangoria
v1: https://lore.kernel.org/r/[email protected]
v1 fixed a segfault when -F
phys_daddris used in perf report without --mem-mode. Arnaldo suggested to bail out the option completely in such case instead of showing 0 values.Ravi Bangoria (3):
perf hists: Replacepr_errwithui__error
perf report: Make -F more strict like -s
perf report: Error out for mem mode fields if mem info is not
availabletools/perf/builtin-report.c | 8 ++++++++ tools/perf/util/sort.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)
Quoted 12 lines · Ravi Bangoria
v1: https://lore.kernel.org/r/[email protected]
v1 fixed a segfault when -F
phys_daddris used in perf report without --mem-mode. Arnaldo suggested to bail out the option completely in such case instead of showing 0 values.Ravi Bangoria (3):
perf hists: Replacepr_errwithui__error
perf report: Make -F more strict like -s
perf report: Error out for mem mode fields if mem info is not
available
Quoted 3 lines
tools/perf/builtin-report.c | 8 ++++++++ tools/perf/util/sort.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-)
looks good
thanks,
jirka