linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 00/26] perf tools: Introduce hists specific format entries
@ 2016-01-18  9:23 Jiri Olsa
  2016-01-18  9:23 ` [PATCH 01/26] perf tools: Factor output_resort from hists__output_resort Jiri Olsa
                   ` (27 more replies)
  0 siblings, 28 replies; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

hi,
currently we have global format sort and output
lists. This rfc patchset introduces hists object
based format entries to allow the hist object to
carry specific format entries.

This will allow to have distinguished hist objects
displaying different stuff in output.

Also available in:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/hists_fmt

thanks for comments,
jirka


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

 tools/perf/builtin-annotate.c     |   2 +-
 tools/perf/builtin-report.c       |  20 ++++-----
 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/ui/browsers/hists.c    |   8 ++--
 tools/perf/ui/gtk/hists.c         |   6 +--
 tools/perf/ui/hist.c              | 170 +++++++++++++++++++++++++++++++++++++----------------------------------
 tools/perf/ui/stdio/hist.c        |  10 ++---
 tools/perf/util/hist.c            |  47 ++++++++++++++------
 tools/perf/util/hist.h            |  65 ++++++++++++++++++++--------
 tools/perf/util/sort.c            | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
 13 files changed, 359 insertions(+), 224 deletions(-)

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

* [PATCH 01/26] perf tools: Factor output_resort from hists__output_resort
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
@ 2016-01-18  9:23 ` Jiri Olsa
  2016-02-04 12:33   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 02/26] perf tools: Introduce perf_evsel__output_resort function Jiri Olsa
                   ` (26 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Current 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.

Link: http://lkml.kernel.org/n/tip-z38ujjabcpch04u71bd27lyq@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 c226303e3da0..83a6f2733cdc 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1179,19 +1179,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->stats.total_period * (callchain_param.min_percent / 100);
 
@@ -1221,6 +1215,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.4.3

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

* [PATCH 02/26] perf tools: Introduce perf_evsel__output_resort function
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
  2016-01-18  9:23 ` [PATCH 01/26] perf tools: Factor output_resort from hists__output_resort Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:33   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 03/26] perf tools: Add _idx fields into struct perf_hpp_fmt Jiri Olsa
                   ` (25 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-5w6e9whw8iy5ve3szil9076y@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 2bf537f190a0..2fe654dd8d2b 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -504,7 +504,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 83a6f2733cdc..a94067c8f753 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1215,9 +1215,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)
@@ -1225,7 +1224,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.4.3

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

* [PATCH 03/26] perf tools: Add _idx fields into struct perf_hpp_fmt
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
  2016-01-18  9:23 ` [PATCH 01/26] perf tools: Factor output_resort from hists__output_resort Jiri Olsa
  2016-01-18  9:24 ` [PATCH 02/26] perf tools: Introduce perf_evsel__output_resort function Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:34   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 04/26] perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Jiri Olsa
                   ` (24 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-fz58ixswttfdcmv5o7v5b9j4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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.4.3

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

* [PATCH 04/26] perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (2 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 03/26] perf tools: Add _idx fields into struct perf_hpp_fmt Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:34   ` [tip:perf/core] perf hists: Use struct perf_hpp_fmt:: idx " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 05/26] perf tools: Add equal method to perf_hpp_fmt struct Jiri Olsa
                   ` (23 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-cc8j41xaxfingpjcag4adkss@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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.4.3

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

* [PATCH 05/26] perf tools: Add equal method to perf_hpp_fmt struct
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (3 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 04/26] perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:34   ` [tip:perf/core] perf hists: Add 'equal' " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 06/26] perf tools: Add hpp__equal callback function Jiri Olsa
                   ` (22 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-6ncdmurfcmyk4sfy7fr4bkr1@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 ec722346e6ff..1b57ec9d7c2f 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1440,20 +1440,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;
@@ -1539,6 +1525,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)
 {
@@ -1560,6 +1565,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);
@@ -1570,11 +1576,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.4.3

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

* [PATCH 06/26] perf tools: Add hpp__equal callback function
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (4 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 05/26] perf tools: Add equal method to perf_hpp_fmt struct Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:35   ` [tip:perf/core] perf hists: Add 'hpp__equal' " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 07/26] perf tools: Make hpp setup function generic Jiri Olsa
                   ` (21 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Adding hpp__equal callback function to compare
hpp output format entries.

Link: http://lkml.kernel.org/n/tip-3amekjgmmufx5lz7slhpmqx3@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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.4.3

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

* [PATCH 07/26] perf tools: Make hpp setup function generic
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (5 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 06/26] perf tools: Add hpp__equal callback function Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:35   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 08/26] perf report: Move ui initialization ahead of sort setup Jiri Olsa
                   ` (20 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

  perf_hpp__setup_output_field
  perf_hpp__append_sort_keys

Link: http://lkml.kernel.org/n/tip-6ncdmurfcmyk4sfy7fr4bkr1@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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.4.3

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

* [PATCH 08/26] perf report: Move ui initialization ahead of sort setup
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (6 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 07/26] perf tools: Make hpp setup function generic Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:35   ` [tip:perf/core] perf report: Move UI " tip-bot for Jiri Olsa
  2016-02-04 12:36   ` [tip:perf/core] perf top: " tip-bot for Arnaldo Carvalho de Melo
  2016-01-18  9:24 ` [PATCH 09/26] perf tools: Allocate output sort field Jiri Olsa
                   ` (19 subsequent siblings)
  27 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-8gngyjsfyua3dh3eifxgb980@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 2fe654dd8d2b..0aa0fd3b4aa7 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -907,15 +907,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;
@@ -925,6 +916,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.4.3

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

* [PATCH 09/26] perf tools: Allocate output sort field
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (7 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 08/26] perf report: Move ui initialization ahead of sort setup Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:36   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 10/26] perf tools: Remove perf_hpp__column_(disable|enable) Jiri Olsa
                   ` (18 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-35p3t3tqxcjbua9bhnkehady@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 1b57ec9d7c2f..a4ce4807fbb7 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1576,6 +1576,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);
@@ -2065,11 +2078,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;
 }
 
@@ -2087,11 +2106,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.4.3

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

* [PATCH 10/26] perf tools: Remove perf_hpp__column_(disable|enable)
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (8 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 09/26] perf tools: Allocate output sort field Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:36   ` [tip:perf/core] perf hists: Remove perf_hpp__column_( disable|enable) tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 11/26] perf tools: Properly release format fields Jiri Olsa
                   ` (17 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-k893o732njrt4hiiz7jplwwp@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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.4.3

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

* [PATCH 11/26] perf tools: Properly release format fields
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (9 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 10/26] perf tools: Remove perf_hpp__column_(disable|enable) Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:37   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 12/26] perf tools: Separate sort fields parsing into setup_sort_list function Jiri Olsa
                   ` (16 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-4gs7pj4kgbvgs38vyj7m9z0i@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 a4ce4807fbb7..a7eed4485afc 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1544,6 +1544,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)
 {
@@ -1566,6 +1574,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);
@@ -1576,6 +1585,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;
@@ -1584,6 +1598,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;
@@ -1817,6 +1832,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)
 {
@@ -1841,6 +1864,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.4.3

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

* [PATCH 12/26] perf tools: Separate sort fields parsing into setup_sort_list function
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (10 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 11/26] perf tools: Properly release format fields Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:37   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 13/26] perf tools: Separate output fields parsing into setup_output_list function Jiri Olsa
                   ` (15 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-9h0ujdlvbx73llz3c7vo8j75@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 a7eed4485afc..844c97f51198 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2238,6 +2238,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[] = {
@@ -2332,7 +2352,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;
 
@@ -2370,17 +2390,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.4.3

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

* [PATCH 13/26] perf tools: Separate output fields parsing into setup_output_list function
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (11 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 12/26] perf tools: Separate sort fields parsing into setup_sort_list function Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:37   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 14/26] perf tools: Introduce struct perf_hpp_list Jiri Olsa
                   ` (14 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-4f4bt1un7gyfbyat7lah65dc@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 844c97f51198..3461198217fc 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2532,6 +2532,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;
@@ -2556,7 +2576,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)
@@ -2576,17 +2596,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.4.3

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

* [PATCH 14/26] perf tools: Introduce struct perf_hpp_list
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (12 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 13/26] perf tools: Separate output fields parsing into setup_output_list function Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-01-25 15:00   ` Namhyung Kim
  2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 15/26] perf tools: Introduce perf_hpp_list__init function Jiri Olsa
                   ` (13 subsequent siblings)
  27 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-bdn1hamlwp2529thajbrh2w7@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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..1253a62c422f 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 = {
+	.list		= LIST_HEAD_INIT(perf_hpp_list.list),
+	.sort_list	= LIST_HEAD_INIT(perf_hpp_list.sort_list),
+};
 
 #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.list);
 }
 
 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.sort_list);
 }
 
 void perf_hpp__cancel_cumulate(void)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f3bcf2d38733..a9c8ccfcc284 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 list;
+	struct list_head sort_list;
+};
+
+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.list, 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.list, 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.sort_list, 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.sort_list, sort_list)
 
 extern struct perf_hpp_fmt perf_hpp__format[];
 
-- 
2.4.3

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

* [PATCH 15/26] perf tools: Introduce perf_hpp_list__init function
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (13 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 14/26] perf tools: Introduce struct perf_hpp_list Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 16/26] perf tools: Add perf_hpp_list register helpers Jiri Olsa
                   ` (12 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-6ucnvu4gdd1rl9rsojgn6t1f@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 a94067c8f753..c80f01460e3b 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1658,3 +1658,9 @@ int hists__init(void)
 
 	return err;
 }
+
+void perf_hpp_list__init(struct perf_hpp_list *list)
+{
+	INIT_LIST_HEAD(&list->list);
+	INIT_LIST_HEAD(&list->sort_list);
+}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index a9c8ccfcc284..ea50a9cf2316 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.4.3

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

* [PATCH 16/26] perf tools: Add perf_hpp_list register helpers
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (14 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 15/26] perf tools: Introduce perf_hpp_list__init function Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 17/26] perf tools: Pass perf_hpp_list all the way through setup_sort_list Jiri Olsa
                   ` (11 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Add ing 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.

Link: http://lkml.kernel.org/n/tip-oklhquvszc18kzox0vscjxtt@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 1253a62c422f..7200349b44b9 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.list);
+	list_add_tail(&format->list, &list->list);
 }
 
-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->sort_list);
 }
 
-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.sort_list);
+	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 ea50a9cf2316..dfa11777efbe 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.list, 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.4.3

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

* [PATCH 17/26] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (15 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 16/26] perf tools: Add perf_hpp_list register helpers Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-03-06 19:21   ` [PATCHv2] " Jiri Olsa
  2016-01-18  9:24 ` [PATCH 18/26] perf tools: Pass perf_hpp_list all the way through setup_output_list Jiri Olsa
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Passing perf_hpp_list all the way through setup_sort_list
so the sort entry could be added on the arbitrary list.

Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/sort.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 3461198217fc..020b3244aec9 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1604,14 +1604,15 @@ static struct perf_hpp_fmt *__hpp_dimension__alloc_hpp(struct hpp_dimension *hd)
 	return fmt;
 }
 
-static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
+static int __sort_dimension__add_hpp_sort(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__register_sort_field(&hse->hpp);
+	perf_hpp_list__register_sort_field(list, &hse->hpp);
 	return 0;
 }
 
@@ -2084,12 +2085,13 @@ out:
 	return ret;
 }
 
-static int __sort_dimension__add(struct sort_dimension *sd)
+static int __sort_dimension__add(struct perf_hpp_list *list,
+				 struct sort_dimension *sd)
 {
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_sort(sd) < 0)
+	if (__sort_dimension__add_hpp_sort(list, sd) < 0)
 		return -1;
 
 	if (sd->entry->se_collapse)
