linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 00/29] perf/core improvements and fixes
@ 2016-02-03 16:33 Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 01/29] perf hists: Factor output_resort from hists__output_resort Arnaldo Carvalho de Melo
                   ` (29 more replies)
  0 siblings, 30 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Andi Kleen, David Ahern,
	Jiri Olsa, Namhyung Kim, Peter Zijlstra, Stephane Eranian,
	Wang Nan, Arnaldo Carvalho de Melo

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit 8eb22c984eb9eeaed47130f5679acd367af69678:

  Merge tag 'perf-core-for-mingo-3' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-02-03 11:02:37 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo

for you to fetch changes up to b62e8dfcda8cb133c062c0e1207afea2476eb7fd:

  perf hists browser: Add 'L' hotkey to change percent limit (2016-02-03 12:24:22 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

New features:

- Add 'L' hotkey to dynamicly set the percent threshold for histogram
  entries and callchains, i.e. dynamicly do what the --percent-limit
  command line option to 'top' and 'report' does. (Namhyung Kim)

Infrastructure:

- Per hists field and sort lists, that will be used, for instance,
  in the c2c tool (Jiri Olsa)

Documentation:

- Update documentation of --sort and --perf-limit options
  for 'perf report' (Namhyung Kim)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
      perf top: Move UI initialization ahead of sort setup

Jiri Olsa (25):
      perf hists: Factor output_resort from hists__output_resort
      perf hists: Introduce perf_evsel__output_resort function
      perf hists: Add _idx fields into struct perf_hpp_fmt
      perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width
      perf hists: Add 'equal' method to perf_hpp_fmt struct
      perf hists: Add 'hpp__equal' callback function
      perf hists: Make hpp setup function generic
      perf report: Move UI initialization ahead of sort setup
      perf hists: Allocate output sort field
      perf hists: Remove perf_hpp__column_(disable|enable)
      perf hists: Properly release format fields
      perf hists: Separate sort fields parsing into setup_sort_list function
      perf hists: Separate output fields parsing into setup_output_list function
      perf hists: Introduce struct perf_hpp_list
      perf hists: Introduce perf_hpp_list__init function
      perf hists: Add perf_hpp_list register helpers
      perf hists: Pass perf_hpp_list all the way through setup_output_list
      perf hists: Introduce perf_hpp_list__for_each_format macro
      perf hists: Introduce perf_hpp_list__for_each_format_safe macro
      perf hists: Introduce perf_hpp_list__for_each_sort_list macro
      perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro
      perf hists: Add struct perf_hpp_list argument to helper functions
      perf tools: Add hpp_list into struct hists object
      perf hists: Introduce hists__for_each_format macro
      perf hists: Introduce hists__for_each_sort_list macro

Namhyung Kim (3):
      perf report: Update documentation of --sort option
      perf report: Update documention of --percent-limit option
      perf hists browser: Add 'L' hotkey to change percent limit

 tools/perf/Documentation/perf-report.txt |  37 +++---
 tools/perf/builtin-annotate.c            |   2 +-
 tools/perf/builtin-report.c              |  20 +--
 tools/perf/builtin-top.c                 |  24 ++--
 tools/perf/tests/hists_cumulate.c        |   2 +-
 tools/perf/tests/hists_filter.c          |   2 +-
 tools/perf/tests/hists_output.c          |  10 +-
 tools/perf/ui/browsers/hists.c           |  63 +++++++++-
 tools/perf/ui/gtk/hists.c                |   6 +-
 tools/perf/ui/hist.c                     | 170 +++++++++++++------------
 tools/perf/ui/stdio/hist.c               |   8 +-
 tools/perf/util/hist.c                   |  47 +++++--
 tools/perf/util/hist.h                   |  65 +++++++---
 tools/perf/util/sort.c                   | 205 +++++++++++++++++++++----------
 14 files changed, 425 insertions(+), 236 deletions(-)

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 01/29] perf hists: Factor output_resort from hists__output_resort
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 02/29] perf hists: Introduce perf_evsel__output_resort function Arnaldo Carvalho de Melo
                   ` (28 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Currently hists__output_resort() depends on hists based on hists_evsel
struct, but we need to be able to sort common hists as well.

Cutting out the sorting base sorting code into output_resort
function, so it can be reused in following patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 098310bc4489..7797d06d4993 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1197,19 +1197,13 @@ static void __hists__insert_output_entry(struct rb_root *entries,
 	rb_insert_color(&he->rb_node, entries);
 }
 
-void hists__output_resort(struct hists *hists, struct ui_progress *prog)
+static void output_resort(struct hists *hists, struct ui_progress *prog,
+			  bool use_callchain)
 {
 	struct rb_root *root;
 	struct rb_node *next;
 	struct hist_entry *n;
 	u64 min_callchain_hits;
-	struct perf_evsel *evsel = hists_to_evsel(hists);
-	bool use_callchain;
-
-	if (evsel && symbol_conf.use_callchain && !symbol_conf.show_ref_callgraph)
-		use_callchain = evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN;
-	else
-		use_callchain = symbol_conf.use_callchain;
 
 	min_callchain_hits = hists__total_period(hists) * (callchain_param.min_percent / 100);
 
@@ -1239,6 +1233,19 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog)
 	}
 }
 
+void hists__output_resort(struct hists *hists, struct ui_progress *prog)
+{
+	struct perf_evsel *evsel = hists_to_evsel(hists);
+	bool use_callchain;
+
+	if (evsel && symbol_conf.use_callchain && !symbol_conf.show_ref_callgraph)
+		use_callchain = evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN;
+	else
+		use_callchain = symbol_conf.use_callchain;
+
+	output_resort(hists, prog, use_callchain);
+}
+
 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
 				       enum hist_filter filter)
 {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 02/29] perf hists: Introduce perf_evsel__output_resort function
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 01/29] perf hists: Factor output_resort from hists__output_resort Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 03/29] perf hists: Add _idx fields into struct perf_hpp_fmt Arnaldo Carvalho de Melo
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Adding evsel specific function to sort hists_evsel based hists. The
hists__output_resort can be now used to sort common hists object.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-annotate.c     |  2 +-
 tools/perf/builtin-report.c       |  2 +-
 tools/perf/builtin-top.c          | 10 ++++++----
 tools/perf/tests/hists_cumulate.c |  2 +-
 tools/perf/tests/hists_filter.c   |  2 +-
 tools/perf/tests/hists_output.c   | 10 +++++-----
 tools/perf/util/hist.c            | 10 +++++++---
 tools/perf/util/hist.h            |  1 +
 8 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index cc5c1267c738..cfe366375c4b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -245,7 +245,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
 			hists__collapse_resort(hists, NULL);
 			/* Don't sort callchain */
 			perf_evsel__reset_sample_bit(pos, CALLCHAIN);
-			hists__output_resort(hists, NULL);
+			perf_evsel__output_resort(pos, NULL);
 
 			if (symbol_conf.event_group &&
 			    !perf_evsel__is_group_leader(pos))
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 72ed0b46d5a1..54ce0479ca28 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -507,7 +507,7 @@ static void report__output_resort(struct report *rep)
 	ui_progress__init(&prog, rep->nr_entries, "Sorting events for output...");
 
 	evlist__for_each(rep->session->evlist, pos)
-		hists__output_resort(evsel__hists(pos), &prog);
+		perf_evsel__output_resort(pos, &prog);
 
 	ui_progress__finish();
 }
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index bf01cbb0ef23..f1bbe2a589f5 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -252,7 +252,8 @@ static void perf_top__print_sym_table(struct perf_top *top)
 	char bf[160];
 	int printed = 0;
 	const int win_width = top->winsize.ws_col - 1;
-	struct hists *hists = evsel__hists(top->sym_evsel);
+	struct perf_evsel *evsel = top->sym_evsel;
+	struct hists *hists = evsel__hists(evsel);
 
 	puts(CONSOLE_CLEAR);
 
@@ -288,7 +289,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
 	}
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 
 	hists__output_recalc_col_len(hists, top->print_entries - printed);
 	putchar('\n');
