Skip to contentSkip to conversation

perf tools: Make perf_hpp__init respect output dimensions

RFC In review Jiri Olsa 4 participants 10 messages Oct 6, 2015 – Oct 8, 2015 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

cover perf tools: Make perf_hpp__init respect output dimensions

hi,
The perf_hpp__init currently does not respect sorting dimensions and the setup_sorting function could endup queueing same format twice. That screwed up the perf_hpp__list and got stuck in loop within perf_hpp__setup_output_field function.

  $ perf report -F +overhead
  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
  1506    {
     #0  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
     #1  0x00000000004c139d in perf_hpp__same_sort_entry (a=a@entry=0x880440 <perf_hpp.format>, b=b@entry=0x2bb2fe0) at util/sort.c:1380
     #2  0x00000000004f8d3c in perf_hpp__setup_output_field () at ui/hist.c:554
     #3  0x00000000004c1d1e in setup_sorting () at util/sort.c:1984
     #4  0x000000000042efbf in cmd_report (argc=0, argv=0x7ffea5a0e790, prefix=<optimized out>) at builtin-report.c:874
     #5  0x0000000000476f13 in run_builtin (p=p@entry=0x875628 <commands+168>, argc=argc@entry=3, argv=argv@entry=0x7ffea5a0e790) at perf.c:385
     #6  0x000000000047710b in handle_internal_command (argc=3, argv=0x7ffea5a0e790) at perf.c:445
     #7  0x0000000000477176 in run_argv (argcp=argcp@entry=0x7ffea5a0e5fc, argv=argv@entry=0x7ffea5a0e5f0) at perf.c:489
     #8  0x00000000004773e7 in main (argc=3, argv=0x7ffea5a0e790) at perf.c:606

Using hpp_dimension__add_output function to register the output column. It will also mark the dimension as taken and omit above stuck.

It might need some other changes.. not sure, Namhyung? ;-)

Available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/cols

thanks,
jirka

---
Jiri Olsa (3):
perf tools: Get rid of superfluos call to reset_dimensions perf tools: Introduce hpp_dimension__add_output function perf tools: Use hpp_dimension__add_output to register hpp columns

 tools/perf/ui/hist.c   | 16 ++++++++--------
 tools/perf/util/sort.c |  8 ++++++--
 tools/perf/util/sort.h |  2 ++
 3 files changed, 16 insertions(+), 10 deletions(-)
author reviewer
#1 lore raw

PATCH 1/3 perf tools: Get rid of superfluos call to reset_dimensions

There's no need to call reset_dimensions within __setup_output_field function. It's already called in its caller setup_sorting right before perf_hpp__init, which will be changed in following patch to respect taken dimension.

---
 tools/perf/util/sort.c | 2 --
 1 file changed, 2 deletions(-)
tools/perf/util/sort.c +0 -2
index ee94b728fca4..8521e3c89b8d 100644
@@ -1917,8 +1917,6 @@ static int __setup_output_field(void)
 	if (field_order == NULL)
 		return 0;
 