@@ -2100,7 +2102,8 @@ static int __sort_dimension__add(struct sort_dimension *sd)
 	return 0;
 }
 
-static int __hpp_dimension__add(struct hpp_dimension *hd)
+static int __hpp_dimension__add(struct perf_hpp_list *list,
+				struct hpp_dimension *hd)
 {
 	struct perf_hpp_fmt *fmt;
 
@@ -2112,7 +2115,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd)
 		return -1;
 
 	hd->taken = 1;
-	perf_hpp__register_sort_field(fmt);
+	perf_hpp_list__register_sort_field(list, fmt);
 	return 0;
 }
 
@@ -2150,7 +2153,7 @@ int hpp_dimension__add_output(unsigned col)
 	return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
 }
 
-static int sort_dimension__add(const char *tok,
+static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
 			       struct perf_evlist *evlist __maybe_unused)
 {
 	unsigned int i;
@@ -2188,7 +2191,7 @@ static int sort_dimension__add(const char *tok,
 			sort__has_socket = 1;
 		}
 
-		return __sort_dimension__add(sd);
+		return __sort_dimension__add(list, sd);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -2197,7 +2200,7 @@ static int sort_dimension__add(const char *tok,
 		if (strncasecmp(tok, hd->name, strlen(tok)))
 			continue;
 
-		return __hpp_dimension__add(hd);
+		return __hpp_dimension__add(list, hd);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
@@ -2212,7 +2215,7 @@ static int sort_dimension__add(const char *tok,
 		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd);
+		__sort_dimension__add(list, sd);
 		return 0;
 	}
 
@@ -2228,7 +2231,7 @@ static int sort_dimension__add(const char *tok,
 		if (sd->entry == &sort_mem_daddr_sym)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd);
+		__sort_dimension__add(list, sd);
 		return 0;
 	}
 
@@ -2238,14 +2241,15 @@ static int sort_dimension__add(const char *tok,
 	return -ESRCH;
 }
 
-static int setup_sort_list(char *str, struct perf_evlist *evlist)
+static int setup_sort_list(struct perf_hpp_list *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);
+		ret = sort_dimension__add(list, tok, evlist);
 		if (ret == -EINVAL) {
 			error("Invalid --sort key: `%s'", tok);
 			break;
@@ -2390,7 +2394,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		}
 	}
 
-	ret = setup_sort_list(str, evlist);
+	ret = setup_sort_list(&perf_hpp_list, str, evlist);
 
 	free(str);
 	return ret;
@@ -2612,7 +2616,7 @@ int setup_sorting(struct perf_evlist *evlist)
 		return err;
 
 	if (parent_pattern != default_parent_pattern) {
-		err = sort_dimension__add("parent", evlist);
+		err = sort_dimension__add(&perf_hpp_list, "parent", evlist);
 		if (err < 0)
 			return err;
 	}
-- 
2.4.3

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

* [PATCH 18/26] perf tools: Pass perf_hpp_list all the way through setup_output_list
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (16 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 17/26] perf tools: Pass perf_hpp_list all the way through setup_sort_list Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:39   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 19/26] perf tools: Introduce perf_hpp_list__for_each_format macro Jiri Olsa
                   ` (9 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-ps9t8kuf3fstm6yopzs2pwt4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 020b3244aec9..3daa7e6ced23 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 perf_hpp_list *list,
 	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;
 }
 
@@ -2119,19 +2120,21 @@ static int __hpp_dimension__add(struct perf_hpp_list *list,
 	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;
 
@@ -2143,14 +2146,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(struct perf_hpp_list *list, const char *tok,
@@ -2493,7 +2496,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;
 
@@ -2503,7 +2506,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++) {
@@ -2512,7 +2515,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++) {
@@ -2521,7 +2524,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++) {
@@ -2530,20 +2533,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;
@@ -2600,7 +2603,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.4.3

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

* [PATCH 19/26] perf tools: Introduce perf_hpp_list__for_each_format macro
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (17 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 18/26] perf tools: Pass perf_hpp_list all the way through setup_output_list Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:39   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 20/26] perf tools: Introduce perf_hpp_list__for_each_format_safe macro Jiri Olsa
                   ` (8 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-5iwpt2svvvvuthdjjlw6uaqm@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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     | 10 +++++-----
 tools/perf/util/hist.h         |  4 ++--
 tools/perf/util/sort.c         |  8 ++++----
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 08c09ad755d2..4416540f2bba 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1040,7 +1040,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;
@@ -1144,7 +1144,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;
 
@@ -1414,7 +1414,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;
 
@@ -2077,7 +2077,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 7200349b44b9..dd0bb4a00d00 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 387110d50b00..f40b05e109cd 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -360,7 +360,7 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
 				    !prefixcmp(sort_order, "comm"))) {
 		struct perf_hpp_fmt *fmt;
 
-		perf_hpp__for_each_format(fmt) {
+		perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
 			if (!perf_hpp__is_sort_entry(fmt))
 				continue;
 
@@ -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;
 
@@ -452,7 +452,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)
@@ -463,7 +463,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;
 
@@ -487,7 +487,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 dfa11777efbe..31add4d1d860 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.list, list)
+#define perf_hpp_list__for_each_format(_list, format) \
+	list_for_each_entry(format, &(_list)->list, list)
 
 #define perf_hpp__for_each_format_safe(format, tmp)	\
 	list_for_each_entry_safe(format, tmp, &perf_hpp_list.list, list)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 3daa7e6ced23..0194dd145401 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2408,7 +2408,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;
 
@@ -2468,7 +2468,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;
 
@@ -2480,7 +2480,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;
 
@@ -2488,7 +2488,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.4.3

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

* [PATCH 20/26] perf tools: Introduce perf_hpp_list__for_each_format_safe macro
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (18 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 19/26] perf tools: Introduce perf_hpp_list__for_each_format macro Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:40   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 21/26] perf tools: Introduce perf_hpp_list__for_each_sort_list macro Jiri Olsa
                   ` (7 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-nj3kp5noe7yt3jodpaha75ed@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 dd0bb4a00d00..4fbb2f43ba3a 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 31add4d1d860..ac0cfb68018c 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)->list, list)
 
-#define perf_hpp__for_each_format_safe(format, tmp)	\
-	list_for_each_entry_safe(format, tmp, &perf_hpp_list.list, list)
+#define perf_hpp_list__for_each_format_safe(_list, format, tmp)	\
+	list_for_each_entry_safe(format, tmp, &(_list)->list, list)
 
 #define perf_hpp__for_each_sort_list(format) \
 	list_for_each_entry(format, &perf_hpp_list.sort_list, sort_list)
-- 
2.4.3

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

* [PATCH 21/26] perf tools: Introduce perf_hpp_list__for_each_sort_list macro
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (19 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 20/26] perf tools: Introduce perf_hpp_list__for_each_format_safe macro Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:40   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 22/26] perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro Jiri Olsa
                   ` (6 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-b2r6j96rjzp7c3ys2e0pqvo5@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 4fbb2f43ba3a..c8d74b357d5e 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 c80f01460e3b..3ba70b7868d5 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -952,7 +952,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;
@@ -967,7 +967,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;
@@ -1111,7 +1111,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 ac0cfb68018c..130f825235a3 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)->list, list)
 
-#define perf_hpp__for_each_sort_list(format) \
-	list_for_each_entry(format, &perf_hpp_list.sort_list, sort_list)
+#define perf_hpp_list__for_each_sort_list(_list, format) \
+	list_for_each_entry(format, &(_list)->sort_list, sort_list)
 
 #define perf_hpp__for_each_sort_list_safe(format, tmp)	\
 	list_for_each_entry_safe(format, tmp, &perf_hpp_list.sort_list, sort_list)
-- 
2.4.3

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

* [PATCH 22/26] perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (20 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 21/26] perf tools: Introduce perf_hpp_list__for_each_sort_list macro Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:40   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 23/26] perf tools: Add struct perf_hpp_list argument to helper functions Jiri Olsa
                   ` (5 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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

Link: http://lkml.kernel.org/n/tip-wvj348z8j4s9o79810vommpr@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 c8d74b357d5e..35b28caf4a76 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 130f825235a3..c9bd23537c1d 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)->sort_list, sort_list)
 
-#define perf_hpp__for_each_sort_list_safe(format, tmp)	\
-	list_for_each_entry_safe(format, tmp, &perf_hpp_list.sort_list, sort_list)
+#define perf_hpp_list__for_each_sort_list_safe(_list, format, tmp)	\
+	list_for_each_entry_safe(format, tmp, &(_list)->sort_list, sort_list)
 
 extern struct perf_hpp_fmt perf_hpp__format[];
 
-- 
2.4.3

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

* [PATCH 23/26] perf tools: Add struct perf_hpp_list argument to helper functions
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (21 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 22/26] perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:41   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 24/26] perf tools: Add hpp_list into struct hists object Jiri Olsa
                   ` (4 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-t5g9q42thptl6qaorydp2v16@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 35b28caf4a76..e904ed7b4e8a 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 c9bd23537c1d..01c321e07cb3 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 0194dd145401..b4f9841392fa 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2637,9 +2637,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;
 }
@@ -2655,5 +2655,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.4.3

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

* [PATCH 24/26] perf tools: Add hpp_list into struct hists object
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (22 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 23/26] perf tools: Add struct perf_hpp_list argument to helper functions Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 25/26] perf tools: Introduce hists__for_each_format macro Jiri Olsa
                   ` (3 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Adding hpp_list into struct hists object.

Initializing struct hists_evsel hists object
to carry global perf_hpp_list list.

Link: http://lkml.kernel.org/n/tip-esut5ecrk8m8ikx162ufvj5z@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 3ba70b7868d5..7ac32bdf53ee 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1594,7 +1594,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;
@@ -1603,6 +1603,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;
 }
 
@@ -1639,7 +1640,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 01c321e07cb3..32599fc7b39f 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.4.3

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

* [PATCH 25/26] perf tools: Introduce hists__for_each_format macro
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (23 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 24/26] perf tools: Add hpp_list into struct hists object Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:41   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-18  9:24 ` [PATCH 26/26] perf tools: Introduce hists__for_each_sort_list macro Jiri Olsa
                   ` (2 subsequent siblings)
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-z96h1i1fdz4obdgouz8ryhy4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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     | 10 +++++-----
 tools/perf/util/hist.h         |  3 +++
 5 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 4416540f2bba..d96afb006206 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1040,7 +1040,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;
@@ -1144,7 +1144,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;
 
@@ -1414,7 +1414,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;
 
@@ -2077,7 +2077,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 e904ed7b4e8a..b92e567372dd 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 f40b05e109cd..89778a9d7ae6 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -360,7 +360,7 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
 				    !prefixcmp(sort_order, "comm"))) {
 		struct perf_hpp_fmt *fmt;
 
-		perf_hpp_list__for_each_format(&perf_hpp_list, fmt) {
+		hists__for_each_format(hists, fmt) {
 			if (!perf_hpp__is_sort_entry(fmt))
 				continue;
 
@@ -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;
 
@@ -452,7 +452,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)
@@ -463,7 +463,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;
 
@@ -487,7 +487,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 32599fc7b39f..e67542b8c126 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)->sort_list, 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.4.3

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

* [PATCH 26/26] perf tools: Introduce hists__for_each_sort_list macro
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (24 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 25/26] perf tools: Introduce hists__for_each_format macro Jiri Olsa
@ 2016-01-18  9:24 ` Jiri Olsa
  2016-02-04 12:42   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  2016-01-19 12:58 ` [RFC 00/26] perf tools: Introduce hists specific format entries Namhyung Kim
  2016-01-25  7:15 ` Jiri Olsa
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-18  9:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-t5g9q42thptl6qaorydp2v16@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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 7ac32bdf53ee..6c058d7739cc 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -949,10 +949,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;
@@ -964,10 +965,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;
@@ -1108,10 +1110,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 e67542b8c126..3fa24b55ebf3 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.4.3

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (25 preceding siblings ...)
  2016-01-18  9:24 ` [PATCH 26/26] perf tools: Introduce hists__for_each_sort_list macro Jiri Olsa
@ 2016-01-19 12:58 ` Namhyung Kim
  2016-01-19 13:23   ` Jiri Olsa
  2016-01-25  7:15 ` Jiri Olsa
  27 siblings, 1 reply; 72+ messages in thread