@@ -540,6 +541,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
 static void perf_top__sort_new_samples(void *arg)
 {
 	struct perf_top *t = arg;
+	struct perf_evsel *evsel = t->sym_evsel;
 	struct hists *hists;
 
 	perf_top__reset_sample_counters(t);
@@ -547,7 +549,7 @@ static void perf_top__sort_new_samples(void *arg)
 	if (t->evlist->selected != NULL)
 		t->sym_evsel = t->evlist->selected;
 
-	hists = evsel__hists(t->sym_evsel);
+	hists = evsel__hists(evsel);
 
 	if (t->evlist->enabled) {
 		if (t->zero) {
@@ -559,7 +561,7 @@ static void perf_top__sort_new_samples(void *arg)
 	}
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 }
 
 static void *display_thread_tui(void *arg)
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index 5e6a86e50fb9..ecf136c385d5 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -191,7 +191,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec
 	 * function since TEST_ASSERT_VAL() returns in case of failure.
 	 */
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(hists_to_evsel(hists), NULL);
 
 	if (verbose > 2) {
 		pr_info("use callchain: %d, cumulate callchain: %d\n",
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 351a42463444..34b945a55d4d 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -145,7 +145,7 @@ int test__hists_filter(int subtest __maybe_unused)
 		struct hists *hists = evsel__hists(evsel);
 
 		hists__collapse_resort(hists, NULL);
-		hists__output_resort(hists, NULL);
+		perf_evsel__output_resort(evsel, NULL);
 
 		if (verbose > 2) {
 			pr_info("Normal histogram\n");
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index b231265148d8..23cce67c7e48 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -156,7 +156,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
 		goto out;
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 
 	if (verbose > 2) {
 		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -256,7 +256,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
 		goto out;
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 
 	if (verbose > 2) {
 		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -310,7 +310,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
 		goto out;
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 
 	if (verbose > 2) {
 		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -388,7 +388,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
 		goto out;
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 
 	if (verbose > 2) {
 		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -491,7 +491,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine)
 		goto out;
 
 	hists__collapse_resort(hists, NULL);
-	hists__output_resort(hists, NULL);
+	perf_evsel__output_resort(evsel, NULL);
 
 	if (verbose > 2) {
 		pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 7797d06d4993..d07955c145e5 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1233,9 +1233,8 @@ static void output_resort(struct hists *hists, struct ui_progress *prog,
 	}
 }
 
-void hists__output_resort(struct hists *hists, struct ui_progress *prog)
+void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog)
 {
-	struct perf_evsel *evsel = hists_to_evsel(hists);
 	bool use_callchain;
 
 	if (evsel && symbol_conf.use_callchain && !symbol_conf.show_ref_callgraph)
@@ -1243,7 +1242,12 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog)
 	else
 		use_callchain = symbol_conf.use_callchain;
 
-	output_resort(hists, prog, use_callchain);
+	output_resort(evsel__hists(evsel), prog, use_callchain);
+}
+
+void hists__output_resort(struct hists *hists, struct ui_progress *prog)
+{
+	output_resort(hists, prog, symbol_conf.use_callchain);
 }
 
 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index d4ec4822a103..bc2499794bef 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -128,6 +128,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
 			      struct hists *hists);
 void hist_entry__delete(struct hist_entry *he);
 
+void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog);
 void hists__output_resort(struct hists *hists, struct ui_progress *prog);
 void hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 03/29] perf hists: Add _idx fields into struct perf_hpp_fmt
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 01/29] perf hists: Factor output_resort from hists__output_resort Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 02/29] perf hists: Introduce perf_evsel__output_resort function Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 04/29] perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Arnaldo Carvalho de Melo
                   ` (26 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Currently there's no way of comparing hpp format entries, which is
needed in following patches.

Adding _idx fields into struct perf_hpp_fmt to recognize and be able to
compare hpp format entries.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 25 ++++++++++++++-----------
 tools/perf/util/hist.h |  1 +
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index bf2a66e254ea..d392801ea17e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -371,7 +371,7 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 	return 0;
 }
 
-#define HPP__COLOR_PRINT_FNS(_name, _fn)		\
+#define HPP__COLOR_PRINT_FNS(_name, _fn, _idx)		\
 	{						\
 		.name   = _name,			\
 		.header	= hpp__header_fn,		\
@@ -381,9 +381,10 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 		.cmp	= hpp__nop_cmp,			\
 		.collapse = hpp__nop_cmp,		\
 		.sort	= hpp__sort_ ## _fn,		\
+		.idx	= PERF_HPP__ ## _idx,		\
 	}
 
-#define HPP__COLOR_ACC_PRINT_FNS(_name, _fn)		\
+#define HPP__COLOR_ACC_PRINT_FNS(_name, _fn, _idx)	\
 	{						\
 		.name   = _name,			\
 		.header	= hpp__header_fn,		\
@@ -393,9 +394,10 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 		.cmp	= hpp__nop_cmp,			\
 		.collapse = hpp__nop_cmp,		\
 		.sort	= hpp__sort_ ## _fn,		\
+		.idx	= PERF_HPP__ ## _idx,		\
 	}
 
-#define HPP__PRINT_FNS(_name, _fn)			\
+#define HPP__PRINT_FNS(_name, _fn, _idx)		\
 	{						\
 		.name   = _name,			\
 		.header	= hpp__header_fn,		\
@@ -404,17 +406,18 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 		.cmp	= hpp__nop_cmp,			\
 		.collapse = hpp__nop_cmp,		\
 		.sort	= hpp__sort_ ## _fn,		\
+		.idx	= PERF_HPP__ ## _idx,		\
 	}
 
 struct perf_hpp_fmt perf_hpp__format[] = {
-	HPP__COLOR_PRINT_FNS("Overhead", overhead),
-	HPP__COLOR_PRINT_FNS("sys", overhead_sys),
-	HPP__COLOR_PRINT_FNS("usr", overhead_us),
-	HPP__COLOR_PRINT_FNS("guest sys", overhead_guest_sys),
-	HPP__COLOR_PRINT_FNS("guest usr", overhead_guest_us),
-	HPP__COLOR_ACC_PRINT_FNS("Children", overhead_acc),
-	HPP__PRINT_FNS("Samples", samples),
-	HPP__PRINT_FNS("Period", period)
+	HPP__COLOR_PRINT_FNS("Overhead", overhead, OVERHEAD),
+	HPP__COLOR_PRINT_FNS("sys", overhead_sys, OVERHEAD_SYS),
+	HPP__COLOR_PRINT_FNS("usr", overhead_us, OVERHEAD_US),
+	HPP__COLOR_PRINT_FNS("guest sys", overhead_guest_sys, OVERHEAD_GUEST_SYS),
+	HPP__COLOR_PRINT_FNS("guest usr", overhead_guest_us, OVERHEAD_GUEST_US),
+	HPP__COLOR_ACC_PRINT_FNS("Children", overhead_acc, OVERHEAD_ACC),
+	HPP__PRINT_FNS("Samples", samples, SAMPLES),
+	HPP__PRINT_FNS("Period", period, PERIOD)
 };
 
 LIST_HEAD(perf_hpp__list);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index bc2499794bef..8a0cbdeb449e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -221,6 +221,7 @@ struct perf_hpp_fmt {
 	bool elide;
 	int len;
 	int user_len;
+	int idx;
 };
 
 extern struct list_head perf_hpp__list;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 04/29] perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 03/29] perf hists: Add _idx fields into struct perf_hpp_fmt Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 05/29] perf hists: Add 'equal' method to perf_hpp_fmt struct Arnaldo Carvalho de Melo
                   ` (25 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

We are going to add dynamic hpp format fields, so we need to make the
'len' change for the format itself, not in the perf_hpp__format
template.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index d392801ea17e..5a11bf0aabc7 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -629,20 +629,12 @@ unsigned int hists__sort_list_width(struct hists *hists)
 
 void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
 {
-	int idx;
-
 	if (perf_hpp__is_sort_entry(fmt))
 		return perf_hpp__reset_sort_width(fmt, hists);
 
-	for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) {
-		if (fmt == &perf_hpp__format[idx])
-			break;
-	}
-
-	if (idx == PERF_HPP__MAX_INDEX)
-		return;
+	BUG_ON(fmt->idx >= PERF_HPP__MAX_INDEX);
 
-	switch (idx) {
+	switch (fmt->idx) {
 	case PERF_HPP__OVERHEAD:
 	case PERF_HPP__OVERHEAD_SYS:
 	case PERF_HPP__OVERHEAD_US:
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 05/29] perf hists: Add 'equal' method to perf_hpp_fmt struct
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (3 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 04/29] perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 06/29] perf hists: Add 'hpp__equal' callback function Arnaldo Carvalho de Melo
                   ` (24 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

To easily compare format entries and make it available for all kinds of
format entries.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   |  9 +++++++--
 tools/perf/util/hist.h |  2 +-
 tools/perf/util/sort.c | 39 ++++++++++++++++++++-------------------
 3 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 5a11bf0aabc7..71c8bb71a350 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -524,6 +524,11 @@ void perf_hpp__cancel_cumulate(void)
 	perf_hpp__format[PERF_HPP__OVERHEAD].name = "Overhead";
 }
 
+static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
+{
+	return a->equal && a->equal(a, b);
+}
+
 void perf_hpp__setup_output_field(void)
 {
 	struct perf_hpp_fmt *fmt;
@@ -542,7 +547,7 @@ void perf_hpp__setup_output_field(void)
 			struct perf_hpp_fmt *pos;
 
 			perf_hpp__for_each_format(pos) {
-				if (perf_hpp__same_sort_entry(pos, fmt))
+				if (fmt_equal(fmt, pos))
 					goto next;
 			}
 		}
@@ -571,7 +576,7 @@ void perf_hpp__append_sort_keys(void)
 			struct perf_hpp_fmt *pos;
 
 			perf_hpp__for_each_sort_list(pos) {
-				if (perf_hpp__same_sort_entry(pos, fmt))
+				if (fmt_equal(fmt, pos))
 					goto next;
 			}
 		}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 8a0cbdeb449e..9a240d7b8d3b 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -215,6 +215,7 @@ struct perf_hpp_fmt {
 			    struct hist_entry *a, struct hist_entry *b);
 	int64_t (*sort)(struct perf_hpp_fmt *fmt,
 			struct hist_entry *a, struct hist_entry *b);
+	bool (*equal)(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
 
 	struct list_head list;
 	struct list_head sort_list;
@@ -268,7 +269,6 @@ void perf_hpp__reset_output_field(void);
 void perf_hpp__append_sort_keys(void);
 
 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
-bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
 bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *format);
 bool perf_hpp__defined_dynamic_entry(struct perf_hpp_fmt *fmt, struct hists *hists);
 
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 898e4b0724bf..170f7f73fe93 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1441,20 +1441,6 @@ struct hpp_sort_entry {
 	struct sort_entry *se;
 };
 
-bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
-{
-	struct hpp_sort_entry *hse_a;
-	struct hpp_sort_entry *hse_b;
-
-	if (!perf_hpp__is_sort_entry(a) || !perf_hpp__is_sort_entry(b))
-		return false;
-
-	hse_a = container_of(a, struct hpp_sort_entry, hpp);
-	hse_b = container_of(b, struct hpp_sort_entry, hpp);
-
-	return hse_a->se == hse_b->se;
-}
-
 void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists)
 {
 	struct hpp_sort_entry *hse;
@@ -1540,6 +1526,25 @@ static int64_t __sort__hpp_sort(struct perf_hpp_fmt *fmt,
 	return sort_fn(a, b);
 }
 
+bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format)
+{
+	return format->header == __sort__hpp_header;
+}
+
+static bool __sort__hpp_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
+{
+	struct hpp_sort_entry *hse_a;
+	struct hpp_sort_entry *hse_b;
+
+	if (!perf_hpp__is_sort_entry(a) || !perf_hpp__is_sort_entry(b))
+		return false;
+
+	hse_a = container_of(a, struct hpp_sort_entry, hpp);
+	hse_b = container_of(b, struct hpp_sort_entry, hpp);
+
+	return hse_a->se == hse_b->se;
+}
+
 static struct hpp_sort_entry *
 __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 {
@@ -1561,6 +1566,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 	hse->hpp.cmp = __sort__hpp_cmp;
 	hse->hpp.collapse = __sort__hpp_collapse;
 	hse->hpp.sort = __sort__hpp_sort;
+	hse->hpp.equal = __sort__hpp_equal;
 
 	INIT_LIST_HEAD(&hse->hpp.list);
 	INIT_LIST_HEAD(&hse->hpp.sort_list);
@@ -1571,11 +1577,6 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 	return hse;
 }
 
-bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format)
-{
-	return format->header == __sort__hpp_header;
-}
-
 static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 06/29] perf hists: Add 'hpp__equal' callback function
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (4 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 05/29] perf hists: Add 'equal' method to perf_hpp_fmt struct Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 07/29] perf hists: Make hpp setup function generic Arnaldo Carvalho de Melo
                   ` (23 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Adding 'hpp__equal' callback function to compare hpp output format
entries.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-7-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 71c8bb71a350..b543f4b7d7d3 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -371,6 +371,19 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 	return 0;
 }
 
+static bool perf_hpp__is_hpp_entry(struct perf_hpp_fmt *a)
+{
+	return a->header == hpp__header_fn;
+}
+
+static bool hpp__equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
+{
+	if (!perf_hpp__is_hpp_entry(a) || !perf_hpp__is_hpp_entry(b))
+		return false;
+
+	return a->idx == b->idx;
+}
+
 #define HPP__COLOR_PRINT_FNS(_name, _fn, _idx)		\
 	{						\
 		.name   = _name,			\
@@ -382,6 +395,7 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 		.collapse = hpp__nop_cmp,		\
 		.sort	= hpp__sort_ ## _fn,		\
 		.idx	= PERF_HPP__ ## _idx,		\
+		.equal	= hpp__equal,			\
 	}
 
 #define HPP__COLOR_ACC_PRINT_FNS(_name, _fn, _idx)	\
@@ -395,6 +409,7 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 		.collapse = hpp__nop_cmp,		\
 		.sort	= hpp__sort_ ## _fn,		\
 		.idx	= PERF_HPP__ ## _idx,		\
+		.equal	= hpp__equal,			\
 	}
 
 #define HPP__PRINT_FNS(_name, _fn, _idx)		\