-	reset_dimensions();
-
 	strp = str = strdup(field_order);
 	if (str == NULL) {
 		error("Not enough memory to setup output fields");
Signature · 1 line
2.4.3
#2 lore raw

[tip:perf/core] perf tools: Get rid of superfluos call to reset_dimensions

perf tools: Get rid of superfluos call to reset_dimensions
Commit-ID:  0974d2c9719a4c74fea0f6886b9922b100b903a6
Gitweb:     http://git.kernel.org/tip/0974d2c9719a4c74fea0f6886b9922b100b903a6
Author:     Jiri Olsa <[email protected]>
AuthorDate: Tue, 6 Oct 2015 14:25:10 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 6 Oct 2015 18:04:58 -0300

perf tools: Get rid of superfluos call to reset_dimensions

There's no need to call reset_dimensions within __setup_output_field function. It's already called in its caller setup_sorting right before perf_hpp__init, which will be changed in following patch to respect taken dimension.

---
 tools/perf/util/sort.c | 2 --
 1 file changed, 2 deletions(-)
tools/perf/util/sort.c +0 -2
index ee94b72..8521e3c 100644
@@ -1917,8 +1917,6 @@ static int __setup_output_field(void)
 	if (field_order == NULL)
 		return 0;
 
-	reset_dimensions();
-
 	strp = str = strdup(field_order);
 	if (str == NULL) {
 		error("Not enough memory to setup output fields");
author reviewer
#3 lore raw

PATCH 2/3 perf tools: Introduce hpp_dimension__add_output function

In reply to Jiri Olsa

This function will allow to register output column from ui code and respect taken sort/output dimensions.

---
 tools/perf/util/sort.c | 6 ++++++
 tools/perf/util/sort.h | 2 ++
 2 files changed, 8 insertions(+)
tools/perf/util/sort.c +6 -0
index 8521e3c89b8d..2d8ccd4d9e1b 100644
@@ -1577,6 +1577,12 @@ static int __hpp_dimension__add_output(struct hpp_dimension *hd)
 	return 0;
 }
 
+int hpp_dimension__add_output(unsigned col)
+{
+	BUG_ON(col >= PERF_HPP__MAX_INDEX);
+	return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
+}
+
 int sort_dimension__add(const char *tok)
 {
 	unsigned int i;
tools/perf/util/sort.h +2 -0
index 33b3d30e18d3..31228851e397 100644
@@ -234,4 +234,6 @@ void perf_hpp__set_elide(int idx, bool elide);
 int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset);
 
 bool is_strict_order(const char *order);
+
+int hpp_dimension__add_output(unsigned col);
 #endif	/* __PERF_SORT_H */
Signature · 1 line
2.4.3
#4 lore raw

[tip:perf/core] perf tools: Introduce hpp_dimension__add_output function

perf tools: Introduce hpp_dimension__add_output function
Commit-ID:  beeaaeb3684d97e89548c1b6b6275329214014df
Gitweb:     http://git.kernel.org/tip/beeaaeb3684d97e89548c1b6b6275329214014df
Author:     Jiri Olsa <[email protected]>
AuthorDate: Tue, 6 Oct 2015 14:25:11 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 6 Oct 2015 18:04:59 -0300

perf tools: Introduce hpp_dimension__add_output function

This function will allow to register output column from ui code and respect taken sort/output dimensions.

---
 tools/perf/util/sort.c | 6 ++++++
 tools/perf/util/sort.h | 2 ++
 2 files changed, 8 insertions(+)
tools/perf/util/sort.c +6 -0
index 8521e3c..2d8ccd4 100644
@@ -1577,6 +1577,12 @@ static int __hpp_dimension__add_output(struct hpp_dimension *hd)
 	return 0;
 }
 
+int hpp_dimension__add_output(unsigned col)
+{
+	BUG_ON(col >= PERF_HPP__MAX_INDEX);
+	return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
+}
+
 int sort_dimension__add(const char *tok)
 {
 	unsigned int i;
tools/perf/util/sort.h +2 -0
index 33b3d30..3122885 100644
@@ -234,4 +234,6 @@ void perf_hpp__set_elide(int idx, bool elide);
 int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset);
 
 bool is_strict_order(const char *order);
+
+int hpp_dimension__add_output(unsigned col);
 #endif	/* __PERF_SORT_H */
author reviewer
#5 lore raw

PATCH 3/3 perf tools: Use hpp_dimension__add_output to register hpp columns

In reply to Jiri Olsa