From: Namhyung Kim @ 2016-01-19 12:58 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

On Mon, Jan 18, 2016 at 10:23:58AM +0100, Jiri Olsa wrote:
> hi,
> currently we have global format sort and output
> lists. This rfc patchset introduces hists object
> based format entries to allow the hist object to
> carry specific format entries.
> 
> This will allow to have distinguished hist objects
> displaying different stuff in output.

How do you manage hists objects to have different hpp lists?  Will you
provide an option to users?  Or is it specific to some tools like
c2c?


> 
> Also available in:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/hists_fmt
> 
> thanks for comments,
> jirka
> 
> 
> ---
> Jiri Olsa (26):
>       perf tools: Factor output_resort from hists__output_resort
>       perf tools: Introduce perf_evsel__output_resort function
>       perf tools: Add _idx fields into struct perf_hpp_fmt
>       perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width
>       perf tools: Add equal method to perf_hpp_fmt struct
>       perf tools: Add hpp__equal callback function
>       perf tools: Make hpp setup function generic
>       perf report: Move ui initialization ahead of sort setup
>       perf tools: Allocate output sort field
>       perf tools: Remove perf_hpp__column_(disable|enable)
>       perf tools: Properly release format fields
>       perf tools: Separate sort fields parsing into setup_sort_list function
>       perf tools: Separate output fields parsing into setup_output_list function
>       perf tools: Introduce struct perf_hpp_list
>       perf tools: Introduce perf_hpp_list__init function
>       perf tools: Add perf_hpp_list register helpers
>       perf tools: Pass perf_hpp_list all the way through setup_sort_list
>       perf tools: Pass perf_hpp_list all the way through setup_output_list
>       perf tools: Introduce perf_hpp_list__for_each_format macro
>       perf tools: Introduce perf_hpp_list__for_each_format_safe macro
>       perf tools: Introduce perf_hpp_list__for_each_sort_list macro
>       perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro
>       perf tools: Add struct perf_hpp_list argument to helper functions
>       perf tools: Add hpp_list into struct hists object
>       perf tools: Introduce hists__for_each_format macro
>       perf tools: Introduce hists__for_each_sort_list macro
> 
>  tools/perf/builtin-annotate.c     |   2 +-
>  tools/perf/builtin-report.c       |  20 ++++-----
>  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/ui/browsers/hists.c    |   8 ++--
>  tools/perf/ui/gtk/hists.c         |   6 +--
>  tools/perf/ui/hist.c              | 170 +++++++++++++++++++++++++++++++++++++----------------------------------
>  tools/perf/ui/stdio/hist.c        |  10 ++---
>  tools/perf/util/hist.c            |  47 ++++++++++++++------
>  tools/perf/util/hist.h            |  65 ++++++++++++++++++++--------
>  tools/perf/util/sort.c            | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
>  13 files changed, 359 insertions(+), 224 deletions(-)

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-01-19 12:58 ` [RFC 00/26] perf tools: Introduce hists specific format entries Namhyung Kim
@ 2016-01-19 13:23   ` Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: Jiri Olsa @ 2016-01-19 13:23 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Peter Zijlstra

On Tue, Jan 19, 2016 at 09:58:41PM +0900, Namhyung Kim wrote:
> On Mon, Jan 18, 2016 at 10:23:58AM +0100, Jiri Olsa wrote:
> > hi,
> > currently we have global format sort and output
> > lists. This rfc patchset introduces hists object
> > based format entries to allow the hist object to
> > carry specific format entries.
> > 
> > This will allow to have distinguished hist objects
> > displaying different stuff in output.
> 
> How do you manage hists objects to have different hpp lists?  Will you
> provide an option to users?  Or is it specific to some tools like
> c2c?

this patchset does not change the visible things,
it allows to initialize hists with perf_hpp_list
that provides sort/output list

the only visible usage I ahve for this is the c2c display
where I display cahclines with details on one screen and
separate cacheline offsets on another

jirka

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
                   ` (26 preceding siblings ...)
  2016-01-19 12:58 ` [RFC 00/26] perf tools: Introduce hists specific format entries Namhyung Kim
@ 2016-01-25  7:15 ` Jiri Olsa
  2016-01-25 14:24   ` Namhyung Kim
  27 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-25  7:15 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar,
	Namhyung Kim, Peter Zijlstra

On Mon, Jan 18, 2016 at 10:23:58AM +0100, Jiri Olsa wrote:
> hi,
> currently we have global format sort and output
> lists. This rfc patchset introduces hists object
> based format entries to allow the hist object to
> carry specific format entries.
> 
> This will allow to have distinguished hist objects
> displaying different stuff in output.
> 
> Also available in:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/hists_fmt
> 
> thanks for comments,

ping

thanks,
jirka

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-01-25  7:15 ` Jiri Olsa
@ 2016-01-25 14:24   ` Namhyung Kim
  2016-01-25 14:37     ` Jiri Olsa
  0 siblings, 1 reply; 72+ messages in thread
From: Namhyung Kim @ 2016-01-25 14:24 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Peter Zijlstra

Hi Jiri,

On Mon, Jan 25, 2016 at 08:15:52AM +0100, Jiri Olsa wrote:
> On Mon, Jan 18, 2016 at 10:23:58AM +0100, Jiri Olsa wrote:
> > hi,
> > currently we have global format sort and output
> > lists. This rfc patchset introduces hists object
> > based format entries to allow the hist object to
> > carry specific format entries.
> > 
> > This will allow to have distinguished hist objects
> > displaying different stuff in output.

The concepth is OK.  But I don't want to embed hists into the
hist_entry for hierarchy mode.  As you said it'd be better to factor
out common bits and embed it both from hists and hist entry.  In the
minimal, two rbroot (for in and out) and a format list would be
required IMHO.

Thanks,
Namhyung

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-01-25 14:24   ` Namhyung Kim
@ 2016-01-25 14:37     ` Jiri Olsa
  2016-02-02 22:22       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-25 14:37 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Peter Zijlstra

On Mon, Jan 25, 2016 at 11:24:24PM +0900, Namhyung Kim wrote:
> Hi Jiri,
> 
> On Mon, Jan 25, 2016 at 08:15:52AM +0100, Jiri Olsa wrote:
> > On Mon, Jan 18, 2016 at 10:23:58AM +0100, Jiri Olsa wrote:
> > > hi,
> > > currently we have global format sort and output
> > > lists. This rfc patchset introduces hists object
> > > based format entries to allow the hist object to
> > > carry specific format entries.
> > > 
> > > This will allow to have distinguished hist objects
> > > displaying different stuff in output.
> 
> The concepth is OK.  But I don't want to embed hists into the
> hist_entry for hierarchy mode.  As you said it'd be better to factor
> out common bits and embed it both from hists and hist entry.  In the
> minimal, two rbroot (for in and out) and a format list would be
> required IMHO.

right.. however this patchset just adds the support to have
format lists (sort and output) defined for the hists object

I plan the 'cutting out common hists' part to come after this
one and after we merge your hierachy view patchset

thanks,
jirka

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

* Re: [PATCH 14/26] perf tools: Introduce struct perf_hpp_list
  2016-01-18  9:24 ` [PATCH 14/26] perf tools: Introduce struct perf_hpp_list Jiri Olsa
@ 2016-01-25 15:00   ` Namhyung Kim
  2016-01-25 15:09     ` Jiri Olsa
  2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Namhyung Kim @ 2016-01-25 15:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

On Mon, Jan 18, 2016 at 10:24:12AM +0100, Jiri Olsa wrote:
> 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.
> 
> Link: http://lkml.kernel.org/n/tip-bdn1hamlwp2529thajbrh2w7@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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..1253a62c422f 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 = {
> +	.list		= LIST_HEAD_INIT(perf_hpp_list.list),
> +	.sort_list	= LIST_HEAD_INIT(perf_hpp_list.sort_list),

As the struct name already contains 'list', I don't think we need to
repeat it in the fields.  


> +};
>  
>  #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.list);
>  }
>  
>  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.sort_list);
>  }
>  
>  void perf_hpp__cancel_cumulate(void)
> diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> index f3bcf2d38733..a9c8ccfcc284 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 list;
> +	struct list_head sort_list;
> +};

What about this?

  struct perf_hpp_list {
    struct list_head fields;
    struct list_head sorts;
  };

This also aligns with the option names.

Thanks,
Namhyung


> +
> +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.list, 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.list, 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.sort_list, 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.sort_list, sort_list)
>  
>  extern struct perf_hpp_fmt perf_hpp__format[];
>  
> -- 
> 2.4.3
> 

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

* Re: [PATCH 14/26] perf tools: Introduce struct perf_hpp_list
  2016-01-25 15:00   ` Namhyung Kim
@ 2016-01-25 15:09     ` Jiri Olsa
  2016-02-02 21:19       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-01-25 15:09 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, David Ahern,
	Ingo Molnar, Peter Zijlstra

On Tue, Jan 26, 2016 at 12:00:46AM +0900, Namhyung Kim wrote:

SNIP

> >  void perf_hpp__cancel_cumulate(void)
> > diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> > index f3bcf2d38733..a9c8ccfcc284 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 list;
> > +	struct list_head sort_list;
> > +};
> 
> What about this?
> 
>   struct perf_hpp_list {
>     struct list_head fields;
>     struct list_head sorts;
>   };
> 
> This also aligns with the option names.

yep, sounds better ;-)

thanks,
jirka

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

* Re: [PATCH 14/26] perf tools: Introduce struct perf_hpp_list
  2016-01-25 15:09     ` Jiri Olsa
@ 2016-02-02 21:19       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-02 21:19 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

Em Mon, Jan 25, 2016 at 04:09:33PM +0100, Jiri Olsa escreveu:
> On Tue, Jan 26, 2016 at 12:00:46AM +0900, Namhyung Kim wrote:
> 
> SNIP
> 
> > >  void perf_hpp__cancel_cumulate(void)
> > > diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> > > index f3bcf2d38733..a9c8ccfcc284 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 list;
> > > +	struct list_head sort_list;
> > > +};
> > 
> > What about this?
> > 
> >   struct perf_hpp_list {
> >     struct list_head fields;
> >     struct list_head sorts;
> >   };
> > 
> > This also aligns with the option names.
> 
> yep, sounds better ;-)

Ok, did the change as I'm refreshing this series to merge it.

- Arnaldo

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-01-25 14:37     ` Jiri Olsa
@ 2016-02-02 22:22       ` Arnaldo Carvalho de Melo
  2016-02-02 22:25         ` Arnaldo Carvalho de Melo
  2016-02-02 22:42         ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-02 22:22 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

Em Mon, Jan 25, 2016 at 03:37:43PM +0100, Jiri Olsa escreveu:
> On Mon, Jan 25, 2016 at 11:24:24PM +0900, Namhyung Kim wrote:
> > Hi Jiri,
> > 
> > On Mon, Jan 25, 2016 at 08:15:52AM +0100, Jiri Olsa wrote:
> > > On Mon, Jan 18, 2016 at 10:23:58AM +0100, Jiri Olsa wrote:
> > > > hi,
> > > > currently we have global format sort and output
> > > > lists. This rfc patchset introduces hists object
> > > > based format entries to allow the hist object to
> > > > carry specific format entries.
> > > > 
> > > > This will allow to have distinguished hist objects
> > > > displaying different stuff in output.
> > 
> > The concepth is OK.  But I don't want to embed hists into the
> > hist_entry for hierarchy mode.  As you said it'd be better to factor
> > out common bits and embed it both from hists and hist entry.  In the
> > minimal, two rbroot (for in and out) and a format list would be
> > required IMHO.
> 
> right.. however this patchset just adds the support to have
> format lists (sort and output) defined for the hists object
> 
> I plan the 'cutting out common hists' part to come after this
> one and after we merge your hierachy view patchset