@@ -407,6 +422,7 @@ static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 		.collapse = hpp__nop_cmp,		\
 		.sort	= hpp__sort_ ## _fn,		\
 		.idx	= PERF_HPP__ ## _idx,		\
+		.equal	= hpp__equal,			\
 	}
 
 struct perf_hpp_fmt perf_hpp__format[] = {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 07/29] perf hists: Make hpp setup function generic
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (5 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 06/29] perf hists: Add 'hpp__equal' callback function Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 08/29] perf report: Move UI initialization ahead of sort setup Arnaldo Carvalho de Melo
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Now that we have the 'equal' method implemented for hpp format entries
we can ease up the logic in the following functions and make them
generic wrt comparing format entries:

  perf_hpp__setup_output_field
  perf_hpp__append_sort_keys

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-8-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c | 36 ++++++++----------------------------
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index b543f4b7d7d3..b0fcaecb7d1d 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -551,21 +551,11 @@ void perf_hpp__setup_output_field(void)
 
 	/* append sort keys to output field */
 	perf_hpp__for_each_sort_list(fmt) {
-		if (!list_empty(&fmt->list))
-			continue;
+		struct perf_hpp_fmt *pos;
 
-		/*
-		 * sort entry fields are dynamically created,
-		 * so they can share a same sort key even though
-		 * the list is empty.
-		 */
-		if (perf_hpp__is_sort_entry(fmt)) {
-			struct perf_hpp_fmt *pos;
-
-			perf_hpp__for_each_format(pos) {
-				if (fmt_equal(fmt, pos))
-					goto next;
-			}
+		perf_hpp__for_each_format(pos) {
+			if (fmt_equal(fmt, pos))
+				goto next;
 		}
 
 		perf_hpp__column_register(fmt);
@@ -580,21 +570,11 @@ void perf_hpp__append_sort_keys(void)
 
 	/* append output fields to sort keys */
 	perf_hpp__for_each_format(fmt) {
-		if (!list_empty(&fmt->sort_list))
-			continue;
+		struct perf_hpp_fmt *pos;
 
-		/*
-		 * sort entry fields are dynamically created,
-		 * so they can share a same sort key even though
-		 * the list is empty.
-		 */
-		if (perf_hpp__is_sort_entry(fmt)) {
-			struct perf_hpp_fmt *pos;
-
-			perf_hpp__for_each_sort_list(pos) {
-				if (fmt_equal(fmt, pos))
-					goto next;
-			}
+		perf_hpp__for_each_sort_list(pos) {
+			if (fmt_equal(fmt, pos))
+				goto next;
 		}
 
 		perf_hpp__register_sort_field(fmt);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 08/29] perf report: Move UI initialization ahead of sort setup
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (6 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 07/29] perf hists: Make hpp setup function generic Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 09/29] perf top: " Arnaldo Carvalho de Melo
                   ` (21 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

The ui initialization changes hpp format callbacks, based on the used
browser. Thus we need this init being processed before setup_sorting.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-9-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-report.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 54ce0479ca28..1eab50ac1ef6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -912,15 +912,6 @@ repeat:
 		symbol_conf.cumulate_callchain = false;
 	}
 
-	if (setup_sorting(session->evlist) < 0) {
-		if (sort_order)
-			parse_options_usage(report_usage, options, "s", 1);
-		if (field_order)
-			parse_options_usage(sort_order ? NULL : report_usage,
-					    options, "F", 1);
-		goto error;
-	}
-
 	/* Force tty output for header output and per-thread stat. */
 	if (report.header || report.header_only || report.show_threads)
 		use_browser = 0;
@@ -930,6 +921,15 @@ repeat:
 	else
 		use_browser = 0;
 
+	if (setup_sorting(session->evlist) < 0) {
+		if (sort_order)
+			parse_options_usage(report_usage, options, "s", 1);
+		if (field_order)
+			parse_options_usage(sort_order ? NULL : report_usage,
+					    options, "F", 1);
+		goto error;
+	}
+
 	if (report.header || report.header_only) {
 		perf_session__fprintf_info(session, stdout,
 					   report.show_full_info);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 09/29] perf top: Move UI initialization ahead of sort setup
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (7 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 08/29] perf report: Move UI initialization ahead of sort setup Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:33 ` [PATCH 10/29] perf hists: Allocate output sort field Arnaldo Carvalho de Melo
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern, Jiri Olsa,
	Namhyung Kim, Peter Zijlstra

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The ui initialization changes hpp format callbacks, based on the used
browser. Thus we need this init being processed before setup_sorting.

Replica of a patch by Jiri for 'perf report'.

Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-9-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-top.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index f1bbe2a589f5..a75de3940b97 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1245,6 +1245,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	/* display thread wants entries to be collapsed in a different tree */
 	sort__need_collapse = 1;
 
+	if (top.use_stdio)
+		use_browser = 0;
+	else if (top.use_tui)
+		use_browser = 1;
+
+	setup_browser(false);
+
 	if (setup_sorting(top.evlist) < 0) {
 		if (sort_order)
 			parse_options_usage(top_usage, options, "s", 1);
@@ -1254,13 +1261,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 		goto out_delete_evlist;
 	}
 
-	if (top.use_stdio)
-		use_browser = 0;
-	else if (top.use_tui)
-		use_browser = 1;
-
-	setup_browser(false);
-
 	status = target__validate(target);
 	if (status) {
 		target__strerror(target, status, errbuf, BUFSIZ);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 10/29] perf hists: Allocate output sort field
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (8 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 09/29] perf top: " Arnaldo Carvalho de Melo
@ 2016-02-03 16:33 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 11/29] perf hists: Remove perf_hpp__column_(disable|enable) Arnaldo Carvalho de Melo
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Currently we use static output fields, because we have single global
list of all sort/output fields.

We will add hists specific sort and output lists in following patches,
so we need all format entries to be dynamically allocated. Adding
support to allocate output sort field.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-10-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 16 ++++++++++++++--
 tools/perf/util/sort.c | 41 +++++++++++++++++++++++++++++++++--------
 2 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index b0fcaecb7d1d..c877c52ff4bc 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -533,11 +533,23 @@ void perf_hpp__column_disable(unsigned col)
 
 void perf_hpp__cancel_cumulate(void)
 {
+	struct perf_hpp_fmt *fmt, *acc, *ovh, *tmp;
+
 	if (is_strict_order(field_order))
 		return;
 
-	perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC);
-	perf_hpp__format[PERF_HPP__OVERHEAD].name = "Overhead";
+	ovh = &perf_hpp__format[PERF_HPP__OVERHEAD];
+	acc = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC];
+
+	perf_hpp__for_each_format_safe(fmt, tmp) {
+		if (acc->equal(acc, fmt)) {
+			perf_hpp__column_unregister(fmt);
+			continue;
+		}
+
+		if (ovh->equal(ovh, fmt))
+			fmt->name = "Overhead";
+	}
 }
 
 static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 170f7f73fe93..52e4a3674985 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1577,6 +1577,19 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 	return hse;
 }
 
+static struct perf_hpp_fmt *__hpp_dimension__alloc_hpp(struct hpp_dimension *hd)
+{
+	struct perf_hpp_fmt *fmt;
+
+	fmt = memdup(hd->fmt, sizeof(*fmt));
+	if (fmt) {
+		INIT_LIST_HEAD(&fmt->list);
+		INIT_LIST_HEAD(&fmt->sort_list);
+	}
+
+	return fmt;
+}
+
 static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);
@@ -2066,11 +2079,17 @@ static int __sort_dimension__add(struct sort_dimension *sd)
 
 static int __hpp_dimension__add(struct hpp_dimension *hd)
 {
-	if (!hd->taken) {
-		hd->taken = 1;
+	struct perf_hpp_fmt *fmt;
 
-		perf_hpp__register_sort_field(hd->fmt);
-	}
+	if (hd->taken)
+		return 0;
+
+	fmt = __hpp_dimension__alloc_hpp(hd);
+	if (!fmt)
+		return -1;
+
+	hd->taken = 1;
+	perf_hpp__register_sort_field(fmt);
 	return 0;
 }
 
