[tip:perf/core] perf report: Add --hierarchy option

2016-02-24 Thread tip-bot for Namhyung Kim
Commit-ID:  4251446d778e669db5ac9f86b02d38064bdbbf9a
Gitweb: http://git.kernel.org/tip/4251446d778e669db5ac9f86b02d38064bdbbf9a
Author: Namhyung Kim 
AuthorDate: Thu, 25 Feb 2016 00:13:48 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 24 Feb 2016 20:21:15 -0300

perf report: Add --hierarchy option

The --hierarchy option is to show output in hierarchy mode.  It extends
folding/unfolding in the TUI and GTK browsers to support sort items as
well as callchains.  Users can toggle the items to see the performance
result at wanted level.

  $ perf report --hierarchy --tui
   Overhead   Command / Shared Object / Symbol
  --
  +  32.96%   gnome-shell
  -  15.11%   swapper
 -  14.97%   [kernel.vmlinux]
   6.82%[k] intel_idle
   0.66%[k] menu_select
   0.43%[k] __hrtimer_start_range_ns
  ...

Signed-off-by: Namhyung Kim 
Acked-by: Pekka Enberg 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1456326830-30456-17-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-report.txt |  3 +++
 tools/perf/Documentation/tips.txt|  1 +
 tools/perf/builtin-report.c  | 17 +
 3 files changed, 21 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index 89cab84..1211399 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -401,6 +401,9 @@ include::itrace.txt[]
 --raw-trace::
When displaying traceevent output, do not use print fmt or plugins.
 
+--hierarchy::
+   Enable hierarchical output.
+
 include::callchain-overhead-calculation.txt[]
 
 SEE ALSO
diff --git a/tools/perf/Documentation/tips.txt 
b/tools/perf/Documentation/tips.txt
index e0ce957..5950b5a 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -27,3 +27,4 @@ Skip collecing build-id when recording: perf record -B
 To change sampling frequency to 100 Hz: perf record -F 100
 See assembly instructions with percentage: perf annotate 
 If you prefer Intel style assembly, try: perf annotate -M intel
+For hierarchical output, try: perf report --hierarchy
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 760e886..f4d8244 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -811,6 +811,8 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
"only show processor socket that match with this filter"),
OPT_BOOLEAN(0, "raw-trace", _conf.raw_trace,
"Show raw trace event output (do not use print fmt or 
plugins)"),
+   OPT_BOOLEAN(0, "hierarchy", _conf.report_hierarchy,
+   "Show entries in a hierarchy"),
OPT_END()
};
struct perf_data_file file = {
@@ -920,6 +922,21 @@ repeat:
symbol_conf.cumulate_callchain = false;
}
 
+   if (symbol_conf.report_hierarchy) {
+   /* disable incompatible options */
+   symbol_conf.event_group = false;
+   symbol_conf.cumulate_callchain = false;
+
+   if (field_order) {
+   pr_err("Error: --hierarchy and --fields options cannot 
be used together\n");
+   parse_options_usage(report_usage, options, "F", 1);
+   parse_options_usage(NULL, options, "hierarchy", 0);
+   goto error;
+   }
+
+   sort__need_collapse = true;
+   }
+
/* Force tty output for header output and per-thread stat. */
if (report.header || report.header_only || report.show_threads)
use_browser = 0;


[tip:perf/core] perf report: Add --hierarchy option

2016-02-24 Thread tip-bot for Namhyung Kim
Commit-ID:  4251446d778e669db5ac9f86b02d38064bdbbf9a
Gitweb: http://git.kernel.org/tip/4251446d778e669db5ac9f86b02d38064bdbbf9a
Author: Namhyung Kim 
AuthorDate: Thu, 25 Feb 2016 00:13:48 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 24 Feb 2016 20:21:15 -0300

perf report: Add --hierarchy option

The --hierarchy option is to show output in hierarchy mode.  It extends
folding/unfolding in the TUI and GTK browsers to support sort items as
well as callchains.  Users can toggle the items to see the performance
result at wanted level.

  $ perf report --hierarchy --tui
   Overhead   Command / Shared Object / Symbol
  --
  +  32.96%   gnome-shell
  -  15.11%   swapper
 -  14.97%   [kernel.vmlinux]
   6.82%[k] intel_idle
   0.66%[k] menu_select
   0.43%[k] __hrtimer_start_range_ns
  ...

Signed-off-by: Namhyung Kim 
Acked-by: Pekka Enberg 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1456326830-30456-17-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-report.txt |  3 +++
 tools/perf/Documentation/tips.txt|  1 +
 tools/perf/builtin-report.c  | 17 +
 3 files changed, 21 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index 89cab84..1211399 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -401,6 +401,9 @@ include::itrace.txt[]
 --raw-trace::
When displaying traceevent output, do not use print fmt or plugins.
 
+--hierarchy::
+   Enable hierarchical output.
+
 include::callchain-overhead-calculation.txt[]
 
 SEE ALSO
diff --git a/tools/perf/Documentation/tips.txt 
b/tools/perf/Documentation/tips.txt
index e0ce957..5950b5a 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -27,3 +27,4 @@ Skip collecing build-id when recording: perf record -B
 To change sampling frequency to 100 Hz: perf record -F 100
 See assembly instructions with percentage: perf annotate 
 If you prefer Intel style assembly, try: perf annotate -M intel
+For hierarchical output, try: perf report --hierarchy
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 760e886..f4d8244 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -811,6 +811,8 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
"only show processor socket that match with this filter"),
OPT_BOOLEAN(0, "raw-trace", _conf.raw_trace,
"Show raw trace event output (do not use print fmt or 
plugins)"),
+   OPT_BOOLEAN(0, "hierarchy", _conf.report_hierarchy,
+   "Show entries in a hierarchy"),
OPT_END()
};
struct perf_data_file file = {
@@ -920,6 +922,21 @@ repeat:
symbol_conf.cumulate_callchain = false;
}
 
+   if (symbol_conf.report_hierarchy) {
+   /* disable incompatible options */
+   symbol_conf.event_group = false;
+   symbol_conf.cumulate_callchain = false;
+
+   if (field_order) {
+   pr_err("Error: --hierarchy and --fields options cannot 
be used together\n");
+   parse_options_usage(report_usage, options, "F", 1);
+   parse_options_usage(NULL, options, "hierarchy", 0);
+   goto error;
+   }
+
+   sort__need_collapse = true;
+   }
+
/* Force tty output for header output and per-thread stat. */
if (report.header || report.header_only || report.show_threads)
use_browser = 0;