Ok, so I rebased it on top of my perf/core branch, adjusting some stuff
wrt recent patchkits from Namhyung (hist_entry__callchain_fprintf() is
no more, etc), and renaming that perf_hpp_list->{list,sort_list} to
->{fields,sorts} as Namhyung suggested and you agreed, it builds...

But perf top isn't showing the overhead column... there were some
changes to perf report in this patchkit to move some initializations...
will check there...

- Arnaldo

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-02-02 22:22       ` Arnaldo Carvalho de Melo
@ 2016-02-02 22:25         ` Arnaldo Carvalho de Melo
  2016-02-02 22:42         ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-02 22:25 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> Ok, so I rebased it on top of my perf/core branch, adjusting some stuff
> wrt recent patchkits from Namhyung (hist_entry__callchain_fprintf() is
> no more, etc), and renaming that perf_hpp_list->{list,sort_list} to
> ->{fields,sorts} as Namhyung suggested and you agreed, it builds...
> 
> But perf top isn't showing the overhead column... there were some
> changes to perf report in this patchkit to move some initializations...
> will check there...

Double checking...

[acme@jouet linux]$ git bisect bad
cd85325039555bbf37d08d399ae2b1c91c70a565 is the first bad commit
commit cd85325039555bbf37d08d399ae2b1c91c70a565
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Jan 18 10:24:07 2016 +0100

    perf hists: Allocate output sort field
    
    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>

:040000 040000 f119a49ec0c9954f3117e151719c3c322c1651e4 4bb14abe5005fe29c45eecd9f6fab30fabc0fd99 M	tools
[acme@jouet linux]$

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-02-02 22:22       ` Arnaldo Carvalho de Melo
  2016-02-02 22:25         ` Arnaldo Carvalho de Melo
@ 2016-02-02 22:42         ` Arnaldo Carvalho de Melo
  2016-02-03  7:58           ` Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-02-02 22:42 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> Ok, so I rebased it on top of my perf/core branch, adjusting some stuff
> wrt recent patchkits from Namhyung (hist_entry__callchain_fprintf() is
> no more, etc), and renaming that perf_hpp_list->{list,sort_list} to
> ->{fields,sorts} as Namhyung suggested and you agreed, it builds...
> 
> But perf top isn't showing the overhead column... there were some
> changes to perf report in this patchkit to move some initializations...
> will check there...

Fixed, doing the same change you made for 'perf report', moving the
setup_sorting call to after the setup_browser one, inserted a new patch
with that just before the patch where the problem was bisected, please
check.

To recap:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tmp.perf/hists/hpp_list

https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=tmp.perf/hists/hpp_list&id=7d105448f8922679956728a7f5106218378c450e

- Arnaldo

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-02-02 22:42         ` Arnaldo Carvalho de Melo
@ 2016-02-03  7:58           ` Jiri Olsa
  2016-02-03 11:02             ` Jiri Olsa
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-02-03  7:58 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

On Tue, Feb 02, 2016 at 07:42:16PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Ok, so I rebased it on top of my perf/core branch, adjusting some stuff
> > wrt recent patchkits from Namhyung (hist_entry__callchain_fprintf() is
> > no more, etc), and renaming that perf_hpp_list->{list,sort_list} to
> > ->{fields,sorts} as Namhyung suggested and you agreed, it builds...
> > 
> > But perf top isn't showing the overhead column... there were some
> > changes to perf report in this patchkit to move some initializations...
> > will check there...
> 
> Fixed, doing the same change you made for 'perf report', moving the
> setup_sorting call to after the setup_browser one, inserted a new patch
> with that just before the patch where the problem was bisected, please
> check.
> 
> To recap:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tmp.perf/hists/hpp_list
> 
> https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=tmp.perf/hists/hpp_list&id=7d105448f8922679956728a7f5106218378c450e

I'll check on that, thanks a lot

jirka

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

* Re: [RFC 00/26] perf tools: Introduce hists specific format entries
  2016-02-03  7:58           ` Jiri Olsa
@ 2016-02-03 11:02             ` Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: Jiri Olsa @ 2016-02-03 11:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

On Wed, Feb 03, 2016 at 08:58:53AM +0100, Jiri Olsa wrote:
> On Tue, Feb 02, 2016 at 07:42:16PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Ok, so I rebased it on top of my perf/core branch, adjusting some stuff
> > > wrt recent patchkits from Namhyung (hist_entry__callchain_fprintf() is
> > > no more, etc), and renaming that perf_hpp_list->{list,sort_list} to
> > > ->{fields,sorts} as Namhyung suggested and you agreed, it builds...
> > > 
> > > But perf top isn't showing the overhead column... there were some
> > > changes to perf report in this patchkit to move some initializations...
> > > will check there...
> > 
> > Fixed, doing the same change you made for 'perf report', moving the
> > setup_sorting call to after the setup_browser one, inserted a new patch
> > with that just before the patch where the problem was bisected, please
> > check.
> > 
> > To recap:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tmp.perf/hists/hpp_list
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=tmp.perf/hists/hpp_list&id=7d105448f8922679956728a7f5106218378c450e
> 
> I'll check on that, thanks a lot

it looks ok to me

thanks,
jirka

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

* [tip:perf/core] perf hists: Factor output_resort from hists__output_resort
  2016-01-18  9:23 ` [PATCH 01/26] perf tools: Factor output_resort from hists__output_resort Jiri Olsa
@ 2016-02-04 12:33   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, mingo, namhyung, dsahern, hpa, tglx, jolsa,
	a.p.zijlstra

Commit-ID:  01441af5df438a171bce36bc3c7cfb588bc98a7a
Gitweb:     http://git.kernel.org/tip/01441af5df438a171bce36bc3c7cfb588bc98a7a
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:23:59 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 11:13:11 -0300

perf hists: Factor output_resort from hists__output_resort

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 098310b..7797d06 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)
 {

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

* [tip:perf/core] perf hists: Introduce perf_evsel__output_resort function
  2016-01-18  9:24 ` [PATCH 02/26] perf tools: Introduce perf_evsel__output_resort function Jiri Olsa
@ 2016-02-04 12:33   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, acme, dsahern, linux-kernel, hpa, mingo, jolsa,
	a.p.zijlstra, tglx

Commit-ID:  452ce03b1e686f0b2da6c1644dce7cdc71e3c69c
Gitweb:     http://git.kernel.org/tip/452ce03b1e686f0b2da6c1644dce7cdc71e3c69c
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:00 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 11:13:11 -0300

perf hists: Introduce perf_evsel__output_resort function

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 cc5c126..cfe3663 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 72ed0b4..54ce047 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 bf01cbb..f1bbe2a 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 5e6a86e..ecf136c 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 351a424..34b945a 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 b231265..23cce67 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 7797d06..d07955c 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 d4ec482..bc24997 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);
 

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

* [tip:perf/core] perf hists: Add _idx fields into struct perf_hpp_fmt
  2016-01-18  9:24 ` [PATCH 03/26] perf tools: Add _idx fields into struct perf_hpp_fmt Jiri Olsa
@ 2016-02-04 12:34   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, a.p.zijlstra, tglx, namhyung, jolsa, linux-kernel, dsahern,
	hpa, mingo

Commit-ID:  b21a763edd5f832c6d966d9e60376f3d21009859
Gitweb:     http://git.kernel.org/tip/b21a763edd5f832c6d966d9e60376f3d21009859
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:01 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 11:13:11 -0300

perf hists: Add _idx fields into struct perf_hpp_fmt

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 bf2a66e..d392801 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 bc24997..8a0cbde 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;

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

* [tip:perf/core] perf hists: Use struct perf_hpp_fmt:: idx in perf_hpp__reset_width
  2016-01-18  9:24 ` [PATCH 04/26] perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Jiri Olsa
@ 2016-02-04 12:34   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, linux-kernel, acme, hpa, namhyung, dsahern, mingo,
	tglx, jolsa

Commit-ID:  2e8b79e706f504801fbce19fa9f16f3c858a105e
Gitweb:     http://git.kernel.org/tip/2e8b79e706f504801fbce19fa9f16f3c858a105e
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:02 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 11:13:12 -0300

perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width

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 d392801..5a11bf0 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:

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

* [tip:perf/core] perf hists: Add 'equal' method to perf_hpp_fmt struct
  2016-01-18  9:24 ` [PATCH 05/26] perf tools: Add equal method to perf_hpp_fmt struct Jiri Olsa
@ 2016-02-04 12:34   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, linux-kernel, a.p.zijlstra, tglx, acme, jolsa, hpa,
	dsahern, mingo

Commit-ID:  97358084b91e94e5f8fcf0379f0430c0ea16bd3b
Gitweb:     http://git.kernel.org/tip/97358084b91e94e5f8fcf0379f0430c0ea16bd3b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:03 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 11:13:12 -0300

perf hists: Add 'equal' method to perf_hpp_fmt struct

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 5a11bf0..71c8bb7 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 8a0cbde..9a240d7 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 898e4b0..170f7f7 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);

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

* [tip:perf/core] perf hists: Add 'hpp__equal' callback function
  2016-01-18  9:24 ` [PATCH 06/26] perf tools: Add hpp__equal callback function Jiri Olsa
@ 2016-02-04 12:35   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, namhyung, acme, linux-kernel, dsahern, jolsa, hpa, tglx,
	a.p.zijlstra

Commit-ID:  c0020efa079c5fc2388945ae7e856b362731442d
Gitweb:     http://git.kernel.org/tip/c0020efa079c5fc2388945ae7e856b362731442d
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:04 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:01 -0300

perf hists: Add 'hpp__equal' callback function

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 71c8bb7..b543f4b 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[] = {

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

* [tip:perf/core] perf hists: Make hpp setup function generic
  2016-01-18  9:24 ` [PATCH 07/26] perf tools: Make hpp setup function generic Jiri Olsa
@ 2016-02-04 12:35   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, linux-kernel, dsahern, namhyung, a.p.zijlstra, jolsa,
	mingo, acme

Commit-ID:  3f931f2c4274565fd6c6a642b16387358cbe6266
Gitweb:     http://git.kernel.org/tip/3f931f2c4274565fd6c6a642b16387358cbe6266
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:05 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:02 -0300

perf hists: Make hpp setup function generic

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 b543f4b..b0fcaec 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);

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

* [tip:perf/core] perf report: Move UI initialization ahead of sort setup
  2016-01-18  9:24 ` [PATCH 08/26] perf report: Move ui initialization ahead of sort setup Jiri Olsa
@ 2016-02-04 12:35   ` tip-bot for Jiri Olsa
  2016-02-04 12:36   ` [tip:perf/core] perf top: " tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mingo, hpa, tglx, namhyung, jolsa, acme, dsahern,
	a.p.zijlstra

Commit-ID:  9887804d01abf7a4e03cfd6be0312d0a5c4e4aba
Gitweb:     http://git.kernel.org/tip/9887804d01abf7a4e03cfd6be0312d0a5c4e4aba
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:06 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:03 -0300

perf report: Move UI initialization ahead of sort setup

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 54ce047..1eab50a 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);

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

* [tip:perf/core] perf top: Move UI initialization ahead of sort setup
  2016-01-18  9:24 ` [PATCH 08/26] perf report: Move ui initialization ahead of sort setup Jiri Olsa
  2016-02-04 12:35   ` [tip:perf/core] perf report: Move UI " tip-bot for Jiri Olsa
@ 2016-02-04 12:36   ` tip-bot for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Arnaldo Carvalho de Melo @ 2016-02-04 12:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, mingo, a.p.zijlstra, acme, tglx, hpa, linux-kernel,
	dsahern, namhyung