@@ -2088,11 +2107,17 @@ static int __sort_dimension__add_output(struct sort_dimension *sd)
 
 static int __hpp_dimension__add_output(struct hpp_dimension *hd)
 {
-	if (!hd->taken) {
-		hd->taken = 1;
+	struct perf_hpp_fmt *fmt;
 
-		perf_hpp__column_register(hd->fmt);
-	}
+	if (hd->taken)
+		return 0;
+
+	fmt = __hpp_dimension__alloc_hpp(hd);
+	if (!fmt)
+		return -1;
+
+	hd->taken = 1;
+	perf_hpp__column_register(fmt);
 	return 0;
 }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 11/29] perf hists: Remove perf_hpp__column_(disable|enable)
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (9 preceding siblings ...)
  2016-02-03 16:33 ` [PATCH 10/29] perf hists: Allocate output sort field Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 12/29] perf hists: Properly release format fields Arnaldo Carvalho de Melo
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Those functions are no longer needed. They operate over perf_hpp__format
array which is now used only as template for dynamic entries.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-11-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 12 ------------
 tools/perf/util/hist.h |  2 --
 2 files changed, 14 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index c877c52ff4bc..80d63a997287 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -519,18 +519,6 @@ void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 	list_add_tail(&format->sort_list, &perf_hpp__sort_list);
 }
 
-void perf_hpp__column_enable(unsigned col)
-{
-	BUG_ON(col >= PERF_HPP__MAX_INDEX);
-	perf_hpp__column_register(&perf_hpp__format[col]);
-}
-
-void perf_hpp__column_disable(unsigned col)
-{
-	BUG_ON(col >= PERF_HPP__MAX_INDEX);
-	perf_hpp__column_unregister(&perf_hpp__format[col]);
-}
-
 void perf_hpp__cancel_cumulate(void)
 {
 	struct perf_hpp_fmt *fmt, *acc, *ovh, *tmp;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 9a240d7b8d3b..1f9e21dd53f3 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -259,8 +259,6 @@ enum {
 void perf_hpp__init(void);
 void perf_hpp__column_register(struct perf_hpp_fmt *format);
 void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
-void perf_hpp__column_enable(unsigned col);
-void perf_hpp__column_disable(unsigned col);
 void perf_hpp__cancel_cumulate(void);
 
 void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 12/29] perf hists: Properly release format fields
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (10 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 11/29] perf hists: Remove perf_hpp__column_(disable|enable) Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 13/29] perf hists: Separate sort fields parsing into setup_sort_list function Arnaldo Carvalho de Melo
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

With multiple list holding format entries, we need the support properly
releasing format output/sort fields.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-12-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   |  8 ++++++++
 tools/perf/util/hist.h |  1 +
 tools/perf/util/sort.c | 24 ++++++++++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 80d63a997287..2cd1a03bf375 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -583,6 +583,12 @@ next:
 	}
 }
 
+static void fmt_free(struct perf_hpp_fmt *fmt)
+{
+	if (fmt->free)
+		fmt->free(fmt);
+}
+
 void perf_hpp__reset_output_field(void)
 {
 	struct perf_hpp_fmt *fmt, *tmp;
@@ -591,12 +597,14 @@ void perf_hpp__reset_output_field(void)
 	perf_hpp__for_each_format_safe(fmt, tmp) {
 		list_del_init(&fmt->list);
 		list_del_init(&fmt->sort_list);
+		fmt_free(fmt);
 	}
 
 	/* reset sort keys */
 	perf_hpp__for_each_sort_list_safe(fmt, tmp) {
 		list_del_init(&fmt->list);
 		list_del_init(&fmt->sort_list);
+		fmt_free(fmt);
 	}
 }
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 1f9e21dd53f3..f3bcf2d38733 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -216,6 +216,7 @@ struct perf_hpp_fmt {
 	int64_t (*sort)(struct perf_hpp_fmt *fmt,
 			struct hist_entry *a, struct hist_entry *b);
 	bool (*equal)(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
+	void (*free)(struct perf_hpp_fmt *fmt);
 
 	struct list_head list;
 	struct list_head sort_list;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 52e4a3674985..b5389a54356d 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1545,6 +1545,14 @@ static bool __sort__hpp_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
 	return hse_a->se == hse_b->se;
 }
 
+static void hse_free(struct perf_hpp_fmt *fmt)
+{
+	struct hpp_sort_entry *hse;
+
+	hse = container_of(fmt, struct hpp_sort_entry, hpp);
+	free(hse);
+}
+
 static struct hpp_sort_entry *
 __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 {
@@ -1567,6 +1575,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 	hse->hpp.collapse = __sort__hpp_collapse;
 	hse->hpp.sort = __sort__hpp_sort;
 	hse->hpp.equal = __sort__hpp_equal;
+	hse->hpp.free = hse_free;
 
 	INIT_LIST_HEAD(&hse->hpp.list);
 	INIT_LIST_HEAD(&hse->hpp.sort_list);
@@ -1577,6 +1586,11 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
 	return hse;
 }
 
+static void hpp_free(struct perf_hpp_fmt *fmt)
+{
+	free(fmt);
+}
+
 static struct perf_hpp_fmt *__hpp_dimension__alloc_hpp(struct hpp_dimension *hd)
 {
 	struct perf_hpp_fmt *fmt;
@@ -1585,6 +1599,7 @@ static struct perf_hpp_fmt *__hpp_dimension__alloc_hpp(struct hpp_dimension *hd)
 	if (fmt) {
 		INIT_LIST_HEAD(&fmt->list);
 		INIT_LIST_HEAD(&fmt->sort_list);
+		fmt->free = hpp_free;
 	}
 
 	return fmt;
@@ -1818,6 +1833,14 @@ bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *fmt)
 	return fmt->cmp == __sort__hde_cmp;
 }
 
+static void hde_free(struct perf_hpp_fmt *fmt)
+{
+	struct hpp_dynamic_entry *hde;
+
+	hde = container_of(fmt, struct hpp_dynamic_entry, hpp);
+	free(hde);
+}
+
 static struct hpp_dynamic_entry *
 __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)
 {
@@ -1842,6 +1865,7 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)
 	hde->hpp.cmp = __sort__hde_cmp;
 	hde->hpp.collapse = __sort__hde_cmp;
 	hde->hpp.sort = __sort__hde_cmp;
+	hde->hpp.free = hde_free;
 
 	INIT_LIST_HEAD(&hde->hpp.list);
 	INIT_LIST_HEAD(&hde->hpp.sort_list);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 13/29] perf hists: Separate sort fields parsing into setup_sort_list function
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (11 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 12/29] perf hists: Properly release format fields Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 14/29] perf hists: Separate output fields parsing into setup_output_list function Arnaldo Carvalho de Melo
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Separating sort fields parsing into setup_sort_list function, so it's
separated from sort_order string setup and could be reused later in
following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-13-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b5389a54356d..ab1c21a950f6 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2241,6 +2241,26 @@ static int sort_dimension__add(const char *tok,
 	return -ESRCH;
 }
 
+static int setup_sort_list(char *str, struct perf_evlist *evlist)
+{
+	char *tmp, *tok;
+	int ret = 0;
+
+	for (tok = strtok_r(str, ", ", &tmp);
+			tok; tok = strtok_r(NULL, ", ", &tmp)) {
+		ret = sort_dimension__add(tok, evlist);
+		if (ret == -EINVAL) {
+			error("Invalid --sort key: `%s'", tok);
+			break;
+		} else if (ret == -ESRCH) {
+			error("Unknown --sort key: `%s'", tok);
+			break;
+		}
+	}
+
+	return ret;
+}
+
 static const char *get_default_sort_order(struct perf_evlist *evlist)
 {
 	const char *default_sort_orders[] = {
@@ -2335,7 +2355,7 @@ static char *setup_overhead(char *keys)
 
 static int __setup_sorting(struct perf_evlist *evlist)
 {
-	char *tmp, *tok, *str;
+	char *str;
 	const char *sort_keys;
 	int ret = 0;
 
@@ -2373,17 +2393,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		}
 	}
 
-	for (tok = strtok_r(str, ", ", &tmp);
-			tok; tok = strtok_r(NULL, ", ", &tmp)) {
-		ret = sort_dimension__add(tok, evlist);
-		if (ret == -EINVAL) {
-			error("Invalid --sort key: `%s'", tok);
-			break;
-		} else if (ret == -ESRCH) {
-			error("Unknown --sort key: `%s'", tok);
-			break;
-		}
-	}
+	ret = setup_sort_list(str, evlist);
 
 	free(str);
 	return ret;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 14/29] perf hists: Separate output fields parsing into setup_output_list function
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (12 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 13/29] perf hists: Separate sort fields parsing into setup_sort_list function Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 15/29] perf hists: Introduce struct perf_hpp_list Arnaldo Carvalho de Melo
                   ` (15 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Separating output fields parsing into setup_output_list function, so
it's separated from field_order string setup and could be reused later
in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-14-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index ab1c21a950f6..36dbd5554f0e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2535,6 +2535,26 @@ static int output_field_add(char *tok)
 	return -ESRCH;
 }
 
+static int setup_output_list(char *str)
+{
+	char *tmp, *tok;
+	int ret = 0;
+
+	for (tok = strtok_r(str, ", ", &tmp);
+			tok; tok = strtok_r(NULL, ", ", &tmp)) {
+		ret = output_field_add(tok);
+		if (ret == -EINVAL) {
+			error("Invalid --fields key: `%s'", tok);
+			break;
+		} else if (ret == -ESRCH) {
+			error("Unknown --fields key: `%s'", tok);
+			break;
+		}
+	}
+
+	return ret;
+}
+
 static void reset_dimensions(void)
 {
 	unsigned int i;
@@ -2559,7 +2579,7 @@ bool is_strict_order(const char *order)
 
 static int __setup_output_field(void)
 {
-	char *tmp, *tok, *str, *strp;
+	char *str, *strp;
 	int ret = -EINVAL;
 
 	if (field_order == NULL)
@@ -2579,17 +2599,7 @@ static int __setup_output_field(void)
 		goto out;
 	}
 
-	for (tok = strtok_r(strp, ", ", &tmp);
-			tok; tok = strtok_r(NULL, ", ", &tmp)) {
-		ret = output_field_add(tok);
-		if (ret == -EINVAL) {
-			error("Invalid --fields key: `%s'", tok);
-			break;
-		} else if (ret == -ESRCH) {
-			error("Unknown --fields key: `%s'", tok);
-			break;
-		}
-	}
+	ret = setup_output_list(strp);
 
 out:
 	free(str);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 15/29] perf hists: Introduce struct perf_hpp_list
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (13 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 14/29] perf hists: Separate output fields parsing into setup_output_list function Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 16/29] perf hists: Introduce perf_hpp_list__init function Arnaldo Carvalho de Melo
                   ` (14 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Gather output and sort lists under struct perf_hpp_list, so we could
have multiple instancies of sort/output format entries.

Replacing current perf_hpp__list and perf_hpp__sort_list lists with
single perf_hpp_list instance.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-15-git-send-email-jolsa@kernel.org
[ Renamed fields to .{fields,sorts} as suggested by Namhyung and acked by Jiri ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 11 ++++++-----
 tools/perf/util/hist.h | 16 ++++++++++------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 2cd1a03bf375..74dbeac4753b 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -436,9 +436,10 @@ struct perf_hpp_fmt perf_hpp__format[] = {
 	HPP__PRINT_FNS("Period", period, PERIOD)
 };
 
-LIST_HEAD(perf_hpp__list);
-LIST_HEAD(perf_hpp__sort_list);
-
+struct perf_hpp_list perf_hpp_list = {
+	.fields	= LIST_HEAD_INIT(perf_hpp_list.fields),
+	.sorts	= LIST_HEAD_INIT(perf_hpp_list.sorts),
+};
 
 #undef HPP__COLOR_PRINT_FNS
 #undef HPP__COLOR_ACC_PRINT_FNS
@@ -506,7 +507,7 @@ void perf_hpp__init(void)
 
 void perf_hpp__column_register(struct perf_hpp_fmt *format)
 {
-	list_add_tail(&format->list, &perf_hpp__list);
+	list_add_tail(&format->list, &perf_hpp_list.fields);
 }
 
 void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
@@ -516,7 +517,7 @@ void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
 
 void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 {
-	list_add_tail(&format->sort_list, &perf_hpp__sort_list);
+	list_add_tail(&format->sort_list, &perf_hpp_list.sorts);
 }
 
 void perf_hpp__cancel_cumulate(void)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f3bcf2d38733..203397a6ea07 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -226,20 +226,24 @@ struct perf_hpp_fmt {
 	int idx;
 };
 
-extern struct list_head perf_hpp__list;
-extern struct list_head perf_hpp__sort_list;
+struct perf_hpp_list {
+	struct list_head fields;
+	struct list_head sorts;
+};
+
+extern struct perf_hpp_list perf_hpp_list;
 
 #define perf_hpp__for_each_format(format) \
-	list_for_each_entry(format, &perf_hpp__list, list)
+	list_for_each_entry(format, &perf_hpp_list.fields, list)
 
 #define perf_hpp__for_each_format_safe(format, tmp)	\
-	list_for_each_entry_safe(format, tmp, &perf_hpp__list, list)
+	list_for_each_entry_safe(format, tmp, &perf_hpp_list.fields, list)
 
 #define perf_hpp__for_each_sort_list(format) \
-	list_for_each_entry(format, &perf_hpp__sort_list, sort_list)
+	list_for_each_entry(format, &perf_hpp_list.sorts, sort_list)
 
 #define perf_hpp__for_each_sort_list_safe(format, tmp)	\
-	list_for_each_entry_safe(format, tmp, &perf_hpp__sort_list, sort_list)
+	list_for_each_entry_safe(format, tmp, &perf_hpp_list.sorts, sort_list)
 
 extern struct perf_hpp_fmt perf_hpp__format[];
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 16/29] perf hists: Introduce perf_hpp_list__init function
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (14 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 15/29] perf hists: Introduce struct perf_hpp_list Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 17/29] perf hists: Add perf_hpp_list register helpers Arnaldo Carvalho de Melo
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Introducing perf_hpp_list__init function to have an easy way to
initialize perf_hpp_list struct.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-16-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c | 6 ++++++
 tools/perf/util/hist.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index d07955c145e5..b762ecc31505 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1642,3 +1642,9 @@ int hists__init(void)
 
 	return err;
 }
+
+void perf_hpp_list__init(struct perf_hpp_list *list)
+{
+	INIT_LIST_HEAD(&list->fields);
+	INIT_LIST_HEAD(&list->sorts);
+}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 203397a6ea07..e22f98e3fc6d 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -386,4 +386,6 @@ int parse_filter_percentage(const struct option *opt __maybe_unused,
 			    const char *arg, int unset __maybe_unused);
 int perf_hist_config(const char *var, const char *value);
 
+void perf_hpp_list__init(struct perf_hpp_list *list);
+
 #endif	/* __PERF_HIST_H */
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 17/29] perf hists: Add perf_hpp_list register helpers
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (15 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 16/29] perf hists: Introduce perf_hpp_list__init function Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 18/29] perf hists: Pass perf_hpp_list all the way through setup_output_list Arnaldo Carvalho de Melo
                   ` (12 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Adding 2 perf_hpp_list register helpers:

  perf_hpp_list__column_register()
  perf_hpp_list__register_sort_field()

to be called within existing helpers:

  perf_hpp__column_register()
  perf_hpp__register_sort_field()

to register format entries within global perf_hpp_list object.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-17-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 14 ++++++++------
 tools/perf/util/hist.h | 18 +++++++++++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 74dbeac4753b..1655c0d9c089 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -505,19 +505,21 @@ void perf_hpp__init(void)
 		hpp_dimension__add_output(PERF_HPP__PERIOD);
 }
 