The perf_hpp__init currently does not respect sorting dimensions and the setup_sorting function could endup queueing same format twice. That screwed up the perf_hpp__list and got stuck in loop within perf_hpp__setup_output_field function.

  $ perf report -F +overhead
  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
  1506    {
     #0  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
     #1  0x00000000004c139d in perf_hpp__same_sort_entry (a=a@entry=0x880440 <perf_hpp.format>, b=b@entry=0x2bb2fe0) at util/sort.c:1380
     #2  0x00000000004f8d3c in perf_hpp__setup_output_field () at ui/hist.c:554
     #3  0x00000000004c1d1e in setup_sorting () at util/sort.c:1984
     #4  0x000000000042efbf in cmd_report (argc=0, argv=0x7ffea5a0e790, prefix=<optimized out>) at builtin-report.c:874
     #5  0x0000000000476f13 in run_builtin (p=p@entry=0x875628 <commands+168>, argc=argc@entry=3, argv=argv@entry=0x7ffea5a0e790) at perf.c:385
     #6  0x000000000047710b in handle_internal_command (argc=3, argv=0x7ffea5a0e790) at perf.c:445
     #7  0x0000000000477176 in run_argv (argcp=argcp@entry=0x7ffea5a0e5fc, argv=argv@entry=0x7ffea5a0e5f0) at perf.c:489
     #8  0x00000000004773e7 in main (argc=3, argv=0x7ffea5a0e790) at perf.c:606

Using hpp_dimension__add_output function to register the output column. It will also mark the dimension as taken and omit above stuck.

---
 tools/perf/ui/hist.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/perf/ui/hist.c +8 -8
index 25d608394d74..5029ba2b55af 100644
@@ -463,27 +463,27 @@ void perf_hpp__init(void)
 		return;
 
 	if (symbol_conf.cumulate_callchain) {
-		perf_hpp__column_enable(PERF_HPP__OVERHEAD_ACC);
+		hpp_dimension__add_output(PERF_HPP__OVERHEAD_ACC);
 		perf_hpp__format[PERF_HPP__OVERHEAD].name = "Self";
 	}
 
-	perf_hpp__column_enable(PERF_HPP__OVERHEAD);
+	hpp_dimension__add_output(PERF_HPP__OVERHEAD);
 
 	if (symbol_conf.show_cpu_utilization) {
-		perf_hpp__column_enable(PERF_HPP__OVERHEAD_SYS);
-		perf_hpp__column_enable(PERF_HPP__OVERHEAD_US);
+		hpp_dimension__add_output(PERF_HPP__OVERHEAD_SYS);
+		hpp_dimension__add_output(PERF_HPP__OVERHEAD_US);
 
 		if (perf_guest) {
-			perf_hpp__column_enable(PERF_HPP__OVERHEAD_GUEST_SYS);
-			perf_hpp__column_enable(PERF_HPP__OVERHEAD_GUEST_US);
+			hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_SYS);
+			hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_US);
 		}
 	}
 
 	if (symbol_conf.show_nr_samples)
-		perf_hpp__column_enable(PERF_HPP__SAMPLES);
+		hpp_dimension__add_output(PERF_HPP__SAMPLES);
 
 	if (symbol_conf.show_total_period)
-		perf_hpp__column_enable(PERF_HPP__PERIOD);
+		hpp_dimension__add_output(PERF_HPP__PERIOD);
 
 	/* prepend overhead field for backward compatiblity.  */
 	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
Signature · 1 line
2.4.3
#6 lore raw

Re: [PATCH 3/3] perf tools: Use hpp_dimension__add_output to register hpp columns

Em Tue, Oct 06, 2015 at 02:25:12PM +0200, Jiri Olsa escreveu:

Quoted 20 lines