Commit-ID:  3ee60c3b18bd4bf30ea9b70e7542116bb5c205ba
Gitweb:     http://git.kernel.org/tip/3ee60c3b18bd4bf30ea9b70e7542116bb5c205ba
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Mon, 18 Jan 2016 10:24:06 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:03 -0300

perf top: Move UI initialization ahead of sort setup

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 f1bbe2a..a75de39 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);

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

* [tip:perf/core] perf hists: Allocate output sort field
  2016-01-18  9:24 ` [PATCH 09/26] perf tools: Allocate output sort field Jiri Olsa
@ 2016-02-04 12:36   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, acme, mingo, linux-kernel, a.p.zijlstra, tglx, dsahern,
	hpa, jolsa

Commit-ID:  1945c3e734cd1f01535dc76de47c38bbe9a87352
Gitweb:     http://git.kernel.org/tip/1945c3e734cd1f01535dc76de47c38bbe9a87352
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:07 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:07 -0300

perf hists: Allocate output sort field

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 b0fcaec..c877c52 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 170f7f7..52e4a36 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;
 }
 

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

* [tip:perf/core] perf hists: Remove perf_hpp__column_( disable|enable)
  2016-01-18  9:24 ` [PATCH 10/26] perf tools: Remove perf_hpp__column_(disable|enable) Jiri Olsa
@ 2016-02-04 12:36   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, jolsa, tglx, dsahern, namhyung, acme, linux-kernel,
	hpa, mingo

Commit-ID:  12cb4397fb398545207acf772b219bd751786015
Gitweb:     http://git.kernel.org/tip/12cb4397fb398545207acf772b219bd751786015
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:08 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:08 -0300

perf hists: Remove perf_hpp__column_(disable|enable)

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 c877c52..80d63a9 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 9a240d7..1f9e21dd 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);

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

* [tip:perf/core] perf hists: Properly release format fields
  2016-01-18  9:24 ` [PATCH 11/26] perf tools: Properly release format fields Jiri Olsa
@ 2016-02-04 12:37   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, linux-kernel, dsahern, acme, hpa, jolsa, mingo,
	a.p.zijlstra, namhyung

Commit-ID:  564132f3116cf376fdc04b2380e621f35efbb6c7
Gitweb:     http://git.kernel.org/tip/564132f3116cf376fdc04b2380e621f35efbb6c7
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:09 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:08 -0300

perf hists: Properly release format fields

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 80d63a9..2cd1a03 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 1f9e21dd..f3bcf2d 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 52e4a36..b5389a5 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);

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

* [tip:perf/core] perf hists: Separate sort fields parsing into setup_sort_list function
  2016-01-18  9:24 ` [PATCH 12/26] perf tools: Separate sort fields parsing into setup_sort_list function Jiri Olsa
@ 2016-02-04 12:37   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, acme, linux-kernel, dsahern, a.p.zijlstra, hpa, mingo,
	namhyung, tglx

Commit-ID:  2fbaa39079672bf52a9208ec1263385b48933cc3
Gitweb:     http://git.kernel.org/tip/2fbaa39079672bf52a9208ec1263385b48933cc3
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:10 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:09 -0300

perf hists: Separate sort fields parsing into setup_sort_list function

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 b5389a5..ab1c21a 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;

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

* [tip:perf/core] perf hists: Separate output fields parsing into setup_output_list function
  2016-01-18  9:24 ` [PATCH 13/26] perf tools: Separate output fields parsing into setup_output_list function Jiri Olsa
@ 2016-02-04 12:37   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, namhyung, tglx, a.p.zijlstra, jolsa, dsahern,
	hpa, mingo

Commit-ID:  6d3375efebe906ad0ce55ddaa883bf41fd8c444b
Gitweb:     http://git.kernel.org/tip/6d3375efebe906ad0ce55ddaa883bf41fd8c444b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:11 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:09 -0300

perf hists: Separate output fields parsing into setup_output_list function

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 ab1c21a..36dbd55 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);

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

* [tip:perf/core] perf hists: Introduce struct perf_hpp_list
  2016-01-18  9:24 ` [PATCH 14/26] perf tools: Introduce struct perf_hpp_list Jiri Olsa
  2016-01-25 15:00   ` Namhyung Kim
@ 2016-02-04 12:38   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, tglx, hpa, jolsa, linux-kernel, namhyung, dsahern,
	a.p.zijlstra

Commit-ID:  7c31e10266bd18de163d5c60899591c0540bb002
Gitweb:     http://git.kernel.org/tip/7c31e10266bd18de163d5c60899591c0540bb002
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:12 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:10 -0300

perf hists: Introduce struct perf_hpp_list

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 2cd1a03..74dbeac 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 f3bcf2d..203397a 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[];
 

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

* [tip:perf/core] perf hists: Introduce perf_hpp_list__init function
  2016-01-18  9:24 ` [PATCH 15/26] perf tools: Introduce perf_hpp_list__init function Jiri Olsa
@ 2016-02-04 12:38   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, a.p.zijlstra, namhyung, dsahern, linux-kernel, acme, mingo,
	jolsa, tglx

Commit-ID:  94b3dc3865097e11073f1abf5b20b5f80af223af
Gitweb:     http://git.kernel.org/tip/94b3dc3865097e11073f1abf5b20b5f80af223af
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:13 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:11 -0300

perf hists: Introduce perf_hpp_list__init function

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 d07955c..b762ecc 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 203397a..e22f98e 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 */

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

* [tip:perf/core] perf hists: Add perf_hpp_list register helpers
  2016-01-18  9:24 ` [PATCH 16/26] perf tools: Add perf_hpp_list register helpers Jiri Olsa
@ 2016-02-04 12:38   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, hpa, linux-kernel, dsahern, jolsa, a.p.zijlstra, tglx,
	namhyung, acme

Commit-ID:  ebdd98e030f5ed6dd1bae9ab01b084f97685bd60
Gitweb:     http://git.kernel.org/tip/ebdd98e030f5ed6dd1bae9ab01b084f97685bd60
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:14 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:12 -0300

perf hists: Add perf_hpp_list register helpers

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 74dbeac..1655c0d 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 e22f98e..a7769d7 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);

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

* [tip:perf/core] perf hists: Pass perf_hpp_list all the way through setup_output_list
  2016-01-18  9:24 ` [PATCH 18/26] perf tools: Pass perf_hpp_list all the way through setup_output_list Jiri Olsa
@ 2016-02-04 12:39   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, tglx, hpa, dsahern, namhyung, a.p.zijlstra, linux-kernel,
	mingo, jolsa

Commit-ID:  07600027fb7114bf7bcabdd121e5178f200d8a44
Gitweb:     http://git.kernel.org/tip/07600027fb7114bf7bcabdd121e5178f200d8a44
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:16 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:13 -0300

perf hists: Pass perf_hpp_list all the way through setup_output_list

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 36dbd55..f643bed 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);

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

* [tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_format macro
  2016-01-18  9:24 ` [PATCH 19/26] perf tools: Introduce perf_hpp_list__for_each_format macro Jiri Olsa
@ 2016-02-04 12:39   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, hpa, acme, linux-kernel, a.p.zijlstra, namhyung, jolsa,
	tglx, dsahern

Commit-ID:  cf094045d718437e3d5cd42ac09d77561cb2f368
Gitweb:     http://git.kernel.org/tip/cf094045d718437e3d5cd42ac09d77561cb2f368
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:17 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:14 -0300

perf hists: Introduce perf_hpp_list__for_each_format macro

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 61d578b..df0aedf 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 0f8dcfd..eca5151 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 1655c0d..7b5e8ce 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 691e52c..83e0bf2 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 a7769d7..eadffca 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 f643bed..1e134ff 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;
 

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

* [tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_format_safe macro
  2016-01-18  9:24 ` [PATCH 20/26] perf tools: Introduce perf_hpp_list__for_each_format_safe macro Jiri Olsa
@ 2016-02-04 12:40   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, tglx, jolsa, namhyung, mingo, acme, hpa,
	linux-kernel, dsahern

Commit-ID:  7a1799e0a276069d8b903ba17179b4983b98c04b
Gitweb:     http://git.kernel.org/tip/7a1799e0a276069d8b903ba17179b4983b98c04b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:18 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:14 -0300

perf hists: Introduce perf_hpp_list__for_each_format_safe macro

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 7b5e8ce..348706a 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 eadffca..f5b2309 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)

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

* [tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_sort_list macro
  2016-01-18  9:24 ` [PATCH 21/26] perf tools: Introduce perf_hpp_list__for_each_sort_list macro Jiri Olsa
@ 2016-02-04 12:40   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, tglx, dsahern, jolsa, hpa, linux-kernel, namhyung,
	a.p.zijlstra

Commit-ID:  d29a497090845002ee449c8dc682dd59ad8bab42
Gitweb:     http://git.kernel.org/tip/d29a497090845002ee449c8dc682dd59ad8bab42
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:19 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:15 -0300

perf hists: Introduce perf_hpp_list__for_each_sort_list macro

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 348706a..f09eabe 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 b762ecc..dea475d 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 f5b2309..c9b2ea4 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)

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

* [tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro
  2016-01-18  9:24 ` [PATCH 22/26] perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro Jiri Olsa
@ 2016-02-04 12:40   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, a.p.zijlstra, acme, namhyung, linux-kernel, mingo,
	dsahern, tglx, hpa

Commit-ID:  1a8ebd243a0b65c2a6d1458705d04dece937ab52
Gitweb:     http://git.kernel.org/tip/1a8ebd243a0b65c2a6d1458705d04dece937ab52
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:20 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:16 -0300

perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro

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 f09eabe..9cda51e 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 c9b2ea4..61d35a9 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[];
 

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

* [tip:perf/core] perf hists: Add struct perf_hpp_list argument to helper functions
  2016-01-18  9:24 ` [PATCH 23/26] perf tools: Add struct perf_hpp_list argument to helper functions Jiri Olsa
@ 2016-02-04 12:41   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, jolsa, linux-kernel, hpa, acme, a.p.zijlstra, tglx,
	dsahern, mingo

Commit-ID:  43e0a68f13047750a3728c983a539c61fb4121c5
Gitweb:     http://git.kernel.org/tip/43e0a68f13047750a3728c983a539c61fb4121c5
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:21 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:17 -0300

perf hists: Add struct perf_hpp_list argument to helper functions

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 9cda51e..8075d4c 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 61d35a9..a39c9c1 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 1e134ff..de620f7 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);
 }

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

* [tip:perf/core] perf tools: Add hpp_list into struct hists object
  2016-01-18  9:24 ` [PATCH 24/26] perf tools: Add hpp_list into struct hists object Jiri Olsa
@ 2016-02-04 12:41   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mingo, a.p.zijlstra, acme, hpa, jolsa, dsahern,
	tglx, namhyung

Commit-ID:  5b65855e20348a9e2772a1cb7c1e6ab477859ba6
Gitweb:     http://git.kernel.org/tip/5b65855e20348a9e2772a1cb7c1e6ab477859ba6
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:22 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:18 -0300

perf tools: Add hpp_list into struct hists object

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 dea475d..2b9cc91 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 a39c9c1..b296ff5 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,

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

* [tip:perf/core] perf hists: Introduce hists__for_each_format macro
  2016-01-18  9:24 ` [PATCH 25/26] perf tools: Introduce hists__for_each_format macro Jiri Olsa
@ 2016-02-04 12:41   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, jolsa, tglx, dsahern, hpa, a.p.zijlstra, acme, mingo,
	linux-kernel

Commit-ID:  f0786af536bb0ba54cb516eee493af03cefdbaa3
Gitweb:     http://git.kernel.org/tip/f0786af536bb0ba54cb516eee493af03cefdbaa3
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:23 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:19 -0300

perf hists: Introduce hists__for_each_format macro

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 df0aedf..3a1e096 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 eca5151..32cc38a 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 8075d4c..1ba4117 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 83e0bf2..1a6e8f7 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 b296ff5..bc90044 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 {

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

* [tip:perf/core] perf hists: Introduce hists__for_each_sort_list macro
  2016-01-18  9:24 ` [PATCH 26/26] perf tools: Introduce hists__for_each_sort_list macro Jiri Olsa
@ 2016-02-04 12:42   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-02-04 12:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, linux-kernel, dsahern, jolsa, tglx, mingo, acme,
	a.p.zijlstra, namhyung

Commit-ID:  aa6f50af822a552b579252ecd42224e09e11e879
Gitweb:     http://git.kernel.org/tip/aa6f50af822a552b579252ecd42224e09e11e879
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 18 Jan 2016 10:24:24 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 3 Feb 2016 12:24:20 -0300

perf hists: Introduce hists__for_each_sort_list macro

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 2b9cc91..12f2d79 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 bc90044..1c7544a 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 {

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

* [PATCHv2] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-01-18  9:24 ` [PATCH 17/26] perf tools: Pass perf_hpp_list all the way through setup_sort_list Jiri Olsa
@ 2016-03-06 19:21   ` Jiri Olsa
  2016-03-07 14:31     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 72+ messages in thread
From: Jiri Olsa @ 2016-03-06 19:21 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

On Mon, Jan 18, 2016 at 10:24:15AM +0100, Jiri Olsa wrote:
> Passing perf_hpp_list all the way through setup_sort_list
> so the sort entry could be added on the arbitrary list.
> 

looks like this one got forgotten..
rebased version attached

thanks,
jirka


---
Passing perf_hpp_list all the way through setup_sort_list
so the sort entry could be added on the arbitrary list.

Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/sort.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index ab6eb7ca8c60..e4dc58e26845 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1614,14 +1614,16 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
 	return hse->se->se_filter(he, type, arg);
 }
 
-static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
+static int __sort_dimension__add_hpp_sort(struct perf_hpp_list *list,
+					  struct sort_dimension *sd,
+					  int level)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, level);
 
 	if (hse == NULL)
 		return -1;
 