-void perf_hpp__column_register(struct perf_hpp_fmt *format)
+void perf_hpp_list__column_register(struct perf_hpp_list *list,
+				    struct perf_hpp_fmt *format)
 {
-	list_add_tail(&format->list, &perf_hpp_list.fields);
+	list_add_tail(&format->list, &list->fields);
 }
 
-void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
+void perf_hpp_list__register_sort_field(struct perf_hpp_list *list,
+					struct perf_hpp_fmt *format)
 {
-	list_del(&format->list);
+	list_add_tail(&format->sort_list, &list->sorts);
 }
 
-void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
+void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
 {
-	list_add_tail(&format->sort_list, &perf_hpp_list.sorts);
+	list_del(&format->list);
 }
 
 void perf_hpp__cancel_cumulate(void)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e22f98e3fc6d..a7769d778374 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -233,6 +233,21 @@ struct perf_hpp_list {
 
 extern struct perf_hpp_list perf_hpp_list;
 
+void perf_hpp_list__column_register(struct perf_hpp_list *list,
+				    struct perf_hpp_fmt *format);
+void perf_hpp_list__register_sort_field(struct perf_hpp_list *list,
+					struct perf_hpp_fmt *format);
+
+static inline void perf_hpp__column_register(struct perf_hpp_fmt *format)
+{
+	perf_hpp_list__column_register(&perf_hpp_list, format);
+}
+
+static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
+{
+	perf_hpp_list__register_sort_field(&perf_hpp_list, format);
+}
+
 #define perf_hpp__for_each_format(format) \
 	list_for_each_entry(format, &perf_hpp_list.fields, list)
 
@@ -262,11 +277,8 @@ enum {
 };
 
 void perf_hpp__init(void);
-void perf_hpp__column_register(struct perf_hpp_fmt *format);
 void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
 void perf_hpp__cancel_cumulate(void);
-
-void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
 void perf_hpp__setup_output_field(void);
 void perf_hpp__reset_output_field(void);
 void perf_hpp__append_sort_keys(void);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 18/29] perf hists: Pass perf_hpp_list all the way through setup_output_list
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (16 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 17/29] perf hists: Add perf_hpp_list register helpers Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 19/29] perf hists: Introduce perf_hpp_list__for_each_format macro Arnaldo Carvalho de Melo
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Passing perf_hpp_list all the way through setup_output_list so the
output entry could be added on the arbitrary list.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-19-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 36dbd5554f0e..f643bed8f63b 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1616,14 +1616,15 @@ static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
 	return 0;
 }
 
-static int __sort_dimension__add_hpp_output(struct sort_dimension *sd)
+static int __sort_dimension__add_hpp_output(struct perf_hpp_list *list,
+					    struct sort_dimension *sd)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);
 
 	if (hse == NULL)
 		return -1;
 
-	perf_hpp__column_register(&hse->hpp);
+	perf_hpp_list__column_register(list, &hse->hpp);
 	return 0;
 }
 
@@ -2117,19 +2118,21 @@ static int __hpp_dimension__add(struct hpp_dimension *hd)
 	return 0;
 }
 
-static int __sort_dimension__add_output(struct sort_dimension *sd)
+static int __sort_dimension__add_output(struct perf_hpp_list *list,
+					struct sort_dimension *sd)
 {
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_output(sd) < 0)
+	if (__sort_dimension__add_hpp_output(list, sd) < 0)
 		return -1;
 
 	sd->taken = 1;
 	return 0;
 }
 
-static int __hpp_dimension__add_output(struct hpp_dimension *hd)
+static int __hpp_dimension__add_output(struct perf_hpp_list *list,
+				       struct hpp_dimension *hd)
 {
 	struct perf_hpp_fmt *fmt;
 
@@ -2141,14 +2144,14 @@ static int __hpp_dimension__add_output(struct hpp_dimension *hd)
 		return -1;
 
 	hd->taken = 1;
-	perf_hpp__column_register(fmt);
+	perf_hpp_list__column_register(list, fmt);
 	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]);
+	return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[col]);
 }
 
 static int sort_dimension__add(const char *tok,
@@ -2492,7 +2495,7 @@ void sort__setup_elide(FILE *output)
 	}
 }
 
-static int output_field_add(char *tok)
+static int output_field_add(struct perf_hpp_list *list, char *tok)
 {
 	unsigned int i;
 
@@ -2502,7 +2505,7 @@ static int output_field_add(char *tok)
 		if (strncasecmp(tok, sd->name, strlen(tok)))
 			continue;
 
-		return __sort_dimension__add_output(sd);
+		return __sort_dimension__add_output(list, sd);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -2511,7 +2514,7 @@ static int output_field_add(char *tok)
 		if (strncasecmp(tok, hd->name, strlen(tok)))
 			continue;
 
-		return __hpp_dimension__add_output(hd);
+		return __hpp_dimension__add_output(list, hd);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
@@ -2520,7 +2523,7 @@ static int output_field_add(char *tok)
 		if (strncasecmp(tok, sd->name, strlen(tok)))
 			continue;
 
-		return __sort_dimension__add_output(sd);
+		return __sort_dimension__add_output(list, sd);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(memory_sort_dimensions); i++) {
@@ -2529,20 +2532,20 @@ static int output_field_add(char *tok)
 		if (strncasecmp(tok, sd->name, strlen(tok)))
 			continue;
 
-		return __sort_dimension__add_output(sd);
+		return __sort_dimension__add_output(list, sd);
 	}
 
 	return -ESRCH;
 }
 
-static int setup_output_list(char *str)
+static int setup_output_list(struct perf_hpp_list *list, char *str)
 {
 	char *tmp, *tok;
 	int ret = 0;
 
 	for (tok = strtok_r(str, ", ", &tmp);
 			tok; tok = strtok_r(NULL, ", ", &tmp)) {
-		ret = output_field_add(tok);
+		ret = output_field_add(list, tok);
 		if (ret == -EINVAL) {
 			error("Invalid --fields key: `%s'", tok);
 			break;
@@ -2599,7 +2602,7 @@ static int __setup_output_field(void)
 		goto out;
 	}
 
-	ret = setup_output_list(strp);
+	ret = setup_output_list(&perf_hpp_list, strp);
 
 out:
 	free(str);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 19/29] perf hists: Introduce perf_hpp_list__for_each_format macro
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (17 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 18/29] perf hists: Pass perf_hpp_list all the way through setup_output_list Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 20/29] perf hists: Introduce perf_hpp_list__for_each_format_safe macro Arnaldo Carvalho de Melo
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Introducing perf_hpp_list__for_each_format macro to iterate
perf_hpp_list object's output entries.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-20-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 8 ++++----
 tools/perf/ui/gtk/hists.c      | 6 +++---
 tools/perf/ui/hist.c           | 8 ++++----
 tools/perf/ui/stdio/hist.c     | 8 ++++----
 tools/perf/util/hist.h         | 4 ++--
 tools/perf/util/sort.c         | 8 ++++----
 6 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 61d578bf4ffd..df0aedfaea75 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1095,7 +1095,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 
 		hist_browser__gotorc(browser, row, 0);
 
-		perf_hpp__for_each_format(fmt) {
+		perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 			if (perf_hpp__should_skip(fmt, entry->hists) ||
 			    column++ < browser->b.horiz_scroll)
 				continue;
@@ -1175,7 +1175,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *
 			return ret;
 	}
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, hists)  || column++ < browser->b.horiz_scroll)
 			continue;
 
@@ -1441,7 +1441,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
 	if (symbol_conf.use_callchain)
 		printed += fprintf(fp, "%c ", folded_sign);
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, he->hists))
 			continue;
 
@@ -2104,7 +2104,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	memset(options, 0, sizeof(options));
 	memset(actions, 0, sizeof(actions));
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		perf_hpp__reset_width(fmt, hists);
 		/*
 		 * This is done just once, and activates the horizontal scrolling
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 0f8dcfdfb10f..eca5151f91d7 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -306,7 +306,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 
 	nr_cols = 0;
 
-	perf_hpp__for_each_format(fmt)
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt)
 		col_types[nr_cols++] = G_TYPE_STRING;
 
 	store = gtk_tree_store_newv(nr_cols, col_types);
@@ -317,7 +317,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 
 	col_idx = 0;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
@@ -367,7 +367,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 
 		col_idx = 0;
 
-		perf_hpp__for_each_format(fmt) {
+		perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 			if (perf_hpp__should_skip(fmt, h->hists))
 				continue;
 
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 1655c0d9c089..7b5e8cedf853 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -556,7 +556,7 @@ void perf_hpp__setup_output_field(void)
 	perf_hpp__for_each_sort_list(fmt) {
 		struct perf_hpp_fmt *pos;
 
-		perf_hpp__for_each_format(pos) {
+		perf_hpp_list__for_each_format(&perf_hpp_list, pos) {
 			if (fmt_equal(fmt, pos))
 				goto next;
 		}
@@ -572,7 +572,7 @@ void perf_hpp__append_sort_keys(void)
 	struct perf_hpp_fmt *fmt;
 
 	/* append output fields to sort keys */
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		struct perf_hpp_fmt *pos;
 
 		perf_hpp__for_each_sort_list(pos) {
@@ -621,7 +621,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
 	bool first = true;
 	struct perf_hpp dummy_hpp;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
@@ -674,7 +674,7 @@ void perf_hpp__set_user_width(const char *width_list_str)
 	struct perf_hpp_fmt *fmt;
 	const char *ptr = width_list_str;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		char *p;
 
 		int len = strtol(ptr, &p, 10);
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 691e52ce7510..83e0bf2ab986 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -384,7 +384,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
 	if (symbol_conf.exclude_other && !he->parent)
 		return 0;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, he->hists))
 			continue;
 
@@ -453,7 +453,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	init_rem_hits();
 
-	perf_hpp__for_each_format(fmt)
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt)
 		perf_hpp__reset_width(fmt, hists);
 
 	if (symbol_conf.col_width_list_str)