The perf_hpp__init currently does not respect sorting dimensions and the setup_sorting function could endup queueing same format twice. That screwed up the perf_hpp__list and got stuck in loop within perf_hpp__setup_output_field function.

  $ perf report -F +overhead
  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
  1506    {
     #0  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
     #1  0x00000000004c139d in perf_hpp__same_sort_entry (a=a@entry=0x880440 <perf_hpp.format>, b=b@entry=0x2bb2fe0) at util/sort.c:1380
     #2  0x00000000004f8d3c in perf_hpp__setup_output_field () at ui/hist.c:554
     #3  0x00000000004c1d1e in setup_sorting () at util/sort.c:1984
     #4  0x000000000042efbf in cmd_report (argc=0, argv=0x7ffea5a0e790, prefix=<optimized out>) at builtin-report.c:874
     #5  0x0000000000476f13 in run_builtin (p=p@entry=0x875628 <commands+168>, argc=argc@entry=3, argv=argv@entry=0x7ffea5a0e790) at perf.c:385
     #6  0x000000000047710b in handle_internal_command (argc=3, argv=0x7ffea5a0e790) at perf.c:445
     #7  0x0000000000477176 in run_argv (argcp=argcp@entry=0x7ffea5a0e5fc, argv=argv@entry=0x7ffea5a0e5f0) at perf.c:489
     #8  0x00000000004773e7 in main (argc=3, argv=0x7ffea5a0e790) at perf.c:606
Quoted 3 lines

Using hpp_dimension__add_output function to register the output column. It will also mark the dimension as taken and omit above stuck.

Thanks, did a quick review, looks sane, tested, fixed the problem, applied.

- Arnaldo

#7 lore raw

[tip:perf/core] perf tools: Use hpp_dimension__add_output to register hpp columns

In reply to Jiri Olsa
perf tools: Use hpp_dimension__add_output to register hpp columns
Commit-ID:  1178bfd41f3ab6914eb6884875b776bc3032c9b5
Gitweb:     http://git.kernel.org/tip/1178bfd41f3ab6914eb6884875b776bc3032c9b5
Author:     Jiri Olsa <[email protected]>
AuthorDate: Tue, 6 Oct 2015 14:25:12 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 6 Oct 2015 18:04:59 -0300

perf tools: Use hpp_dimension__add_output to register hpp columns

The perf_hpp__init currently does not respect sorting dimensions and the setup_sorting function could endup queueing same format twice. That screwed up the perf_hpp__list and got stuck in loop within perf_hpp__setup_output_field function.

  $ perf report -F +overhead
  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
  1506    {
     #0  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
     #1  0x00000000004c139d in perf_hpp__same_sort_entry (a=a@entry=0x880440 <perf_hpp.format>, b=b@entry=0x2bb2fe0) at util/sort.c:1380
     #2  0x00000000004f8d3c in perf_hpp__setup_output_field () at ui/hist.c:554
     #3  0x00000000004c1d1e in setup_sorting () at util/sort.c:1984
     #4  0x000000000042efbf in cmd_report (argc=0, argv=0x7ffea5a0e790, prefix=<optimized out>) at builtin-report.c:874
     #5  0x0000000000476f13 in run_builtin (p=p@entry=0x875628 <commands+168>, argc=argc@entry=3, argv=argv@entry=0x7ffea5a0e790) at perf.c:385
     #6  0x000000000047710b in handle_internal_command (argc=3, argv=0x7ffea5a0e790) at perf.c:445
     #7  0x0000000000477176 in run_argv (argcp=argcp@entry=0x7ffea5a0e5fc, argv=argv@entry=0x7ffea5a0e5f0) at perf.c:489
     #8  0x00000000004773e7 in main (argc=3, argv=0x7ffea5a0e790) at perf.c:606

Using hpp_dimension__add_output function to register the output column. It will also mark the dimension as taken and omit above stuck.

---
 tools/perf/ui/hist.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/perf/ui/hist.c +8 -8
index 25d6083..5029ba2 100644
@@ -463,27 +463,27 @@ void perf_hpp__init(void)
 		return;
 
 	if (symbol_conf.cumulate_callchain) {
-		perf_hpp__column_enable(PERF_HPP__OVERHEAD_ACC);
+		hpp_dimension__add_output(PERF_HPP__OVERHEAD_ACC);
 		perf_hpp__format[PERF_HPP__OVERHEAD].name = "Self";
 	}
 
-	perf_hpp__column_enable(PERF_HPP__OVERHEAD);
+	hpp_dimension__add_output(PERF_HPP__OVERHEAD);
 
 	if (symbol_conf.show_cpu_utilization) {
-		perf_hpp__column_enable(PERF_HPP__OVERHEAD_SYS);
-		perf_hpp__column_enable(PERF_HPP__OVERHEAD_US);
+		hpp_dimension__add_output(PERF_HPP__OVERHEAD_SYS);
+		hpp_dimension__add_output(PERF_HPP__OVERHEAD_US);
 
 		if (perf_guest) {
-			perf_hpp__column_enable(PERF_HPP__OVERHEAD_GUEST_SYS);
-			perf_hpp__column_enable(PERF_HPP__OVERHEAD_GUEST_US);
+			hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_SYS);
+			hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_US);
 		}
 	}
 
 	if (symbol_conf.show_nr_samples)
-		perf_hpp__column_enable(PERF_HPP__SAMPLES);
+		hpp_dimension__add_output(PERF_HPP__SAMPLES);
 
 	if (symbol_conf.show_total_period)
-		perf_hpp__column_enable(PERF_HPP__PERIOD);
+		hpp_dimension__add_output(PERF_HPP__PERIOD);
 
 	/* prepend overhead field for backward compatiblity.  */
 	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
maintainer Acked-by on the v1 series
#8 lore raw
In reply to Jiri Olsa
Quoted 21 lines · Jiri Olsa