-	perf_hpp__register_sort_field(&hse->hpp);
+	perf_hpp_list__register_sort_field(list, &hse->hpp);
 	return 0;
 }
 
@@ -2119,12 +2121,14 @@ out:
 	return ret;
 }
 
-static int __sort_dimension__add(struct sort_dimension *sd, int level)
+static int __sort_dimension__add(struct perf_hpp_list *list,
+				 struct sort_dimension *sd,
+				 int level)
 {
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_sort(sd, level) < 0)
+	if (__sort_dimension__add_hpp_sort(list, sd, level) < 0)
 		return -1;
 
 	if (sd->entry->se_collapse)
@@ -2135,7 +2139,9 @@ static int __sort_dimension__add(struct sort_dimension *sd, int level)
 	return 0;
 }
 
-static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
+static int __hpp_dimension__add(struct perf_hpp_list *list,
+				struct hpp_dimension *hd,
+				int level)
 {
 	struct perf_hpp_fmt *fmt;
 
@@ -2147,7 +2153,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
 		return -1;
 
 	hd->taken = 1;
-	perf_hpp__register_sort_field(fmt);
+	perf_hpp_list__register_sort_field(list, fmt);
 	return 0;
 }
 
@@ -2187,7 +2193,8 @@ int hpp_dimension__add_output(unsigned col)
 	return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[col]);
 }
 
-static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
+static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
+			       struct perf_evlist *evlist __maybe_unused,
 			       int level)
 {
 	unsigned int i;
@@ -2227,7 +2234,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 			sort__has_thread = 1;
 		}
 
-		return __sort_dimension__add(sd, level);
+		return __sort_dimension__add(list, sd, level);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -2236,7 +2243,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (strncasecmp(tok, hd->name, strlen(tok)))
 			continue;
 
-		return __hpp_dimension__add(hd, level);
+		return __hpp_dimension__add(list, hd, level);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
@@ -2251,7 +2258,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, level);
+		__sort_dimension__add(list, sd, level);
 		return 0;
 	}
 
@@ -2267,7 +2274,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (sd->entry == &sort_mem_daddr_sym)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, level);
+		__sort_dimension__add(list, sd, level);
 		return 0;
 	}
 
@@ -2277,7 +2284,8 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 	return -ESRCH;
 }
 
-static int setup_sort_list(char *str, struct perf_evlist *evlist)
+static int setup_sort_list(struct perf_hpp_list *list, char *str,
+			   struct perf_evlist *evlist)
 {
 	char *tmp, *tok;
 	int ret = 0;
@@ -2285,7 +2293,7 @@ static int setup_sort_list(char *str, struct perf_evlist *evlist)
 
 	for (tok = strtok_r(str, ", ", &tmp);
 			tok; tok = strtok_r(NULL, ", ", &tmp)) {
-		ret = sort_dimension__add(tok, evlist, level++);
+		ret = sort_dimension__add(list, tok, evlist, level++);
 		if (ret == -EINVAL) {
 			error("Invalid --sort key: `%s'", tok);
 			break;
@@ -2430,7 +2438,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		}
 	}
 
-	ret = setup_sort_list(str, evlist);
+	ret = setup_sort_list(&perf_hpp_list, str, evlist);
 
 	free(str);
 	return ret;
@@ -2675,7 +2683,7 @@ int setup_sorting(struct perf_evlist *evlist)
 		return err;
 
 	if (parent_pattern != default_parent_pattern) {
-		err = sort_dimension__add("parent", evlist, -1);
+		err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1);
 		if (err < 0)
 			return err;
 	}
-- 
2.4.3

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

* Re: [PATCHv2] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-03-06 19:21   ` [PATCHv2] " Jiri Olsa
@ 2016-03-07 14:31     ` Arnaldo Carvalho de Melo
  2016-03-09 10:04       ` [PATCHv3] " Jiri Olsa
  0 siblings, 1 reply; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-03-07 14:31 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

Em Sun, Mar 06, 2016 at 08:21:52PM +0100, Jiri Olsa escreveu:
> On Mon, Jan 18, 2016 at 10:24:15AM +0100, Jiri Olsa wrote:
> > Passing perf_hpp_list all the way through setup_sort_list
> > so the sort entry could be added on the arbitrary list.
> > 
> 
> looks like this one got forgotten..
> rebased version attached
> 
> thanks,
> jirka
> 
> 
> ---
> Passing perf_hpp_list all the way through setup_sort_list
> so the sort entry could be added on the arbitrary list.
> 
> Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/sort.c | 38 +++++++++++++++++++++++---------------
>  1 file changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index ab6eb7ca8c60..e4dc58e26845 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1614,14 +1614,16 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
>  	return hse->se->se_filter(he, type, arg);
>  }
>  
> -static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
> +static int __sort_dimension__add_hpp_sort(struct perf_hpp_list *list,
> +					  struct sort_dimension *sd,
> +					  int level)

If the function is named foo__bar(), then the convention is for the
first parameter to be a pointer to "foo", so, above, it would make:

static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd,
					  struct perf_hpp_list *list,
					  int level)

>  {
>  	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, level);
>  
>  	if (hse == NULL)
>  		return -1;
>  
> -	perf_hpp__register_sort_field(&hse->hpp);
> +	perf_hpp_list__register_sort_field(list, &hse->hpp);
>  	return 0;
>  }
>  
> @@ -2119,12 +2121,14 @@ out:
>  	return ret;
>  }
>  
> -static int __sort_dimension__add(struct sort_dimension *sd, int level)
> +static int __sort_dimension__add(struct perf_hpp_list *list,
> +				 struct sort_dimension *sd,
> +				 int level)

ditto for here and the other cases below.

- Arnaldo

>  {
>  	if (sd->taken)
>  		return 0;
>  
> -	if (__sort_dimension__add_hpp_sort(sd, level) < 0)
> +	if (__sort_dimension__add_hpp_sort(list, sd, level) < 0)
>  		return -1;
>  
>  	if (sd->entry->se_collapse)
> @@ -2135,7 +2139,9 @@ static int __sort_dimension__add(struct sort_dimension *sd, int level)
>  	return 0;
>  }
>  
> -static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
> +static int __hpp_dimension__add(struct perf_hpp_list *list,
> +				struct hpp_dimension *hd,
> +				int level)
>  {
>  	struct perf_hpp_fmt *fmt;
>  
> @@ -2147,7 +2153,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
>  		return -1;
>  
>  	hd->taken = 1;
> -	perf_hpp__register_sort_field(fmt);
> +	perf_hpp_list__register_sort_field(list, fmt);
>  	return 0;
>  }
>  
> @@ -2187,7 +2193,8 @@ int hpp_dimension__add_output(unsigned col)
>  	return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[col]);
>  }
>  
> -static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
> +static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
> +			       struct perf_evlist *evlist __maybe_unused,
>  			       int level)
>  {
>  	unsigned int i;
> @@ -2227,7 +2234,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  			sort__has_thread = 1;
>  		}
>  
> -		return __sort_dimension__add(sd, level);
> +		return __sort_dimension__add(list, sd, level);
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
> @@ -2236,7 +2243,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  		if (strncasecmp(tok, hd->name, strlen(tok)))
>  			continue;
>  
> -		return __hpp_dimension__add(hd, level);
> +		return __hpp_dimension__add(list, hd, level);
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
> @@ -2251,7 +2258,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
>  			sort__has_sym = 1;
>  
> -		__sort_dimension__add(sd, level);
> +		__sort_dimension__add(list, sd, level);
>  		return 0;
>  	}
>  
> @@ -2267,7 +2274,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  		if (sd->entry == &sort_mem_daddr_sym)
>  			sort__has_sym = 1;
>  
> -		__sort_dimension__add(sd, level);
> +		__sort_dimension__add(list, sd, level);
>  		return 0;
>  	}
>  
> @@ -2277,7 +2284,8 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  	return -ESRCH;
>  }
>  
> -static int setup_sort_list(char *str, struct perf_evlist *evlist)
> +static int setup_sort_list(struct perf_hpp_list *list, char *str,
> +			   struct perf_evlist *evlist)
>  {
>  	char *tmp, *tok;
>  	int ret = 0;
> @@ -2285,7 +2293,7 @@ static int setup_sort_list(char *str, struct perf_evlist *evlist)
>  
>  	for (tok = strtok_r(str, ", ", &tmp);
>  			tok; tok = strtok_r(NULL, ", ", &tmp)) {
> -		ret = sort_dimension__add(tok, evlist, level++);
> +		ret = sort_dimension__add(list, tok, evlist, level++);
>  		if (ret == -EINVAL) {
>  			error("Invalid --sort key: `%s'", tok);
>  			break;
> @@ -2430,7 +2438,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
>  		}
>  	}
>  
> -	ret = setup_sort_list(str, evlist);
> +	ret = setup_sort_list(&perf_hpp_list, str, evlist);
>  
>  	free(str);
>  	return ret;
> @@ -2675,7 +2683,7 @@ int setup_sorting(struct perf_evlist *evlist)
>  		return err;
>  
>  	if (parent_pattern != default_parent_pattern) {
> -		err = sort_dimension__add("parent", evlist, -1);
> +		err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1);
>  		if (err < 0)
>  			return err;
>  	}
> -- 
> 2.4.3

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

* [PATCHv3] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-03-07 14:31     ` Arnaldo Carvalho de Melo
@ 2016-03-09 10:04       ` Jiri Olsa
  2016-03-09 12:47         ` Namhyung Kim
  2016-03-11  8:46         ` [tip:perf/core] " tip-bot for Jiri Olsa
  0 siblings, 2 replies; 72+ messages in thread
