Skip to contentSkip to conversation

perf report: Few fixes

PATCH Applied Ravi Bangoria 4 participants 10 messages Nov 14, 2019 – Dec 6, 2019 perf events

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 43d1d410854a..cba8f22e4ffb 100644
@@ -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
#2 lore raw

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 such pr_err with ui__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
---
 tools/perf/util/sort.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/sort.c +5 -5
index 43d1d410854a..cba8f22e4ffb 100644
@@ -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
merge bot Applied
#3 lore raw

[tip: perf/urgent] perf report/top TUI: Replace pr_err() with ui__error()

In reply to Ravi Bangoria
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:     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
index 345b5cc..106d795 100644
@@ -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;
 	}
 
#4 lore raw

PATCH v2 2/3 perf report: Make -F more strict like -s

In reply to Ravi Bangoria

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
index cba8f22e4ffb..9999f6853440 100644
@@ -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
merge bot Applied
#5 lore raw

[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
index 106d795..9fcba28 100644
@@ -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);
 	}
 
#6 lore raw

PATCH v2 3/3 perf report: Bail out --mem-mode if mem info is not available

In reply to Ravi Bangoria

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] 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
index aae0e57c60fb..7c854d35c9ef 100644
@@ -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
merge bot Applied
#7 lore raw

[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] 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
index 830d563..387311c 100644
@@ -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)) {
#8 lore raw
In reply to Ravi Bangoria

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_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(-)
Acked-by on the v2 series
#9 lore raw
In reply to Ravi Bangoria
Quoted 12 lines · Ravi Bangoria

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

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