@@ -464,7 +464,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	fprintf(fp, "# ");
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
@@ -488,7 +488,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	fprintf(fp, "# ");
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		unsigned int i;
 
 		if (perf_hpp__should_skip(fmt, hists))
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index a7769d778374..eadffca1a501 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -248,8 +248,8 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 	perf_hpp_list__register_sort_field(&perf_hpp_list, format);
 }
 
-#define perf_hpp__for_each_format(format) \
-	list_for_each_entry(format, &perf_hpp_list.fields, list)
+#define perf_hpp_list__for_each_format(_list, format) \
+	list_for_each_entry(format, &(_list)->fields, list)
 
 #define perf_hpp__for_each_format_safe(format, tmp)	\
 	list_for_each_entry_safe(format, tmp, &perf_hpp_list.fields, list)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index f643bed8f63b..1e134ff56ad4 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2407,7 +2407,7 @@ void perf_hpp__set_elide(int idx, bool elide)
 	struct perf_hpp_fmt *fmt;
 	struct hpp_sort_entry *hse;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (!perf_hpp__is_sort_entry(fmt))
 			continue;
 
@@ -2467,7 +2467,7 @@ void sort__setup_elide(FILE *output)
 	struct perf_hpp_fmt *fmt;
 	struct hpp_sort_entry *hse;
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (!perf_hpp__is_sort_entry(fmt))
 			continue;
 
@@ -2479,7 +2479,7 @@ void sort__setup_elide(FILE *output)
 	 * It makes no sense to elide all of sort entries.
 	 * Just revert them to show up again.
 	 */
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (!perf_hpp__is_sort_entry(fmt))
 			continue;
 
@@ -2487,7 +2487,7 @@ void sort__setup_elide(FILE *output)
 			return;
 	}
 
-	perf_hpp__for_each_format(fmt) {
+	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		if (!perf_hpp__is_sort_entry(fmt))
 			continue;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 20/29] perf hists: Introduce perf_hpp_list__for_each_format_safe macro
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (18 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 19/29] perf hists: Introduce perf_hpp_list__for_each_format macro Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 21/29] perf hists: Introduce perf_hpp_list__for_each_sort_list macro Arnaldo Carvalho de Melo
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Introducing perf_hpp_list__for_each_format_safe macro to iterate
perf_hpp_list object's output entries safely.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-21-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 4 ++--
 tools/perf/util/hist.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 7b5e8cedf853..348706a908f9 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -532,7 +532,7 @@ void perf_hpp__cancel_cumulate(void)
 	ovh = &perf_hpp__format[PERF_HPP__OVERHEAD];
 	acc = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC];
 