From: Jiri Olsa @ 2016-03-09 10:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra

On Mon, Mar 07, 2016 at 11:31:00AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Mar 06, 2016 at 08:21:52PM +0100, Jiri Olsa escreveu:
> > On Mon, Jan 18, 2016 at 10:24:15AM +0100, Jiri Olsa wrote:
> > > Passing perf_hpp_list all the way through setup_sort_list
> > > so the sort entry could be added on the arbitrary list.
> > > 
> > 
> > looks like this one got forgotten..
> > rebased version attached
> > 
> > thanks,
> > jirka
> > 
> > 
> > ---
> > Passing perf_hpp_list all the way through setup_sort_list
> > so the sort entry could be added on the arbitrary list.
> > 
> > Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/perf/util/sort.c | 38 +++++++++++++++++++++++---------------
> >  1 file changed, 23 insertions(+), 15 deletions(-)
> > 
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index ab6eb7ca8c60..e4dc58e26845 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -1614,14 +1614,16 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
> >  	return hse->se->se_filter(he, type, arg);
> >  }
> >  
> > -static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
> > +static int __sort_dimension__add_hpp_sort(struct perf_hpp_list *list,
> > +					  struct sort_dimension *sd,
> > +					  int level)
> 
> If the function is named foo__bar(), then the convention is for the
> first parameter to be a pointer to "foo", so, above, it would make:
> 
> static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd,
> 					  struct perf_hpp_list *list,
> 					  int level)

right, v3 attached

thanks,
jirka


---
Passing perf_hpp_list all the way through setup_sort_list
so the sort entry could be added on the arbitrary list.

Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/sort.c | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 041f236379e0..59a101e43457 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1614,19 +1614,21 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
 	return hse->se->se_filter(he, type, arg);
 }
 
-static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
+static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd,
+					  struct perf_hpp_list *list,
+					  int level)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, level);
 
 	if (hse == NULL)
 		return -1;
 
-	perf_hpp__register_sort_field(&hse->hpp);
+	perf_hpp_list__register_sort_field(list, &hse->hpp);
 	return 0;
 }
 
-static int __sort_dimension__add_hpp_output(struct perf_hpp_list *list,
-					    struct sort_dimension *sd)
+static int __sort_dimension__add_hpp_output(struct sort_dimension *sd,
+					    struct perf_hpp_list *list)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, 0);
 
@@ -2147,12 +2149,14 @@ out:
 	return ret;
 }
 
-static int __sort_dimension__add(struct sort_dimension *sd, int level)
+static int __sort_dimension__add(struct sort_dimension *sd,
+				 struct perf_hpp_list *list,
+				 int level)
 {
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_sort(sd, level) < 0)
+	if (__sort_dimension__add_hpp_sort(sd, list, level) < 0)
 		return -1;
 
 	if (sd->entry->se_collapse)
@@ -2163,7 +2167,9 @@ static int __sort_dimension__add(struct sort_dimension *sd, int level)
 	return 0;
 }
 
-static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
+static int __hpp_dimension__add(struct hpp_dimension *hd,
+				struct perf_hpp_list *list,
+				int level)
 {
 	struct perf_hpp_fmt *fmt;
 
@@ -2175,7 +2181,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
 		return -1;
 
 	hd->taken = 1;
-	perf_hpp__register_sort_field(fmt);
+	perf_hpp_list__register_sort_field(list, fmt);
 	return 0;
 }
 
@@ -2185,7 +2191,7 @@ static int __sort_dimension__add_output(struct perf_hpp_list *list,
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_output(list, sd) < 0)
+	if (__sort_dimension__add_hpp_output(sd, list) < 0)
 		return -1;
 
 	sd->taken = 1;
@@ -2215,7 +2221,8 @@ int hpp_dimension__add_output(unsigned col)
 	return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[col]);
 }
 
-static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
+static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
+			       struct perf_evlist *evlist __maybe_unused,
 			       int level)
 {
 	unsigned int i;
@@ -2255,7 +2262,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 			sort__has_thread = 1;
 		}
 
-		return __sort_dimension__add(sd, level);
+		return __sort_dimension__add(sd, list, level);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -2264,7 +2271,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (strncasecmp(tok, hd->name, strlen(tok)))
 			continue;
 
-		return __hpp_dimension__add(hd, level);
+		return __hpp_dimension__add(hd, list, level);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
@@ -2279,7 +2286,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, level);
+		__sort_dimension__add(sd, list, level);
 		return 0;
 	}
 
@@ -2295,7 +2302,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (sd->entry == &sort_mem_daddr_sym)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, level);
+		__sort_dimension__add(sd, list, level);
 		return 0;
 	}
 
@@ -2305,7 +2312,8 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 	return -ESRCH;
 }
 
-static int setup_sort_list(char *str, struct perf_evlist *evlist)
+static int setup_sort_list(struct perf_hpp_list *list, char *str,
+			   struct perf_evlist *evlist)
 {
 	char *tmp, *tok;
 	int ret = 0;
@@ -2332,7 +2340,7 @@ static int setup_sort_list(char *str, struct perf_evlist *evlist)
 		}
 
 		if (*tok) {
-			ret = sort_dimension__add(tok, evlist, level);
+			ret = sort_dimension__add(list, tok, evlist, level);
 			if (ret == -EINVAL) {
 				error("Invalid --sort key: `%s'", tok);
 				break;
@@ -2480,7 +2488,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		}
 	}
 
-	ret = setup_sort_list(str, evlist);
+	ret = setup_sort_list(&perf_hpp_list, str, evlist);
 
 	free(str);
 	return ret;
@@ -2725,7 +2733,7 @@ int setup_sorting(struct perf_evlist *evlist)
 		return err;
 
 	if (parent_pattern != default_parent_pattern) {
-		err = sort_dimension__add("parent", evlist, -1);
+		err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1);
 		if (err < 0)
 			return err;
 	}
-- 
2.4.3

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

* Re: [PATCHv3] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-03-09 10:04       ` [PATCHv3] " Jiri Olsa
@ 2016-03-09 12:47         ` Namhyung Kim
  2016-03-09 13:38           ` Arnaldo Carvalho de Melo
  2016-03-11  8:46         ` [tip:perf/core] " tip-bot for Jiri Olsa
  1 sibling, 1 reply; 72+ messages in thread
From: Namhyung Kim @ 2016-03-09 12:47 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, lkml, David Ahern,
	Ingo Molnar, Peter Zijlstra

On Wed, Mar 09, 2016 at 11:04:17AM +0100, Jiri Olsa wrote:
> On Mon, Mar 07, 2016 at 11:31:00AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Sun, Mar 06, 2016 at 08:21:52PM +0100, Jiri Olsa escreveu:
> > > --- a/tools/perf/util/sort.c
> > > +++ b/tools/perf/util/sort.c
> > > @@ -1614,14 +1614,16 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
> > >  	return hse->se->se_filter(he, type, arg);
> > >  }
> > >  
> > > -static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
> > > +static int __sort_dimension__add_hpp_sort(struct perf_hpp_list *list,
> > > +					  struct sort_dimension *sd,
> > > +					  int level)
> > 
> > If the function is named foo__bar(), then the convention is for the
> > first parameter to be a pointer to "foo", so, above, it would make:
> > 
> > static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd,
> > 					  struct perf_hpp_list *list,
> > 					  int level)
> 
> right, v3 attached
> 
> thanks,
> jirka
> 
> 
> ---
> Passing perf_hpp_list all the way through setup_sort_list
> so the sort entry could be added on the arbitrary list.
> 
> Link: http://lkml.kernel.org/n/tip-1r0tlhwdfolal61gvciii07e@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/sort.c | 44 ++++++++++++++++++++++++++------------------
>  1 file changed, 26 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 041f236379e0..59a101e43457 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1614,19 +1614,21 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
>  	return hse->se->se_filter(he, type, arg);
>  }
>  
> -static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
> +static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd,
> +					  struct perf_hpp_list *list,
> +					  int level)
>  {
>  	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, level);
>  
>  	if (hse == NULL)
>  		return -1;
>  
> -	perf_hpp__register_sort_field(&hse->hpp);
> +	perf_hpp_list__register_sort_field(list, &hse->hpp);
>  	return 0;
>  }
>  
> -static int __sort_dimension__add_hpp_output(struct perf_hpp_list *list,
> -					    struct sort_dimension *sd)
> +static int __sort_dimension__add_hpp_output(struct sort_dimension *sd,
> +					    struct perf_hpp_list *list)
>  {
>  	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, 0);
>  
> @@ -2147,12 +2149,14 @@ out:
>  	return ret;
>  }
>  
> -static int __sort_dimension__add(struct sort_dimension *sd, int level)
> +static int __sort_dimension__add(struct sort_dimension *sd,
> +				 struct perf_hpp_list *list,
> +				 int level)
>  {
>  	if (sd->taken)
>  		return 0;
>  
> -	if (__sort_dimension__add_hpp_sort(sd, level) < 0)
> +	if (__sort_dimension__add_hpp_sort(sd, list, level) < 0)
>  		return -1;
>  
>  	if (sd->entry->se_collapse)
> @@ -2163,7 +2167,9 @@ static int __sort_dimension__add(struct sort_dimension *sd, int level)
>  	return 0;
>  }
>  
> -static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
> +static int __hpp_dimension__add(struct hpp_dimension *hd,
> +				struct perf_hpp_list *list,
> +				int level)
>  {
>  	struct perf_hpp_fmt *fmt;
>  
> @@ -2175,7 +2181,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
>  		return -1;
>  
>  	hd->taken = 1;
> -	perf_hpp__register_sort_field(fmt);
> +	perf_hpp_list__register_sort_field(list, fmt);
>  	return 0;
>  }
>  
> @@ -2185,7 +2191,7 @@ static int __sort_dimension__add_output(struct perf_hpp_list *list,
>  	if (sd->taken)
>  		return 0;
>  
> -	if (__sort_dimension__add_hpp_output(list, sd) < 0)
> +	if (__sort_dimension__add_hpp_output(sd, list) < 0)
>  		return -1;
>  
>  	sd->taken = 1;
> @@ -2215,7 +2221,8 @@ int hpp_dimension__add_output(unsigned col)
>  	return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[col]);
>  }
>  
> -static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
> +static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
> +			       struct perf_evlist *evlist __maybe_unused,
>  			       int level)
>  {
>  	unsigned int i;
> @@ -2255,7 +2262,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  			sort__has_thread = 1;
>  		}
>  
> -		return __sort_dimension__add(sd, level);
> +		return __sort_dimension__add(sd, list, level);
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
> @@ -2264,7 +2271,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  		if (strncasecmp(tok, hd->name, strlen(tok)))
>  			continue;
>  
> -		return __hpp_dimension__add(hd, level);
> +		return __hpp_dimension__add(hd, list, level);
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
> @@ -2279,7 +2286,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
>  			sort__has_sym = 1;
>  
> -		__sort_dimension__add(sd, level);
> +		__sort_dimension__add(sd, list, level);
>  		return 0;
>  	}
>  
> @@ -2295,7 +2302,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  		if (sd->entry == &sort_mem_daddr_sym)
>  			sort__has_sym = 1;
>  
> -		__sort_dimension__add(sd, level);
> +		__sort_dimension__add(sd, list, level);
>  		return 0;
>  	}
>  
> @@ -2305,7 +2312,8 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
>  	return -ESRCH;
>  }
>  
> -static int setup_sort_list(char *str, struct perf_evlist *evlist)
> +static int setup_sort_list(struct perf_hpp_list *list, char *str,
> +			   struct perf_evlist *evlist)
>  {
>  	char *tmp, *tok;
>  	int ret = 0;
> @@ -2332,7 +2340,7 @@ static int setup_sort_list(char *str, struct perf_evlist *evlist)
>  		}
>  
>  		if (*tok) {
> -			ret = sort_dimension__add(tok, evlist, level);
> +			ret = sort_dimension__add(list, tok, evlist, level);
>  			if (ret == -EINVAL) {
>  				error("Invalid --sort key: `%s'", tok);
>  				break;
> @@ -2480,7 +2488,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
>  		}
>  	}
>  
> -	ret = setup_sort_list(str, evlist);
> +	ret = setup_sort_list(&perf_hpp_list, str, evlist);
>  
>  	free(str);
>  	return ret;
> @@ -2725,7 +2733,7 @@ int setup_sorting(struct perf_evlist *evlist)
>  		return err;
>  
>  	if (parent_pattern != default_parent_pattern) {
> -		err = sort_dimension__add("parent", evlist, -1);
> +		err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1);
>  		if (err < 0)
>  			return err;
>  	}
> -- 
> 2.4.3
> 

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