hi,
The perf_hpp__init currently does not respect sorting dimensions and the setup_sorting function could endup queueing same format twice. That screwed up the perf_hpp__list and got stuck in loop within perf_hpp__setup_output_field function.

  $ perf report -F +overhead
  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
  1506    {
     #0  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
     #1  0x00000000004c139d in perf_hpp__same_sort_entry (a=a@entry=0x880440 <perf_hpp.format>, b=b@entry=0x2bb2fe0) at util/sort.c:1380
     #2  0x00000000004f8d3c in perf_hpp__setup_output_field () at ui/hist.c:554
     #3  0x00000000004c1d1e in setup_sorting () at util/sort.c:1984
     #4  0x000000000042efbf in cmd_report (argc=0, argv=0x7ffea5a0e790, prefix=<optimized out>) at builtin-report.c:874
     #5  0x0000000000476f13 in run_builtin (p=p@entry=0x875628 <commands+168>, argc=argc@entry=3, argv=argv@entry=0x7ffea5a0e790) at perf.c:385
     #6  0x000000000047710b in handle_internal_command (argc=3, argv=0x7ffea5a0e790) at perf.c:445
     #7  0x0000000000477176 in run_argv (argcp=argcp@entry=0x7ffea5a0e5fc, argv=argv@entry=0x7ffea5a0e5f0) at perf.c:489
     #8  0x00000000004773e7 in main (argc=3, argv=0x7ffea5a0e790) at perf.c:606
Quoted 5 lines

Using hpp_dimension__add_output function to register the output column. It will also mark the dimension as taken and omit above stuck.

It might need some other changes.. not sure, Namhyung? ;-)

Nope. It looks good to me as is. :) It should work once it sets up the output field and sort list properly, so

Thanks,
Namhyung

Quoted 19 lines

Available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/cols

thanks,
jirka

---
Jiri Olsa (3):
perf tools: Get rid of superfluos call to reset_dimensions perf tools: Introduce hpp_dimension__add_output function perf tools: Use hpp_dimension__add_output to register hpp columns

 tools/perf/ui/hist.c   | 16 ++++++++--------
 tools/perf/util/sort.c |  8 ++++++--
 tools/perf/util/sort.h |  2 ++
 3 files changed, 16 insertions(+), 10 deletions(-)
Signature · 2 lines
Thanks,
Namhyung
#9 lore raw

Em Tue, Oct 06, 2015 at 11:04:28PM +0900, Namhyung Kim escreveu:

Quoted 26 lines · Jiri Olsa
Quoted 25 lines

hi,
The perf_hpp__init currently does not respect sorting dimensions and the setup_sorting function could endup queueing same format twice. That screwed up the perf_hpp__list and got stuck in loop within perf_hpp__setup_output_field function.

  $ perf report -F +overhead
  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
  1506    {
     #0  0x00000000004c1355 in perf_hpp__is_sort_entry (format=format@entry=0x880440 <perf_hpp.format>) at util/sort.c:1506
     #1  0x00000000004c139d in perf_hpp__same_sort_entry (a=a@entry=0x880440 <perf_hpp.format>, b=b@entry=0x2bb2fe0) at util/sort.c:1380
     #2  0x00000000004f8d3c in perf_hpp__setup_output_field () at ui/hist.c:554
     #3  0x00000000004c1d1e in setup_sorting () at util/sort.c:1984
     #4  0x000000000042efbf in cmd_report (argc=0, argv=0x7ffea5a0e790, prefix=<optimized out>) at builtin-report.c:874
     #5  0x0000000000476f13 in run_builtin (p=p@entry=0x875628 <commands+168>, argc=argc@entry=3, argv=argv@entry=0x7ffea5a0e790) at perf.c:385
     #6  0x000000000047710b in handle_internal_command (argc=3, argv=0x7ffea5a0e790) at perf.c:445
     #7  0x0000000000477176 in run_argv (argcp=argcp@entry=0x7ffea5a0e5fc, argv=argv@entry=0x7ffea5a0e5f0) at perf.c:489
     #8  0x00000000004773e7 in main (argc=3, argv=0x7ffea5a0e790) at perf.c:606

Using hpp_dimension__add_output function to register the output column. It will also mark the dimension as taken and omit above stuck.

Quoted 6 lines
Quoted 1 line

It might need some other changes.. not sure, Namhyung? ;-)

Nope. It looks good to me as is. :) It should work once it sets up the output field and sort list properly, so

Thanks, added.

- Arnaldo