-	perf_hpp__for_each_format_safe(fmt, tmp) {
+	perf_hpp_list__for_each_format_safe(&perf_hpp_list, fmt, tmp) {
 		if (acc->equal(acc, fmt)) {
 			perf_hpp__column_unregister(fmt);
 			continue;
@@ -597,7 +597,7 @@ void perf_hpp__reset_output_field(void)
 	struct perf_hpp_fmt *fmt, *tmp;
 
 	/* reset output fields */
-	perf_hpp__for_each_format_safe(fmt, tmp) {
+	perf_hpp_list__for_each_format_safe(&perf_hpp_list, fmt, tmp) {
 		list_del_init(&fmt->list);
 		list_del_init(&fmt->sort_list);
 		fmt_free(fmt);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index eadffca1a501..f5b2309de16e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -251,8 +251,8 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 #define perf_hpp_list__for_each_format(_list, format) \
 	list_for_each_entry(format, &(_list)->fields, list)
 
-#define perf_hpp__for_each_format_safe(format, tmp)	\
-	list_for_each_entry_safe(format, tmp, &perf_hpp_list.fields, list)
+#define perf_hpp_list__for_each_format_safe(_list, format, tmp)	\
+	list_for_each_entry_safe(format, tmp, &(_list)->fields, list)
 
 #define perf_hpp__for_each_sort_list(format) \
 	list_for_each_entry(format, &perf_hpp_list.sorts, sort_list)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 21/29] perf hists: Introduce perf_hpp_list__for_each_sort_list macro
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (19 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 20/29] perf hists: Introduce perf_hpp_list__for_each_format_safe macro Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 22/29] perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro Arnaldo Carvalho de Melo
                   ` (8 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Introducing perf_hpp_list__for_each_sort_list macro to iterate
perf_hpp_list object's sort entries.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-22-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 4 ++--
 tools/perf/util/hist.c | 6 +++---
 tools/perf/util/hist.h | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 348706a908f9..f09eabe18167 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -553,7 +553,7 @@ void perf_hpp__setup_output_field(void)
 	struct perf_hpp_fmt *fmt;
 
 	/* append sort keys to output field */
-	perf_hpp__for_each_sort_list(fmt) {
+	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
 		struct perf_hpp_fmt *pos;
 
 		perf_hpp_list__for_each_format(&perf_hpp_list, pos) {
@@ -575,7 +575,7 @@ void perf_hpp__append_sort_keys(void)
 	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 		struct perf_hpp_fmt *pos;
 
-		perf_hpp__for_each_sort_list(pos) {
+		perf_hpp_list__for_each_sort_list(&perf_hpp_list, pos) {
 			if (fmt_equal(fmt, pos))
 				goto next;
 		}
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b762ecc31505..dea475d1fab0 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -961,7 +961,7 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp__for_each_sort_list(fmt) {
+	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
 		cmp = fmt->cmp(fmt, left, right);
 		if (cmp)
 			break;
@@ -976,7 +976,7 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp__for_each_sort_list(fmt) {
+	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
 		cmp = fmt->collapse(fmt, left, right);
 		if (cmp)
 			break;
@@ -1120,7 +1120,7 @@ static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp__for_each_sort_list(fmt) {
+	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
 		if (perf_hpp__should_skip(fmt, a->hists))
 			continue;
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f5b2309de16e..c9b2ea4a4929 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -254,8 +254,8 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 #define perf_hpp_list__for_each_format_safe(_list, format, tmp)	\
 	list_for_each_entry_safe(format, tmp, &(_list)->fields, list)
 
-#define perf_hpp__for_each_sort_list(format) \
-	list_for_each_entry(format, &perf_hpp_list.sorts, sort_list)
+#define perf_hpp_list__for_each_sort_list(_list, format) \
+	list_for_each_entry(format, &(_list)->sorts, sort_list)
 
 #define perf_hpp__for_each_sort_list_safe(format, tmp)	\
 	list_for_each_entry_safe(format, tmp, &perf_hpp_list.sorts, sort_list)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 22/29] perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (20 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 21/29] perf hists: Introduce perf_hpp_list__for_each_sort_list macro Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 23/29] perf hists: Add struct perf_hpp_list argument to helper functions Arnaldo Carvalho de Melo
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Introducing perf_hpp_list__for_each_sort_list_safe macro
to iterate perf_hpp_list object's sort entries safely.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-23-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 2 +-
 tools/perf/util/hist.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index f09eabe18167..9cda51edfdbd 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -604,7 +604,7 @@ void perf_hpp__reset_output_field(void)
 	}
 
 	/* reset sort keys */
-	perf_hpp__for_each_sort_list_safe(fmt, tmp) {
+	perf_hpp_list__for_each_sort_list_safe(&perf_hpp_list, fmt, tmp) {
 		list_del_init(&fmt->list);
 		list_del_init(&fmt->sort_list);
 		fmt_free(fmt);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index c9b2ea4a4929..61d35a9f928b 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -257,8 +257,8 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 #define perf_hpp_list__for_each_sort_list(_list, format) \
 	list_for_each_entry(format, &(_list)->sorts, sort_list)
 
-#define perf_hpp__for_each_sort_list_safe(format, tmp)	\
-	list_for_each_entry_safe(format, tmp, &perf_hpp_list.sorts, sort_list)
+#define perf_hpp_list__for_each_sort_list_safe(_list, format, tmp)	\
+	list_for_each_entry_safe(format, tmp, &(_list)->sorts, sort_list)
 
 extern struct perf_hpp_fmt perf_hpp__format[];
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 23/29] perf hists: Add struct perf_hpp_list argument to helper functions
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (21 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 22/29] perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 24/29] perf tools: Add hpp_list into struct hists object Arnaldo Carvalho de Melo
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

Adding struct perf_hpp_list argument to following helper functions:

  void perf_hpp__setup_output_field(struct perf_hpp_list *list);
  void perf_hpp__reset_output_field(struct perf_hpp_list *list);
  void perf_hpp__append_sort_keys(struct perf_hpp_list *list);

so they could be used on hists's hpp_list.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-24-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/hist.c   | 19 ++++++++++---------
 tools/perf/util/hist.h |  7 ++++---
 tools/perf/util/sort.c |  6 +++---
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 9cda51edfdbd..8075d4cc54a8 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -548,15 +548,15 @@ static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
 	return a->equal && a->equal(a, b);
 }
 
-void perf_hpp__setup_output_field(void)
+void perf_hpp__setup_output_field(struct perf_hpp_list *list)
 {
 	struct perf_hpp_fmt *fmt;
 
 	/* append sort keys to output field */
-	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
+	perf_hpp_list__for_each_sort_list(list, fmt) {
 		struct perf_hpp_fmt *pos;
 
-		perf_hpp_list__for_each_format(&perf_hpp_list, pos) {
+		perf_hpp_list__for_each_format(list, pos) {
 			if (fmt_equal(fmt, pos))
 				goto next;
 		}
@@ -567,15 +567,15 @@ next:
 	}
 }
 
-void perf_hpp__append_sort_keys(void)
+void perf_hpp__append_sort_keys(struct perf_hpp_list *list)
 {
 	struct perf_hpp_fmt *fmt;
 
 	/* append output fields to sort keys */
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	perf_hpp_list__for_each_format(list, fmt) {
 		struct perf_hpp_fmt *pos;
 
-		perf_hpp_list__for_each_sort_list(&perf_hpp_list, pos) {
+		perf_hpp_list__for_each_sort_list(list, pos) {
 			if (fmt_equal(fmt, pos))
 				goto next;
 		}
@@ -586,25 +586,26 @@ next:
 	}
 }
 
+
 static void fmt_free(struct perf_hpp_fmt *fmt)
 {
 	if (fmt->free)
 		fmt->free(fmt);
 }
 
-void perf_hpp__reset_output_field(void)
+void perf_hpp__reset_output_field(struct perf_hpp_list *list)
 {
 	struct perf_hpp_fmt *fmt, *tmp;
 
 	/* reset output fields */
-	perf_hpp_list__for_each_format_safe(&perf_hpp_list, fmt, tmp) {
+	perf_hpp_list__for_each_format_safe(list, fmt, tmp) {
 		list_del_init(&fmt->list);
 		list_del_init(&fmt->sort_list);
 		fmt_free(fmt);
 	}
 
 	/* reset sort keys */
-	perf_hpp_list__for_each_sort_list_safe(&perf_hpp_list, fmt, tmp) {
+	perf_hpp_list__for_each_sort_list_safe(list, fmt, tmp) {
 		list_del_init(&fmt->list);
 		list_del_init(&fmt->sort_list);
 		fmt_free(fmt);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 61d35a9f928b..a39c9c1159ff 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -279,9 +279,10 @@ enum {
 void perf_hpp__init(void);
 void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
 void perf_hpp__cancel_cumulate(void);
-void perf_hpp__setup_output_field(void);
-void perf_hpp__reset_output_field(void);
-void perf_hpp__append_sort_keys(void);
+void perf_hpp__setup_output_field(struct perf_hpp_list *list);
+void perf_hpp__reset_output_field(struct perf_hpp_list *list);
+void perf_hpp__append_sort_keys(struct perf_hpp_list *list);
+
 
 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
 bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *format);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 1e134ff56ad4..de620f7f40f4 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2636,9 +2636,9 @@ int setup_sorting(struct perf_evlist *evlist)
 		return err;
 
 	/* copy sort keys to output fields */
-	perf_hpp__setup_output_field();
+	perf_hpp__setup_output_field(&perf_hpp_list);
 	/* and then copy output fields to sort keys */
-	perf_hpp__append_sort_keys();
+	perf_hpp__append_sort_keys(&perf_hpp_list);
 
 	return 0;
 }
@@ -2654,5 +2654,5 @@ void reset_output_field(void)
 	sort_order = NULL;
 
 	reset_dimensions();
-	perf_hpp__reset_output_field();
+	perf_hpp__reset_output_field(&perf_hpp_list);
 }
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 24/29] perf tools: Add hpp_list into struct hists object
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (22 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 23/29] perf hists: Add struct perf_hpp_list argument to helper functions Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 25/29] perf hists: Introduce hists__for_each_format macro Arnaldo Carvalho de Melo
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Adding hpp_list into struct hists object.

Initializing struct hists_evsel hists object to carry global
perf_hpp_list list.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-25-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c | 5 +++--
 tools/perf/util/hist.h | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index dea475d1fab0..2b9cc9129692 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1578,7 +1578,7 @@ int perf_hist_config(const char *var, const char *value)
 	return 0;
 }
 
-int __hists__init(struct hists *hists)
+int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list)
 {
 	memset(hists, 0, sizeof(*hists));
 	hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT;
@@ -1587,6 +1587,7 @@ int __hists__init(struct hists *hists)
 	hists->entries = RB_ROOT;
 	pthread_mutex_init(&hists->lock, NULL);
 	hists->socket_filter = -1;
+	hists->hpp_list = hpp_list;
 	return 0;
 }
 
@@ -1623,7 +1624,7 @@ static int hists_evsel__init(struct perf_evsel *evsel)
 {
 	struct hists *hists = evsel__hists(evsel);
 
-	__hists__init(hists);
+	__hists__init(hists, &perf_hpp_list);
 	return 0;
 }
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index a39c9c1159ff..b296ff5b9683 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -75,6 +75,7 @@ struct hists {
 	u64			event_stream;
 	u16			col_len[HISTC_NR_COLS];
 	int			socket_filter;
+	struct perf_hpp_list	*hpp_list;
 };
 
 struct hist_entry_iter;
@@ -186,7 +187,7 @@ static inline struct hists *evsel__hists(struct perf_evsel *evsel)
 }
 
 int hists__init(void);
-int __hists__init(struct hists *hists);
+int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
 
 struct rb_root *hists__get_rotate_entries_in(struct hists *hists);
 bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 25/29] perf hists: Introduce hists__for_each_format macro
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (23 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 24/29] perf tools: Add hpp_list into struct hists object Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 26/29] perf hists: Introduce hists__for_each_sort_list macro Arnaldo Carvalho de Melo
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

With the hist object having the perf_hpp_list we can now iterate output
format entries based in the hists object. Adding hists__for_each_format
macro to do that.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-26-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 8 ++++----
 tools/perf/ui/gtk/hists.c      | 6 +++---
 tools/perf/ui/hist.c           | 2 +-
 tools/perf/ui/stdio/hist.c     | 8 ++++----
 tools/perf/util/hist.h         | 3 +++
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index df0aedfaea75..3a1e0965a8fd 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1095,7 +1095,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
 
 		hist_browser__gotorc(browser, row, 0);
 
-		perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+		hists__for_each_format(browser->hists, fmt) {
 			if (perf_hpp__should_skip(fmt, entry->hists) ||
 			    column++ < browser->b.horiz_scroll)
 				continue;
@@ -1175,7 +1175,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *
 			return ret;
 	}
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(browser->hists, fmt) {
 		if (perf_hpp__should_skip(fmt, hists)  || column++ < browser->b.horiz_scroll)
 			continue;
 
@@ -1441,7 +1441,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
 	if (symbol_conf.use_callchain)
 		printed += fprintf(fp, "%c ", folded_sign);
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(browser->hists, fmt) {
 		if (perf_hpp__should_skip(fmt, he->hists))
 			continue;
 
@@ -2104,7 +2104,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	memset(options, 0, sizeof(options));
 	memset(actions, 0, sizeof(actions));
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(browser->hists, fmt) {
 		perf_hpp__reset_width(fmt, hists);
 		/*
 		 * This is done just once, and activates the horizontal scrolling
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index eca5151f91d7..32cc38a5b57f 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -306,7 +306,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 
 	nr_cols = 0;
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt)
+	hists__for_each_format(hists, fmt)
 		col_types[nr_cols++] = G_TYPE_STRING;
 
 	store = gtk_tree_store_newv(nr_cols, col_types);
@@ -317,7 +317,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 
 	col_idx = 0;
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(hists, fmt) {
 		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
@@ -367,7 +367,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 
 		col_idx = 0;
 
-		perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+		hists__for_each_format(hists, fmt) {
 			if (perf_hpp__should_skip(fmt, h->hists))
 				continue;
 
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 8075d4cc54a8..1ba4117d9c2d 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -622,7 +622,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
 	bool first = true;
 	struct perf_hpp dummy_hpp;
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(hists, fmt) {
 		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 83e0bf2ab986..1a6e8f7f38c4 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -384,7 +384,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
 	if (symbol_conf.exclude_other && !he->parent)
 		return 0;
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(he->hists, fmt) {
 		if (perf_hpp__should_skip(fmt, he->hists))
 			continue;
 
@@ -453,7 +453,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	init_rem_hits();
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt)
+	hists__for_each_format(hists, fmt)
 		perf_hpp__reset_width(fmt, hists);
 
 	if (symbol_conf.col_width_list_str)
@@ -464,7 +464,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	fprintf(fp, "# ");
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(hists, fmt) {
 		if (perf_hpp__should_skip(fmt, hists))
 			continue;
 
@@ -488,7 +488,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	fprintf(fp, "# ");
 
-	perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+	hists__for_each_format(hists, fmt) {
 		unsigned int i;
 
 		if (perf_hpp__should_skip(fmt, hists))
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index b296ff5b9683..bc900448e36f 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -261,6 +261,9 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 #define perf_hpp_list__for_each_sort_list_safe(_list, format, tmp)	\
 	list_for_each_entry_safe(format, tmp, &(_list)->sorts, sort_list)
 
+#define hists__for_each_format(hists, format) \
+	perf_hpp_list__for_each_format((hists)->hpp_list, fmt)
+
 extern struct perf_hpp_fmt perf_hpp__format[];
 
 enum {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 26/29] perf hists: Introduce hists__for_each_sort_list macro
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (24 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 25/29] perf hists: Introduce hists__for_each_format macro Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 27/29] perf report: Update documentation of --sort option Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Jiri Olsa <jolsa@kernel.org>

With the hist object having the perf_hpp_list we can now iterate sort
format entries based in the hists object. Adding
hists__for_each_sort_list macro to do that.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1453109064-1026-27-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c | 9 ++++++---
 tools/perf/util/hist.h | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 2b9cc9129692..12f2d794dc28 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -958,10 +958,11 @@ out:
 int64_t
 hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 {
+	struct hists *hists = left->hists;
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
+	hists__for_each_sort_list(hists, fmt) {
 		cmp = fmt->cmp(fmt, left, right);
 		if (cmp)
 			break;
@@ -973,10 +974,11 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 int64_t
 hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
 {
+	struct hists *hists = left->hists;
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
+	hists__for_each_sort_list(hists, fmt) {
 		cmp = fmt->collapse(fmt, left, right);
 		if (cmp)
 			break;
@@ -1117,10 +1119,11 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
 
 static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
 {
+	struct hists *hists = a->hists;
 	struct perf_hpp_fmt *fmt;
 	int64_t cmp = 0;
 
-	perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) {
+	hists__for_each_sort_list(hists, fmt) {
 		if (perf_hpp__should_skip(fmt, a->hists))
 			continue;
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index bc900448e36f..1c7544a8fe1a 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -264,6 +264,9 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
 #define hists__for_each_format(hists, format) \
 	perf_hpp_list__for_each_format((hists)->hpp_list, fmt)
 
+#define hists__for_each_sort_list(hists, format) \
+	perf_hpp_list__for_each_sort_list((hists)->hpp_list, fmt)
+
 extern struct perf_hpp_fmt perf_hpp__format[];
 
 enum {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 27/29] perf report: Update documentation of --sort option
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (25 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 26/29] perf hists: Introduce hists__for_each_sort_list macro Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 28/29] perf report: Update documention of --percent-limit option Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Namhyung Kim, Andi Kleen, David Ahern, Jiri Olsa,
	Peter Zijlstra, Stephane Eranian, Wang Nan,
	Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Namhyung Kim <namhyung@kernel.org>

The description of the memory sort key (used by --mem-mode) was
misplaced.  Move it under the --sort option so that it can be referenced
properly.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1454508683-5735-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-report.txt | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 8a301f6afb37..1cb8fac596b1 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -117,6 +117,22 @@ OPTIONS
 	And default sort keys are changed to comm, dso_from, symbol_from, dso_to
 	and symbol_to, see '--branch-stack'.
 
+	If the --mem-mode option is used, the following sort keys are also available
+	(incompatible with --branch-stack):
+	symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline.
+
+	- symbol_daddr: name of data symbol being executed on at the time of sample
+	- dso_daddr: name of library or module containing the data being executed
+	on at the time of the sample
+	- locked: whether the bus was locked at the time of the sample
+	- tlb: type of tlb access for the data at the time of the sample
+	- mem: type of memory access for the data at the time of the sample
+	- snoop: type of snoop (if any) for the data at the time of the sample
+	- dcacheline: the cacheline the data address is on at the time of the sample
+
+	And the default sort keys are changed to local_weight, mem, sym, dso,
+	symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
+
 	If the data file has tracepoint event(s), following (dynamic) sort keys
 	are also available:
 	trace, trace_fields, [<event>.]<field>[/raw]
@@ -151,22 +167,6 @@ OPTIONS
 	By default, every sort keys not specified in -F will be appended
 	automatically.
 
-	If --mem-mode option is used, following sort keys are also available
-	(incompatible with --branch-stack):
-	symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline.
-
-	- symbol_daddr: name of data symbol being executed on at the time of sample
-	- dso_daddr: name of library or module containing the data being executed
-	on at the time of sample
-	- locked: whether the bus was locked at the time of sample
-	- tlb: type of tlb access for the data at the time of sample
-	- mem: type of memory access for the data at the time of sample
-	- snoop: type of snoop (if any) for the data at the time of sample
-	- dcacheline: the cacheline the data address is on at the time of sample
-
-	And default sort keys are changed to local_weight, mem, sym, dso,
-	symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
-
 -p::
 --parent=<regex>::
         A regex filter to identify parent. The parent is a caller of this
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 28/29] perf report: Update documention of --percent-limit option
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (26 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 27/29] perf report: Update documentation of --sort option Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-03 16:34 ` [PATCH 29/29] perf hists browser: Add 'L' hotkey to change percent limit Arnaldo Carvalho de Melo
  2016-02-04  7:59 ` [GIT PULL 00/29] perf/core improvements and fixes Ingo Molnar
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Namhyung Kim, Andi Kleen, David Ahern, Jiri Olsa,
	Peter Zijlstra, Stephane Eranian, Wang Nan,
	Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Namhyung Kim <namhyung@kernel.org>

The --percent-limit option was changed to be applied to callchains as
well as to hist entries recently, but it missed to update the doc.

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1454508683-5735-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-report.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 1cb8fac596b1..89cab84e92fd 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -351,7 +351,10 @@ OPTIONS
 
 --percent-limit::
 	Do not show entries which have an overhead under that percent.
-	(Default: 0).
+	(Default: 0).  Note that this option also sets the percent limit (threshold)
+	of callchains.  However the default value of callchain threshold is
+	different than the default value of hist entries.  Please see the
+	--call-graph option for details.
 
 --percentage::
 	Determine how to display the overhead percentage of filtered entries.
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 29/29] perf hists browser: Add 'L' hotkey to change percent limit
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (27 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 28/29] perf report: Update documention of --percent-limit option Arnaldo Carvalho de Melo
@ 2016-02-03 16:34 ` Arnaldo Carvalho de Melo
  2016-02-04  7:59 ` [GIT PULL 00/29] perf/core improvements and fixes Ingo Molnar
  29 siblings, 0 replies; 31+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-03 16:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Namhyung Kim, Andi Kleen, David Ahern, Jiri Olsa,
	Peter Zijlstra, Stephane Eranian, Wang Nan,
	Arnaldo Carvalho de Melo

See http://www.infradead.org/rpr.html

From: Namhyung Kim <namhyung@kernel.org>

Add 'L' key action to change the percent limit applied to both of hist
entries and callchains.

Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1454508683-5735-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 3a1e0965a8fd..a5a5390476ac 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2029,6 +2029,42 @@ static void hist_browser__update_nr_entries(struct hist_browser *hb)
 	hb->nr_non_filtered_entries = nr_entries;
 }
 
+static void hist_browser__update_percent_limit(struct hist_browser *hb,
+					       double percent)
+{
+	struct hist_entry *he;
+	struct rb_node *nd = rb_first(&hb->hists->entries);
+	u64 total = hists__total_period(hb->hists);
+	u64 min_callchain_hits = total * (percent / 100);
+
+	hb->min_pcnt = callchain_param.min_percent = percent;
+
+	if (!symbol_conf.use_callchain)
+		return;
+
+	while ((nd = hists__filter_entries(nd, hb->min_pcnt)) != NULL) {
+		he = rb_entry(nd, struct hist_entry, rb_node);
+
+		if (callchain_param.mode == CHAIN_GRAPH_REL) {
+			total = he->stat.period;
+
+			if (symbol_conf.cumulate_callchain)
+				total = he->stat_acc->period;
+
+			min_callchain_hits = total * (percent / 100);
+		}
+
+		callchain_param.sort(&he->sorted_chain, he->callchain,
+				     min_callchain_hits, &callchain_param);
+
+		/* force to re-evaluate folding state of callchains */
+		he->init_have_children = false;
+		hist_entry__set_folding(he, false);
+
+		nd = rb_next(nd);
+	}
+}
+
 static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				    const char *helpline,
 				    bool left_exits,
@@ -2064,6 +2100,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	"E             Expand all callchains\n"				\
 	"F             Toggle percentage of filtered entries\n"		\
 	"H             Display column headers\n"			\
+	"L             Change percent limit\n"				\
 	"m             Display context menu\n"				\
 	"S             Zoom into current Processor Socket\n"		\
 
@@ -2219,6 +2256,24 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 				top->zero = !top->zero;
 			}
 			continue;
+		case 'L':
+			if (ui_browser__input_window("Percent Limit",
+					"Please enter the value you want to hide entries under that percent.",
+					buf, "ENTER: OK, ESC: Cancel",
+					delay_secs * 2) == K_ENTER) {
+				char *end;
+				double new_percent = strtod(buf, &end);
+
+				if (new_percent < 0 || new_percent > 100) {
+					ui_browser__warning(&browser->b, delay_secs * 2,
+						"Invalid percent: %.2f", new_percent);
+					continue;
+				}
+
+				hist_browser__update_percent_limit(browser, new_percent);
+				hist_browser__reset(browser);
+			}
+			continue;
 		case K_F1:
 		case 'h':
 		case '?':
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [GIT PULL 00/29] perf/core improvements and fixes
  2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (28 preceding siblings ...)
  2016-02-03 16:34 ` [PATCH 29/29] perf hists browser: Add 'L' hotkey to change percent limit Arnaldo Carvalho de Melo
@ 2016-02-04  7:59 ` Ingo Molnar
  29 siblings, 0 replies; 31+ messages in thread
From: Ingo Molnar @ 2016-02-04  7:59 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Andi Kleen, David Ahern, Jiri Olsa, Namhyung Kim,
	Peter Zijlstra, Stephane Eranian, Wang Nan,
	Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit 8eb22c984eb9eeaed47130f5679acd367af69678:
> 
>   Merge tag 'perf-core-for-mingo-3' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-02-03 11:02:37 +0100)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
> 
> for you to fetch changes up to b62e8dfcda8cb133c062c0e1207afea2476eb7fd:
> 
>   perf hists browser: Add 'L' hotkey to change percent limit (2016-02-03 12:24:22 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> New features:
> 
> - Add 'L' hotkey to dynamicly set the percent threshold for histogram
>   entries and callchains, i.e. dynamicly do what the --percent-limit
>   command line option to 'top' and 'report' does. (Namhyung Kim)
> 
> Infrastructure:
> 
> - Per hists field and sort lists, that will be used, for instance,
>   in the c2c tool (Jiri Olsa)
> 
> Documentation:
> 
> - Update documentation of --sort and --perf-limit options
>   for 'perf report' (Namhyung Kim)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Arnaldo Carvalho de Melo (1):
>       perf top: Move UI initialization ahead of sort setup
> 
> Jiri Olsa (25):
>       perf hists: Factor output_resort from hists__output_resort
>       perf hists: Introduce perf_evsel__output_resort function
>       perf hists: Add _idx fields into struct perf_hpp_fmt
>       perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width
>       perf hists: Add 'equal' method to perf_hpp_fmt struct
>       perf hists: Add 'hpp__equal' callback function
>       perf hists: Make hpp setup function generic
>       perf report: Move UI initialization ahead of sort setup
>       perf hists: Allocate output sort field
>       perf hists: Remove perf_hpp__column_(disable|enable)
>       perf hists: Properly release format fields
>       perf hists: Separate sort fields parsing into setup_sort_list function
>       perf hists: Separate output fields parsing into setup_output_list function
>       perf hists: Introduce struct perf_hpp_list
>       perf hists: Introduce perf_hpp_list__init function
>       perf hists: Add perf_hpp_list register helpers
>       perf hists: Pass perf_hpp_list all the way through setup_output_list
>       perf hists: Introduce perf_hpp_list__for_each_format macro
>       perf hists: Introduce perf_hpp_list__for_each_format_safe macro
>       perf hists: Introduce perf_hpp_list__for_each_sort_list macro
>       perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro
>       perf hists: Add struct perf_hpp_list argument to helper functions
>       perf tools: Add hpp_list into struct hists object
>       perf hists: Introduce hists__for_each_format macro
>       perf hists: Introduce hists__for_each_sort_list macro
> 
> Namhyung Kim (3):
>       perf report: Update documentation of --sort option
>       perf report: Update documention of --percent-limit option
>       perf hists browser: Add 'L' hotkey to change percent limit
> 
>  tools/perf/Documentation/perf-report.txt |  37 +++---
>  tools/perf/builtin-annotate.c            |   2 +-
>  tools/perf/builtin-report.c              |  20 +--
>  tools/perf/builtin-top.c                 |  24 ++--
>  tools/perf/tests/hists_cumulate.c        |   2 +-
>  tools/perf/tests/hists_filter.c          |   2 +-
>  tools/perf/tests/hists_output.c          |  10 +-
>  tools/perf/ui/browsers/hists.c           |  63 +++++++++-
>  tools/perf/ui/gtk/hists.c                |   6 +-
>  tools/perf/ui/hist.c                     | 170 +++++++++++++------------
>  tools/perf/ui/stdio/hist.c               |   8 +-
>  tools/perf/util/hist.c                   |  47 +++++--
>  tools/perf/util/hist.h                   |  65 +++++++---
>  tools/perf/util/sort.c                   | 205 +++++++++++++++++++++----------
>  14 files changed, 425 insertions(+), 236 deletions(-)

Pulled, thanks a lot Arnaldo!

	Ingo

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2016-02-04  7:59 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03 16:33 [GIT PULL 00/29] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 01/29] perf hists: Factor output_resort from hists__output_resort Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 02/29] perf hists: Introduce perf_evsel__output_resort function Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 03/29] perf hists: Add _idx fields into struct perf_hpp_fmt Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 04/29] perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 05/29] perf hists: Add 'equal' method to perf_hpp_fmt struct Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 06/29] perf hists: Add 'hpp__equal' callback function Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 07/29] perf hists: Make hpp setup function generic Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 08/29] perf report: Move UI initialization ahead of sort setup Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 09/29] perf top: " Arnaldo Carvalho de Melo
2016-02-03 16:33 ` [PATCH 10/29] perf hists: Allocate output sort field Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 11/29] perf hists: Remove perf_hpp__column_(disable|enable) Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 12/29] perf hists: Properly release format fields Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 13/29] perf hists: Separate sort fields parsing into setup_sort_list function Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 14/29] perf hists: Separate output fields parsing into setup_output_list function Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 15/29] perf hists: Introduce struct perf_hpp_list Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 16/29] perf hists: Introduce perf_hpp_list__init function Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 17/29] perf hists: Add perf_hpp_list register helpers Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 18/29] perf hists: Pass perf_hpp_list all the way through setup_output_list Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 19/29] perf hists: Introduce perf_hpp_list__for_each_format macro Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 20/29] perf hists: Introduce perf_hpp_list__for_each_format_safe macro Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 21/29] perf hists: Introduce perf_hpp_list__for_each_sort_list macro Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 22/29] perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 23/29] perf hists: Add struct perf_hpp_list argument to helper functions Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 24/29] perf tools: Add hpp_list into struct hists object Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 25/29] perf hists: Introduce hists__for_each_format macro Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 26/29] perf hists: Introduce hists__for_each_sort_list macro Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 27/29] perf report: Update documentation of --sort option Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 28/29] perf report: Update documention of --percent-limit option Arnaldo Carvalho de Melo
2016-02-03 16:34 ` [PATCH 29/29] perf hists browser: Add 'L' hotkey to change percent limit Arnaldo Carvalho de Melo
2016-02-04  7:59 ` [GIT PULL 00/29] perf/core improvements and fixes Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).