* Re: [PATCHv3] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-03-09 12:47         ` Namhyung Kim
@ 2016-03-09 13:38           ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 72+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-03-09 13:38 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Jiri Olsa, lkml, David Ahern, Ingo Molnar, Peter Zijlstra

Em Wed, Mar 09, 2016 at 09:47:51PM +0900, Namhyung Kim escreveu:
> On Wed, Mar 09, 2016 at 11:04:17AM +0100, Jiri Olsa wrote:
> > Passing perf_hpp_list all the way through setup_sort_list
> > so the sort entry could be added on the arbitrary list.
> 
> Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks, applied,

- Arnaldo

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

* [tip:perf/core] perf tools: Pass perf_hpp_list all the way through setup_sort_list
  2016-03-09 10:04       ` [PATCHv3] " Jiri Olsa
  2016-03-09 12:47         ` Namhyung Kim
@ 2016-03-11  8:46         ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 72+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-03-11  8:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, linux-kernel, acme, mingo, a.p.zijlstra, namhyung, tglx,
	jolsa, hpa, jolsa

Commit-ID:  d7b617f51be4fffa3cbb5adf6d4258e616dce294
Gitweb:     http://git.kernel.org/tip/d7b617f51be4fffa3cbb5adf6d4258e616dce294
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Wed, 9 Mar 2016 11:04:17 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Mar 2016 10:37:26 -0300

perf tools: Pass perf_hpp_list all the way through setup_sort_list

Pass perf_hpp_list all the way through setup_sort_list so that the sort
entry can be added on the arbitrary list.

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

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 041f236..59a101e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1614,19 +1614,21 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg)
 	return hse->se->se_filter(he, type, arg);
 }
 
-static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level)
+static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd,
+					  struct perf_hpp_list *list,
+					  int level)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, level);
 
 	if (hse == NULL)
 		return -1;
 
-	perf_hpp__register_sort_field(&hse->hpp);
+	perf_hpp_list__register_sort_field(list, &hse->hpp);
 	return 0;
 }
 
-static int __sort_dimension__add_hpp_output(struct perf_hpp_list *list,
-					    struct sort_dimension *sd)
+static int __sort_dimension__add_hpp_output(struct sort_dimension *sd,
+					    struct perf_hpp_list *list)
 {
 	struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd, 0);
 
@@ -2147,12 +2149,14 @@ out:
 	return ret;
 }
 
-static int __sort_dimension__add(struct sort_dimension *sd, int level)
+static int __sort_dimension__add(struct sort_dimension *sd,
+				 struct perf_hpp_list *list,
+				 int level)
 {
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_sort(sd, level) < 0)
+	if (__sort_dimension__add_hpp_sort(sd, list, level) < 0)
 		return -1;
 
 	if (sd->entry->se_collapse)
@@ -2163,7 +2167,9 @@ static int __sort_dimension__add(struct sort_dimension *sd, int level)
 	return 0;
 }
 
-static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
+static int __hpp_dimension__add(struct hpp_dimension *hd,
+				struct perf_hpp_list *list,
+				int level)
 {
 	struct perf_hpp_fmt *fmt;
 
@@ -2175,7 +2181,7 @@ static int __hpp_dimension__add(struct hpp_dimension *hd, int level)
 		return -1;
 
 	hd->taken = 1;
-	perf_hpp__register_sort_field(fmt);
+	perf_hpp_list__register_sort_field(list, fmt);
 	return 0;
 }
 
@@ -2185,7 +2191,7 @@ static int __sort_dimension__add_output(struct perf_hpp_list *list,
 	if (sd->taken)
 		return 0;
 
-	if (__sort_dimension__add_hpp_output(list, sd) < 0)
+	if (__sort_dimension__add_hpp_output(sd, list) < 0)
 		return -1;
 
 	sd->taken = 1;
@@ -2215,7 +2221,8 @@ int hpp_dimension__add_output(unsigned col)
 	return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[col]);
 }
 
-static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
+static int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
+			       struct perf_evlist *evlist __maybe_unused,
 			       int level)
 {
 	unsigned int i;
@@ -2255,7 +2262,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 			sort__has_thread = 1;
 		}
 
-		return __sort_dimension__add(sd, level);
+		return __sort_dimension__add(sd, list, level);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
@@ -2264,7 +2271,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (strncasecmp(tok, hd->name, strlen(tok)))
 			continue;
 
-		return __hpp_dimension__add(hd, level);
+		return __hpp_dimension__add(hd, list, level);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) {
@@ -2279,7 +2286,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, level);
+		__sort_dimension__add(sd, list, level);
 		return 0;
 	}
 
@@ -2295,7 +2302,7 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 		if (sd->entry == &sort_mem_daddr_sym)
 			sort__has_sym = 1;
 
-		__sort_dimension__add(sd, level);
+		__sort_dimension__add(sd, list, level);
 		return 0;
 	}
 
@@ -2305,7 +2312,8 @@ static int sort_dimension__add(const char *tok, struct perf_evlist *evlist,
 	return -ESRCH;
 }
 
-static int setup_sort_list(char *str, struct perf_evlist *evlist)
+static int setup_sort_list(struct perf_hpp_list *list, char *str,
+			   struct perf_evlist *evlist)
 {
 	char *tmp, *tok;
 	int ret = 0;
@@ -2332,7 +2340,7 @@ static int setup_sort_list(char *str, struct perf_evlist *evlist)
 		}
 
 		if (*tok) {
-			ret = sort_dimension__add(tok, evlist, level);
+			ret = sort_dimension__add(list, tok, evlist, level);
 			if (ret == -EINVAL) {
 				error("Invalid --sort key: `%s'", tok);
 				break;
@@ -2480,7 +2488,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
 		}
 	}
 
-	ret = setup_sort_list(str, evlist);
+	ret = setup_sort_list(&perf_hpp_list, str, evlist);
 
 	free(str);
 	return ret;
@@ -2725,7 +2733,7 @@ int setup_sorting(struct perf_evlist *evlist)
 		return err;
 
 	if (parent_pattern != default_parent_pattern) {
-		err = sort_dimension__add("parent", evlist, -1);
+		err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1);
 		if (err < 0)
 			return err;
 	}

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

end of thread, other threads:[~2016-03-11  8:46 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18  9:23 [RFC 00/26] perf tools: Introduce hists specific format entries Jiri Olsa
2016-01-18  9:23 ` [PATCH 01/26] perf tools: Factor output_resort from hists__output_resort Jiri Olsa
2016-02-04 12:33   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 02/26] perf tools: Introduce perf_evsel__output_resort function Jiri Olsa
2016-02-04 12:33   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 03/26] perf tools: Add _idx fields into struct perf_hpp_fmt Jiri Olsa
2016-02-04 12:34   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 04/26] perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width Jiri Olsa
2016-02-04 12:34   ` [tip:perf/core] perf hists: Use struct perf_hpp_fmt:: idx " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 05/26] perf tools: Add equal method to perf_hpp_fmt struct Jiri Olsa
2016-02-04 12:34   ` [tip:perf/core] perf hists: Add 'equal' " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 06/26] perf tools: Add hpp__equal callback function Jiri Olsa
2016-02-04 12:35   ` [tip:perf/core] perf hists: Add 'hpp__equal' " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 07/26] perf tools: Make hpp setup function generic Jiri Olsa
2016-02-04 12:35   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 08/26] perf report: Move ui initialization ahead of sort setup Jiri Olsa
2016-02-04 12:35   ` [tip:perf/core] perf report: Move UI " tip-bot for Jiri Olsa
2016-02-04 12:36   ` [tip:perf/core] perf top: " tip-bot for Arnaldo Carvalho de Melo
2016-01-18  9:24 ` [PATCH 09/26] perf tools: Allocate output sort field Jiri Olsa
2016-02-04 12:36   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 10/26] perf tools: Remove perf_hpp__column_(disable|enable) Jiri Olsa
2016-02-04 12:36   ` [tip:perf/core] perf hists: Remove perf_hpp__column_( disable|enable) tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 11/26] perf tools: Properly release format fields Jiri Olsa
2016-02-04 12:37   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 12/26] perf tools: Separate sort fields parsing into setup_sort_list function Jiri Olsa
2016-02-04 12:37   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 13/26] perf tools: Separate output fields parsing into setup_output_list function Jiri Olsa
2016-02-04 12:37   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 14/26] perf tools: Introduce struct perf_hpp_list Jiri Olsa
2016-01-25 15:00   ` Namhyung Kim
2016-01-25 15:09     ` Jiri Olsa
2016-02-02 21:19       ` Arnaldo Carvalho de Melo
2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 15/26] perf tools: Introduce perf_hpp_list__init function Jiri Olsa
2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 16/26] perf tools: Add perf_hpp_list register helpers Jiri Olsa
2016-02-04 12:38   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 17/26] perf tools: Pass perf_hpp_list all the way through setup_sort_list Jiri Olsa
2016-03-06 19:21   ` [PATCHv2] " Jiri Olsa
2016-03-07 14:31     ` Arnaldo Carvalho de Melo
2016-03-09 10:04       ` [PATCHv3] " Jiri Olsa
2016-03-09 12:47         ` Namhyung Kim
2016-03-09 13:38           ` Arnaldo Carvalho de Melo
2016-03-11  8:46         ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 18/26] perf tools: Pass perf_hpp_list all the way through setup_output_list Jiri Olsa
2016-02-04 12:39   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 19/26] perf tools: Introduce perf_hpp_list__for_each_format macro Jiri Olsa
2016-02-04 12:39   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 20/26] perf tools: Introduce perf_hpp_list__for_each_format_safe macro Jiri Olsa
2016-02-04 12:40   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 21/26] perf tools: Introduce perf_hpp_list__for_each_sort_list macro Jiri Olsa
2016-02-04 12:40   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 22/26] perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro Jiri Olsa
2016-02-04 12:40   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 23/26] perf tools: Add struct perf_hpp_list argument to helper functions Jiri Olsa
2016-02-04 12:41   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 24/26] perf tools: Add hpp_list into struct hists object Jiri Olsa
2016-02-04 12:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 25/26] perf tools: Introduce hists__for_each_format macro Jiri Olsa
2016-02-04 12:41   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-18  9:24 ` [PATCH 26/26] perf tools: Introduce hists__for_each_sort_list macro Jiri Olsa
2016-02-04 12:42   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-01-19 12:58 ` [RFC 00/26] perf tools: Introduce hists specific format entries Namhyung Kim
2016-01-19 13:23   ` Jiri Olsa
2016-01-25  7:15 ` Jiri Olsa
2016-01-25 14:24   ` Namhyung Kim
2016-01-25 14:37     ` Jiri Olsa
2016-02-02 22:22       ` Arnaldo Carvalho de Melo
2016-02-02 22:25         ` Arnaldo Carvalho de Melo
2016-02-02 22:42         ` Arnaldo Carvalho de Melo
2016-02-03  7:58           ` Jiri Olsa
2016-02-03 11:02             ` Jiri Olsa

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).