Skip to contentSkip to conversation

perf tools: Introduce hists specific format entries

RFC In review Jiri Olsa 5 participants 72 messages Jan 18, 2016 – Mar 11, 2016 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

cover perf tools: Introduce hists specific format entries

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(-)
author reviewer
#1 lore raw

PATCH 1/26 perf tools: Factor output_resort from hists__output_resort

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.

---
 tools/perf/util/hist.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
tools/perf/util/hist.c +15 -8
index c226303e3da0..83a6f2733cdc 100644
@@ -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)
 {
Signature · 1 line
2.4.3
#2 lore raw

[tip:perf/core] perf hists: Factor output_resort from hists__output_resort

perf hists: Factor output_resort from hists__output_resort
Commit-ID:  01441af5df438a171bce36bc3c7cfb588bc98a7a
Gitweb:     http://git.kernel.org/tip/01441af5df438a171bce36bc3c7cfb588bc98a7a
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:23:59 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/hist.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
tools/perf/util/hist.c +15 -8
index 098310b..7797d06 100644
@@ -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)
 {
author reviewer
#3 lore raw

PATCH 2/26 perf tools: Introduce perf_evsel__output_resort function

In reply to Jiri Olsa

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

---
 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(-)
tools/perf/builtin-annotate.c +1 -1
index cc5c1267c738..cfe366375c4b 100644
@@ -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))
tools/perf/builtin-report.c +1 -1
index 2bf537f190a0..2fe654dd8d2b 100644
@@ -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();
 }
tools/perf/builtin-top.c +6 -4
index bf01cbb0ef23..f1bbe2a589f5 100644
@@ -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)
tools/perf/tests/hists_cumulate.c +1 -1
index 5e6a86e50fb9..ecf136c385d5 100644
@@ -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",
tools/perf/tests/hists_filter.c +1 -1
index 351a42463444..34b945a55d4d 100644
@@ -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");
tools/perf/tests/hists_output.c +5 -5
index b231265148d8..23cce67c7e48 100644
@@ -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);
tools/perf/util/hist.c +7 -3
index 83a6f2733cdc..a94067c8f753 100644
@@ -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,
tools/perf/util/hist.h +1 -0
index d4ec4822a103..bc2499794bef 100644
@@ -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);
 
Signature · 1 line
2.4.3
#4 lore raw

[tip:perf/core] perf hists: Introduce perf_evsel__output_resort function

perf hists: Introduce perf_evsel__output_resort function
Commit-ID:  452ce03b1e686f0b2da6c1644dce7cdc71e3c69c
Gitweb:     http://git.kernel.org/tip/452ce03b1e686f0b2da6c1644dce7cdc71e3c69c
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:00 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/builtin-annotate.c +1 -1
index cc5c126..cfe3663 100644
@@ -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))
tools/perf/builtin-report.c +1 -1
index 72ed0b4..54ce047 100644
@@ -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();
 }
tools/perf/builtin-top.c +6 -4
index bf01cbb..f1bbe2a 100644
@@ -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)
tools/perf/tests/hists_cumulate.c +1 -1
index 5e6a86e..ecf136c 100644
@@ -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",
tools/perf/tests/hists_filter.c +1 -1
index 351a424..34b945a 100644
@@ -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");
tools/perf/tests/hists_output.c +5 -5
index b231265..23cce67 100644
@@ -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);
tools/perf/util/hist.c +7 -3
index 7797d06..d07955c 100644
@@ -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,
tools/perf/util/hist.h +1 -0
index d4ec482..bc24997 100644
@@ -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);
 
author reviewer
#5 lore raw

PATCH 3/26 perf tools: Add _idx fields into struct perf_hpp_fmt

In reply to Jiri Olsa

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.

---
 tools/perf/ui/hist.c   | 25 ++++++++++++++-----------
 tools/perf/util/hist.h |  1 +
 2 files changed, 15 insertions(+), 11 deletions(-)
tools/perf/ui/hist.c +14 -11
index bf2a66e254ea..d392801ea17e 100644
@@ -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);
tools/perf/util/hist.h +1 -0
index bc2499794bef..8a0cbdeb449e 100644
@@ -221,6 +221,7 @@ struct perf_hpp_fmt {
 	bool elide;
 	int len;
 	int user_len;
+	int idx;
 };
 
 extern struct list_head perf_hpp__list;
Signature · 1 line
2.4.3
#6 lore raw

[tip:perf/core] perf hists: Add _idx fields into struct perf_hpp_fmt

perf hists: Add _idx fields into struct perf_hpp_fmt
Commit-ID:  b21a763edd5f832c6d966d9e60376f3d21009859
Gitweb:     http://git.kernel.org/tip/b21a763edd5f832c6d966d9e60376f3d21009859
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:01 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   | 25 ++++++++++++++-----------
 tools/perf/util/hist.h |  1 +
 2 files changed, 15 insertions(+), 11 deletions(-)
tools/perf/ui/hist.c +14 -11
index bf2a66e..d392801 100644
@@ -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);
tools/perf/util/hist.h +1 -0
index bc24997..8a0cbde 100644
@@ -221,6 +221,7 @@ struct perf_hpp_fmt {
 	bool elide;
 	int len;
 	int user_len;
+	int idx;
 };
 
 extern struct list_head perf_hpp__list;
author reviewer
#7 lore raw

PATCH 4/26 perf tools: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width

In reply to Jiri Olsa

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.

---
 tools/perf/ui/hist.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
tools/perf/ui/hist.c +2 -10
index d392801ea17e..5a11bf0aabc7 100644
@@ -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:
Signature · 1 line
2.4.3
#8 lore raw

[tip:perf/core] perf hists: Use struct perf_hpp_fmt:: idx in perf_hpp__reset_width

perf hists: Use struct perf_hpp_fmt::idx in perf_hpp__reset_width
Commit-ID:  2e8b79e706f504801fbce19fa9f16f3c858a105e
Gitweb:     http://git.kernel.org/tip/2e8b79e706f504801fbce19fa9f16f3c858a105e
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:02 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
tools/perf/ui/hist.c +2 -10
index d392801..5a11bf0 100644
@@ -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:
author reviewer
#9 lore raw

PATCH 5/26 perf tools: Add equal method to perf_hpp_fmt struct

In reply to Jiri Olsa

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

---
 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(-)
tools/perf/ui/hist.c +7 -2
index 5a11bf0aabc7..71c8bb71a350 100644
@@ -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;
 			}
 		}
tools/perf/util/hist.h +1 -1
index 8a0cbdeb449e..9a240d7b8d3b 100644
@@ -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);
 
tools/perf/util/sort.c +20 -19
index ec722346e6ff..1b57ec9d7c2f 100644
@@ -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);
Signature · 1 line
2.4.3
#10 lore raw

[tip:perf/core] perf hists: Add 'equal' method to perf_hpp_fmt struct

perf hists: Add 'equal' method to perf_hpp_fmt struct
Commit-ID:  97358084b91e94e5f8fcf0379f0430c0ea16bd3b
Gitweb:     http://git.kernel.org/tip/97358084b91e94e5f8fcf0379f0430c0ea16bd3b
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:03 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/ui/hist.c +7 -2
index 5a11bf0..71c8bb7 100644
@@ -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;
 			}
 		}
tools/perf/util/hist.h +1 -1
index 8a0cbde..9a240d7 100644
@@ -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);
 
tools/perf/util/sort.c +20 -19
index 898e4b0..170f7f7 100644
@@ -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);
author reviewer
#11 lore raw

PATCH 6/26 perf tools: Add hpp__equal callback function

In reply to Jiri Olsa

Adding hpp__equal callback function to compare
hpp output format entries.

---
 tools/perf/ui/hist.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tools/perf/ui/hist.c +16 -0
index 71c8bb71a350..b543f4b7d7d3 100644
@@ -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[] = {
Signature · 1 line
2.4.3
#12 lore raw

[tip:perf/core] perf hists: Add 'hpp__equal' callback function

perf hists: Add 'hpp__equal' callback function
Commit-ID:  c0020efa079c5fc2388945ae7e856b362731442d
Gitweb:     http://git.kernel.org/tip/c0020efa079c5fc2388945ae7e856b362731442d
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:04 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tools/perf/ui/hist.c +16 -0
index 71c8bb7..b543f4b 100644
@@ -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[] = {
author reviewer
#13 lore raw

PATCH 7/26 perf tools: Make hpp setup function generic

In reply to Jiri Olsa

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

---
 tools/perf/ui/hist.c | 36 ++++++++----------------------------
 1 file changed, 8 insertions(+), 28 deletions(-)
tools/perf/ui/hist.c +8 -28
index b543f4b7d7d3..b0fcaecb7d1d 100644
@@ -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);
Signature · 1 line
2.4.3
#14 lore raw

[tip:perf/core] perf hists: Make hpp setup function generic

perf hists: Make hpp setup function generic
Commit-ID:  3f931f2c4274565fd6c6a642b16387358cbe6266
Gitweb:     http://git.kernel.org/tip/3f931f2c4274565fd6c6a642b16387358cbe6266
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:05 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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

---
 tools/perf/ui/hist.c | 36 ++++++++----------------------------
 1 file changed, 8 insertions(+), 28 deletions(-)
tools/perf/ui/hist.c +8 -28
index b543f4b..b0fcaec 100644
@@ -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);
author reviewer
#15 lore raw

PATCH 8/26 perf report: Move ui initialization ahead of sort setup

In reply to Jiri Olsa

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

---
 tools/perf/builtin-report.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
tools/perf/builtin-report.c +9 -9
index 2fe654dd8d2b..0aa0fd3b4aa7 100644
@@ -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);
Signature · 1 line
2.4.3
#16 lore raw

[tip:perf/core] perf report: Move UI initialization ahead of sort setup

perf report: Move UI initialization ahead of sort setup
Commit-ID:  9887804d01abf7a4e03cfd6be0312d0a5c4e4aba
Gitweb:     http://git.kernel.org/tip/9887804d01abf7a4e03cfd6be0312d0a5c4e4aba
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:06 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/builtin-report.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
tools/perf/builtin-report.c +9 -9
index 54ce047..1eab50a 100644
@@ -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);
#17 lore raw

[tip:perf/core] perf top: Move UI initialization ahead of sort setup

In reply to Jiri Olsa
perf top: Move UI initialization ahead of sort setup
Commit-ID:  3ee60c3b18bd4bf30ea9b70e7542116bb5c205ba
Gitweb:     http://git.kernel.org/tip/3ee60c3b18bd4bf30ea9b70e7542116bb5c205ba
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:06 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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'.

---
 tools/perf/builtin-top.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/builtin-top.c +7 -7
index f1bbe2a..a75de39 100644
@@ -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);
author reviewer
#18 lore raw

PATCH 9/26 perf tools: Allocate output sort field

In reply to Jiri Olsa

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.

---
 tools/perf/ui/hist.c   | 16 ++++++++++++++--
 tools/perf/util/sort.c | 41 +++++++++++++++++++++++++++++++++--------
 2 files changed, 47 insertions(+), 10 deletions(-)
tools/perf/ui/hist.c +14 -2
index b0fcaecb7d1d..c877c52ff4bc 100644
@@ -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)
tools/perf/util/sort.c +33 -8

61 lines not on this page · raw message

Signature · 1 line
2.4.3
#19 lore raw

[tip:perf/core] perf hists: Allocate output sort field

perf hists: Allocate output sort field
Commit-ID:  1945c3e734cd1f01535dc76de47c38bbe9a87352
Gitweb:     http://git.kernel.org/tip/1945c3e734cd1f01535dc76de47c38bbe9a87352
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:07 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   | 16 ++++++++++++++--
 tools/perf/util/sort.c | 41 +++++++++++++++++++++++++++++++++--------
 2 files changed, 47 insertions(+), 10 deletions(-)
tools/perf/ui/hist.c +14 -2
index b0fcaec..c877c52 100644
@@ -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)
tools/perf/util/sort.c +33 -8

61 lines not on this page · raw message

author reviewer
#20 lore raw

PATCH 10/26 perf tools: Remove perf_hpp__column_(disable|enable)

In reply to Jiri Olsa

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

---
 tools/perf/ui/hist.c   | 12 ------------
 tools/perf/util/hist.h |  2 --
 2 files changed, 14 deletions(-)
tools/perf/ui/hist.c +0 -12
index c877c52ff4bc..80d63a997287 100644
@@ -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;
tools/perf/util/hist.h +0 -2
index 9a240d7b8d3b..1f9e21dd53f3 100644
@@ -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);
Signature · 1 line
2.4.3
#21 lore raw

[tip:perf/core] perf hists: Remove perf_hpp__column_( disable|enable)

perf hists: Remove perf_hpp__column_(disable|enable)
Commit-ID:  12cb4397fb398545207acf772b219bd751786015
Gitweb:     http://git.kernel.org/tip/12cb4397fb398545207acf772b219bd751786015
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:08 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   | 12 ------------
 tools/perf/util/hist.h |  2 --
 2 files changed, 14 deletions(-)
tools/perf/ui/hist.c +0 -12
index c877c52..80d63a9 100644
@@ -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;
tools/perf/util/hist.h +0 -2
index 9a240d7..1f9e21dd 100644
@@ -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);
author reviewer
#22 lore raw

PATCH 11/26 perf tools: Properly release format fields

In reply to Jiri Olsa

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

---
 tools/perf/ui/hist.c   |  8 ++++++++
 tools/perf/util/hist.h |  1 +
 tools/perf/util/sort.c | 24 ++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
tools/perf/ui/hist.c +8 -0
index 80d63a997287..2cd1a03bf375 100644
@@ -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);
 	}
 }
 
tools/perf/util/hist.h +1 -0
index 1f9e21dd53f3..f3bcf2d38733 100644
@@ -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;
tools/perf/util/sort.c +24 -0
index a4ce4807fbb7..a7eed4485afc 100644
@@ -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);
Signature · 1 line
2.4.3
#23 lore raw

[tip:perf/core] perf hists: Properly release format fields

perf hists: Properly release format fields
Commit-ID:  564132f3116cf376fdc04b2380e621f35efbb6c7
Gitweb:     http://git.kernel.org/tip/564132f3116cf376fdc04b2380e621f35efbb6c7
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:09 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   |  8 ++++++++
 tools/perf/util/hist.h |  1 +
 tools/perf/util/sort.c | 24 ++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
tools/perf/ui/hist.c +8 -0
index 80d63a9..2cd1a03 100644
@@ -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);
 	}
 }
 
tools/perf/util/hist.h +1 -0
index 1f9e21dd..f3bcf2d 100644
@@ -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;
tools/perf/util/sort.c +24 -0
index 52e4a36..b5389a5 100644
@@ -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);
author reviewer
#24 lore raw

PATCH 12/26 perf tools: Separate sort fields parsing into setup_sort_list function

In reply to Jiri Olsa

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.

---
 tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
tools/perf/util/sort.c +22 -12
index a7eed4485afc..844c97f51198 100644
@@ -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;
Signature · 1 line
2.4.3
#25 lore raw

[tip:perf/core] perf hists: Separate sort fields parsing into setup_sort_list function

perf hists: Separate sort fields parsing into setup_sort_list function
Commit-ID:  2fbaa39079672bf52a9208ec1263385b48933cc3
Gitweb:     http://git.kernel.org/tip/2fbaa39079672bf52a9208ec1263385b48933cc3
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:10 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
tools/perf/util/sort.c +22 -12
index b5389a5..ab1c21a 100644
@@ -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;
author reviewer
#26 lore raw

PATCH 13/26 perf tools: Separate output fields parsing into setup_output_list function

In reply to Jiri Olsa

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.

---
 tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
tools/perf/util/sort.c +22 -12
index 844c97f51198..3461198217fc 100644
@@ -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);
Signature · 1 line
2.4.3
#27 lore raw

[tip:perf/core] perf hists: Separate output fields parsing into setup_output_list function

perf hists: Separate output fields parsing into setup_output_list function
Commit-ID:  6d3375efebe906ad0ce55ddaa883bf41fd8c444b
Gitweb:     http://git.kernel.org/tip/6d3375efebe906ad0ce55ddaa883bf41fd8c444b
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:11 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/sort.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
tools/perf/util/sort.c +22 -12
index ab1c21a..36dbd55 100644
@@ -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);
author reviewer
#28 lore raw

PATCH 14/26 perf tools: Introduce struct perf_hpp_list

In reply to Jiri Olsa

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.

---
 tools/perf/ui/hist.c   | 11 ++++++-----
 tools/perf/util/hist.h | 16 ++++++++++------
 2 files changed, 16 insertions(+), 11 deletions(-)
tools/perf/ui/hist.c +6 -5
index 2cd1a03bf375..1253a62c422f 100644
@@ -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)
tools/perf/util/hist.h +10 -6
index f3bcf2d38733..a9c8ccfcc284 100644
@@ -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[];
 
Signature · 1 line
2.4.3
maintainer
#29 lore raw

Re: [PATCH 14/26] perf tools: Introduce struct perf_hpp_list

Quoted 19 lines · Jiri Olsa

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.

---
 tools/perf/ui/hist.c   | 11 ++++++-----
 tools/perf/util/hist.h | 16 ++++++++++------
 2 files changed, 16 insertions(+), 11 deletions(-)
tools/perf/ui/hist.c +0 -0
index 2cd1a03bf375..1253a62c422f 100644

tools/perf/ui/hist.c struct perf_hpp_fmt perf_hpp__format[] = { · line 441

Quoted 9 lines
tools/perf/ui/hist.c +3 -3
@@ -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.

Quoted 27 lines
tools/perf/ui/hist.c +3 -2
+};
 
 #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)
tools/perf/util/hist.h +0 -0
index f3bcf2d38733..a9c8ccfcc284 100644

tools/perf/util/hist.h struct perf_hpp_fmt { · line 232

Quoted 9 lines
tools/perf/util/hist.h +4 -2
@@ -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

Quoted 24 lines
tools/perf/util/hist.h +6 -4
+
+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[];
 
Signature · 1 line
2.4.3
#30 lore raw

Re: [PATCH 14/26] perf tools: Introduce struct perf_hpp_list

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

SNIP

Quoted 18 lines
Quoted 6 lines

void perf_hpp__cancel_cumulate(void)

tools/perf/util/hist.h +0 -0
index f3bcf2d38733..a9c8ccfcc284 100644

tools/perf/util/hist.h struct perf_hpp_fmt { · line 232

Quoted 9 lines
tools/perf/util/hist.h +4 -2
@@ -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?

Quoted 6 lines
  struct perf_hpp_list {
    struct list_head fields;
    struct list_head sorts;
  };

This also aligns with the option names.

yep, sounds better ;-)

thanks,
jirka

#31 lore raw

Re: [PATCH 14/26] perf tools: Introduce struct perf_hpp_list

Em Mon, Jan 25, 2016 at 04:09:33PM +0100, Jiri Olsa escreveu:

Quoted 22 lines · Namhyung Kim

SNIP

Quoted 18 lines
Quoted 6 lines

void perf_hpp__cancel_cumulate(void)

tools/perf/util/hist.h +0 -0
index f3bcf2d38733..a9c8ccfcc284 100644

tools/perf/util/hist.h struct perf_hpp_fmt { · line 232

Quoted 9 lines
tools/perf/util/hist.h +4 -2
@@ -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?

Quoted 8 lines
Quoted 6 lines
  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

#32 lore raw

[tip:perf/core] perf hists: Introduce struct perf_hpp_list

In reply to Jiri Olsa
perf hists: Introduce struct perf_hpp_list
Commit-ID:  7c31e10266bd18de163d5c60899591c0540bb002
Gitweb:     http://git.kernel.org/tip/7c31e10266bd18de163d5c60899591c0540bb002
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:12 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

Cc David Ahern <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ Renamed fields to .{fields,sorts} as suggested by Namhyung and acked by Jiri ]
---
 tools/perf/ui/hist.c   | 11 ++++++-----
 tools/perf/util/hist.h | 16 ++++++++++------
 2 files changed, 16 insertions(+), 11 deletions(-)
tools/perf/ui/hist.c +6 -5
index 2cd1a03..74dbeac 100644
@@ -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)
tools/perf/util/hist.h +10 -6
index f3bcf2d..203397a 100644
@@ -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[];
 
author reviewer
#33 lore raw

PATCH 15/26 perf tools: Introduce perf_hpp_list__init function

In reply to Jiri Olsa

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

---
 tools/perf/util/hist.c | 6 ++++++
 tools/perf/util/hist.h | 2 ++
 2 files changed, 8 insertions(+)
tools/perf/util/hist.c +6 -0
index a94067c8f753..c80f01460e3b 100644
@@ -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);
+}
tools/perf/util/hist.h +2 -0
index a9c8ccfcc284..ea50a9cf2316 100644
@@ -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 */
Signature · 1 line
2.4.3
#34 lore raw

[tip:perf/core] perf hists: Introduce perf_hpp_list__init function

perf hists: Introduce perf_hpp_list__init function
Commit-ID:  94b3dc3865097e11073f1abf5b20b5f80af223af
Gitweb:     http://git.kernel.org/tip/94b3dc3865097e11073f1abf5b20b5f80af223af
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:13 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/hist.c | 6 ++++++
 tools/perf/util/hist.h | 2 ++
 2 files changed, 8 insertions(+)
tools/perf/util/hist.c +6 -0
index d07955c..b762ecc 100644
@@ -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);
+}
tools/perf/util/hist.h +2 -0
index 203397a..e22f98e 100644
@@ -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 */
author reviewer
#35 lore raw

PATCH 16/26 perf tools: Add perf_hpp_list register helpers

In reply to Jiri Olsa

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.

---
 tools/perf/ui/hist.c   | 14 ++++++++------
 tools/perf/util/hist.h | 18 +++++++++++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)
tools/perf/ui/hist.c +8 -6
index 1253a62c422f..7200349b44b9 100644
@@ -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)
tools/perf/util/hist.h +15 -3
index ea50a9cf2316..dfa11777efbe 100644
@@ -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);
Signature · 1 line
2.4.3
#36 lore raw

[tip:perf/core] perf hists: Add perf_hpp_list register helpers

perf hists: Add perf_hpp_list register helpers
Commit-ID:  ebdd98e030f5ed6dd1bae9ab01b084f97685bd60
Gitweb:     http://git.kernel.org/tip/ebdd98e030f5ed6dd1bae9ab01b084f97685bd60
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:14 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   | 14 ++++++++------
 tools/perf/util/hist.h | 18 +++++++++++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)
tools/perf/ui/hist.c +8 -6
index 74dbeac..1655c0d 100644
@@ -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)
tools/perf/util/hist.h +15 -3
index e22f98e..a7769d7 100644
@@ -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);
author reviewer
#37 lore raw

PATCH 17/26 perf tools: Pass perf_hpp_list all the way through setup_sort_list

In reply to Jiri Olsa

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

---
 tools/perf/util/sort.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +19 -15
index 3461198217fc..020b3244aec9 100644
@@ -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;
 	}
Signature · 1 line
2.4.3
#38 lore raw

PATCH v2 1/1 perf tools: Pass perf_hpp_list all the way through setup_sort_list

Quoted 3 lines · Jiri Olsa

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.

---
 tools/perf/util/sort.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +23 -15
index ab6eb7ca8c60..e4dc58e26845 100644
@@ -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;
 	}
Signature · 1 line
2.4.3
#39 lore raw

Re: [PATCHv2] perf tools: Pass perf_hpp_list all the way through setup_sort_list

Em Sun, Mar 06, 2016 at 08:21:52PM +0100, Jiri Olsa escreveu:

Quoted 27 lines · Jiri Olsa
Quoted 3 lines

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.

---
 tools/perf/util/sort.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +0 -0
index ab6eb7ca8c60..e4dc58e26845 100644

tools/perf/util/sort.c int hist_entry__filter(struct hist_entry *he, int type, const void *arg) · line 1619

Quoted 7 lines
tools/perf/util/sort.c +3 -1
@@ -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)

Quoted 12 lines
tools/perf/util/sort.c +1 -1
 {
 	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;
 }
 

tools/perf/util/sort.c out: · line 2126

Quoted 7 lines
tools/perf/util/sort.c +3 -1
@@ -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

Quoted 114 lines
tools/perf/util/sort.c +16 -12
 {
 	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;
 	}
Signature · 1 line
2.4.3
#40 lore raw

PATCH v3 1/1 perf tools: Pass perf_hpp_list all the way through setup_sort_list

Quoted 39 lines · Arnaldo Carvalho de Melo

Em Sun, Mar 06, 2016 at 08:21:52PM +0100, Jiri Olsa escreveu:

Quoted 27 lines · Jiri Olsa
Quoted 3 lines

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.

---
 tools/perf/util/sort.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +0 -0
index ab6eb7ca8c60..e4dc58e26845 100644

tools/perf/util/sort.c int hist_entry__filter(struct hist_entry *he, int type, const void *arg) · line 1619

Quoted 7 lines
tools/perf/util/sort.c +3 -1
@@ -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:

Quoted 3 lines

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.

---
 tools/perf/util/sort.c | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)
tools/perf/util/sort.c +26 -18
index 041f236379e0..59a101e43457 100644
@@ -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;
 	}
Signature · 1 line
2.4.3
maintainer Acked-by on v3 1/1
#41 lore raw

Re: [PATCHv3] perf tools: Pass perf_hpp_list all the way through setup_sort_list

Quoted 26 lines · Jiri Olsa
Quoted 15 lines · Arnaldo Carvalho de Melo

Em Sun, Mar 06, 2016 at 08:21:52PM +0100, Jiri Olsa escreveu:

tools/perf/util/sort.c int hist_entry__filter(struct hist_entry *he, int type, const void *arg) · line 1619

Quoted 10 lines
tools/perf/util/sort.c +3 -1
@@ -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:

Quoted 3 lines

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

right, v3 attached

thanks,
jirka

Quoted 6 lines

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

Thanks,
Namhyung

Quoted 166 lines
---
 tools/perf/util/sort.c | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)
tools/perf/util/sort.c +26 -18
index 041f236379e0..59a101e43457 100644
@@ -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;
 	}
Signature · 1 line
2.4.3
maintainer Applied
#42 lore raw

Re: [PATCHv3] perf tools: Pass perf_hpp_list all the way through setup_sort_list

Em Wed, Mar 09, 2016 at 09:47:51PM +0900, Namhyung Kim escreveu:

Quoted 5 lines · Jiri Olsa
Quoted 2 lines

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

Thanks, applied,

- Arnaldo

#43 lore raw

[tip:perf/core] perf tools: Pass perf_hpp_list all the way through setup_sort_list

In reply to Jiri Olsa
perf tools: Pass perf_hpp_list all the way through setup_sort_list
Commit-ID:  d7b617f51be4fffa3cbb5adf6d4258e616dce294
Gitweb:     http://git.kernel.org/tip/d7b617f51be4fffa3cbb5adf6d4258e616dce294
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 9 Mar 2016 11:04:17 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/sort.c | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)
tools/perf/util/sort.c +26 -18
index 041f236..59a101e 100644
@@ -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;
 	}
author reviewer
#44 lore raw

PATCH 18/26 perf tools: Pass perf_hpp_list all the way through setup_output_list

In reply to Jiri Olsa

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

---
 tools/perf/util/sort.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +18 -15
index 020b3244aec9..3daa7e6ced23 100644
@@ -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);
Signature · 1 line
2.4.3
#45 lore raw

[tip:perf/core] perf hists: Pass perf_hpp_list all the way through setup_output_list

perf hists: Pass perf_hpp_list all the way through setup_output_list
Commit-ID:  07600027fb7114bf7bcabdd121e5178f200d8a44
Gitweb:     http://git.kernel.org/tip/07600027fb7114bf7bcabdd121e5178f200d8a44
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:16 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/sort.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
tools/perf/util/sort.c +18 -15
index 36dbd55..f643bed 100644
@@ -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);
author reviewer
#46 lore raw

PATCH 19/26 perf tools: Introduce perf_hpp_list__for_each_format macro

In reply to Jiri Olsa

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

---
 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(-)
tools/perf/ui/browsers/hists.c +4 -4
index 08c09ad755d2..4416540f2bba 100644
@@ -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
tools/perf/ui/gtk/hists.c +3 -3
index 0f8dcfdfb10f..eca5151f91d7 100644
@@ -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;
 
tools/perf/ui/hist.c +4 -4
index 7200349b44b9..dd0bb4a00d00 100644
@@ -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);
tools/perf/ui/stdio/hist.c +5 -5
index 387110d50b00..f40b05e109cd 100644
@@ -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))
tools/perf/util/hist.h +2 -2
index dfa11777efbe..31add4d1d860 100644
@@ -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)
tools/perf/util/sort.c +4 -4
index 3daa7e6ced23..0194dd145401 100644
@@ -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;
 
Signature · 1 line
2.4.3
#47 lore raw

[tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_format macro

perf hists: Introduce perf_hpp_list__for_each_format macro
Commit-ID:  cf094045d718437e3d5cd42ac09d77561cb2f368
Gitweb:     http://git.kernel.org/tip/cf094045d718437e3d5cd42ac09d77561cb2f368
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:17 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/ui/browsers/hists.c +4 -4
index 61d578b..df0aedf 100644
@@ -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
tools/perf/ui/gtk/hists.c +3 -3
index 0f8dcfd..eca5151 100644
@@ -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;
 
tools/perf/ui/hist.c +4 -4
index 1655c0d..7b5e8ce 100644
@@ -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);
tools/perf/ui/stdio/hist.c +4 -4
index 691e52c..83e0bf2 100644
@@ -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))
tools/perf/util/hist.h +2 -2
index a7769d7..eadffca 100644
@@ -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)
tools/perf/util/sort.c +4 -4
index f643bed..1e134ff 100644
@@ -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;
 
author reviewer
#48 lore raw

PATCH 20/26 perf tools: Introduce perf_hpp_list__for_each_format_safe macro

In reply to Jiri Olsa

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

---
 tools/perf/ui/hist.c   | 4 ++--
 tools/perf/util/hist.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/ui/hist.c +2 -2
index dd0bb4a00d00..4fbb2f43ba3a 100644
@@ -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);
tools/perf/util/hist.h +2 -2
index 31add4d1d860..ac0cfb68018c 100644
@@ -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)
Signature · 1 line
2.4.3
#49 lore raw

[tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_format_safe macro

perf hists: Introduce perf_hpp_list__for_each_format_safe macro
Commit-ID:  7a1799e0a276069d8b903ba17179b4983b98c04b
Gitweb:     http://git.kernel.org/tip/7a1799e0a276069d8b903ba17179b4983b98c04b
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:18 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   | 4 ++--
 tools/perf/util/hist.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/ui/hist.c +2 -2
index 7b5e8ce..348706a 100644
@@ -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);
tools/perf/util/hist.h +2 -2
index eadffca..f5b2309 100644
@@ -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)
author reviewer
#50 lore raw

PATCH 21/26 perf tools: Introduce perf_hpp_list__for_each_sort_list macro

In reply to Jiri Olsa

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

---
 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(-)
tools/perf/ui/hist.c +2 -2
index 4fbb2f43ba3a..c8d74b357d5e 100644
@@ -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;
 		}
tools/perf/util/hist.c +3 -3
index c80f01460e3b..3ba70b7868d5 100644
@@ -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;
 
tools/perf/util/hist.h +2 -2
index ac0cfb68018c..130f825235a3 100644
@@ -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)
Signature · 1 line
2.4.3
#51 lore raw

[tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_sort_list macro

perf hists: Introduce perf_hpp_list__for_each_sort_list macro
Commit-ID:  d29a497090845002ee449c8dc682dd59ad8bab42
Gitweb:     http://git.kernel.org/tip/d29a497090845002ee449c8dc682dd59ad8bab42
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:19 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/ui/hist.c +2 -2
index 348706a..f09eabe 100644
@@ -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;
 		}
tools/perf/util/hist.c +3 -3
index b762ecc..dea475d 100644
@@ -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;
 
tools/perf/util/hist.h +2 -2
index f5b2309..c9b2ea4 100644
@@ -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)
author reviewer
#52 lore raw

PATCH 22/26 perf tools: Introduce perf_hpp_list__for_each_sort_list_safe macro

In reply to Jiri Olsa

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

---
 tools/perf/ui/hist.c   | 2 +-
 tools/perf/util/hist.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/ui/hist.c +1 -1
index c8d74b357d5e..35b28caf4a76 100644
@@ -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);
tools/perf/util/hist.h +2 -2
index 130f825235a3..c9bd23537c1d 100644
@@ -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[];
 
Signature · 1 line
2.4.3
#53 lore raw

[tip:perf/core] perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro

perf hists: Introduce perf_hpp_list__for_each_sort_list_safe macro
Commit-ID:  1a8ebd243a0b65c2a6d1458705d04dece937ab52
Gitweb:     http://git.kernel.org/tip/1a8ebd243a0b65c2a6d1458705d04dece937ab52
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:20 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/ui/hist.c   | 2 +-
 tools/perf/util/hist.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/ui/hist.c +1 -1
index f09eabe..9cda51e 100644
@@ -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);
tools/perf/util/hist.h +2 -2
index c9b2ea4..61d35a9 100644
@@ -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[];
 
author reviewer
#54 lore raw

PATCH 23/26 perf tools: Add struct perf_hpp_list argument to helper functions

In reply to Jiri Olsa

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.

---
 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(-)
tools/perf/ui/hist.c +10 -9
index 35b28caf4a76..e904ed7b4e8a 100644
@@ -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);
tools/perf/util/hist.h +4 -3
index c9bd23537c1d..01c321e07cb3 100644
@@ -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);
tools/perf/util/sort.c +3 -3
index 0194dd145401..b4f9841392fa 100644
@@ -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);
 }
Signature · 1 line
2.4.3
#55 lore raw

[tip:perf/core] perf hists: Add struct perf_hpp_list argument to helper functions

perf hists: Add struct perf_hpp_list argument to helper functions
Commit-ID:  43e0a68f13047750a3728c983a539c61fb4121c5
Gitweb:     http://git.kernel.org/tip/43e0a68f13047750a3728c983a539c61fb4121c5
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:21 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/ui/hist.c +10 -9
index 9cda51e..8075d4c 100644
@@ -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);
tools/perf/util/hist.h +4 -3
index 61d35a9..a39c9c1 100644
@@ -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);
tools/perf/util/sort.c +3 -3
index 1e134ff..de620f7 100644
@@ -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);
 }
author reviewer
#56 lore raw

PATCH 24/26 perf tools: Add hpp_list into struct hists object

In reply to Jiri Olsa

Adding hpp_list into struct hists object.

Initializing struct hists_evsel hists object
to carry global perf_hpp_list list.

---
 tools/perf/util/hist.c | 5 +++--
 tools/perf/util/hist.h | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
tools/perf/util/hist.c +3 -2
index 3ba70b7868d5..7ac32bdf53ee 100644
@@ -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;
 }
 
tools/perf/util/hist.h +2 -1
index 01c321e07cb3..32599fc7b39f 100644
@@ -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,
Signature · 1 line
2.4.3
#57 lore raw

[tip:perf/core] perf tools: Add hpp_list into struct hists object

perf tools: Add hpp_list into struct hists object
Commit-ID:  5b65855e20348a9e2772a1cb7c1e6ab477859ba6
Gitweb:     http://git.kernel.org/tip/5b65855e20348a9e2772a1cb7c1e6ab477859ba6
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:22 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/hist.c | 5 +++--
 tools/perf/util/hist.h | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
tools/perf/util/hist.c +3 -2
index dea475d..2b9cc91 100644
@@ -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;
 }
 
tools/perf/util/hist.h +2 -1
index a39c9c1..b296ff5 100644
@@ -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,
author reviewer
#58 lore raw

PATCH 25/26 perf tools: Introduce hists__for_each_format macro

In reply to Jiri Olsa

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.

---
 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(-)
tools/perf/ui/browsers/hists.c +4 -4
index 4416540f2bba..d96afb006206 100644
@@ -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
tools/perf/ui/gtk/hists.c +3 -3
index eca5151f91d7..32cc38a5b57f 100644
@@ -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;
 
tools/perf/ui/hist.c +1 -1
index e904ed7b4e8a..b92e567372dd 100644
@@ -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;
 
tools/perf/ui/stdio/hist.c +5 -5
index f40b05e109cd..89778a9d7ae6 100644
@@ -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))
tools/perf/util/hist.h +3 -0
index 32599fc7b39f..e67542b8c126 100644
@@ -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 {
Signature · 1 line
2.4.3
#59 lore raw

[tip:perf/core] perf hists: Introduce hists__for_each_format macro

perf hists: Introduce hists__for_each_format macro
Commit-ID:  f0786af536bb0ba54cb516eee493af03cefdbaa3
Gitweb:     http://git.kernel.org/tip/f0786af536bb0ba54cb516eee493af03cefdbaa3
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:23 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 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(-)
tools/perf/ui/browsers/hists.c +4 -4
index df0aedf..3a1e096 100644
@@ -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
tools/perf/ui/gtk/hists.c +3 -3
index eca5151..32cc38a 100644
@@ -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;
 
tools/perf/ui/hist.c +1 -1
index 8075d4c..1ba4117 100644
@@ -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;
 
tools/perf/ui/stdio/hist.c +4 -4
index 83e0bf2..1a6e8f7 100644
@@ -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))
tools/perf/util/hist.h +3 -0
index b296ff5..bc90044 100644
@@ -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 {
author reviewer
#60 lore raw

PATCH 26/26 perf tools: Introduce hists__for_each_sort_list macro

In reply to Jiri Olsa

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.

---
 tools/perf/util/hist.c | 9 ++++++---
 tools/perf/util/hist.h | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)
tools/perf/util/hist.c +6 -3
index 7ac32bdf53ee..6c058d7739cc 100644
@@ -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;
 
tools/perf/util/hist.h +3 -0
index e67542b8c126..3fa24b55ebf3 100644
@@ -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 {
Signature · 1 line
2.4.3
#61 lore raw

[tip:perf/core] perf hists: Introduce hists__for_each_sort_list macro

perf hists: Introduce hists__for_each_sort_list macro
Commit-ID:  aa6f50af822a552b579252ecd42224e09e11e879
Gitweb:     http://git.kernel.org/tip/aa6f50af822a552b579252ecd42224e09e11e879
Author:     Jiri Olsa <[email protected]>
AuthorDate: Mon, 18 Jan 2016 10:24:24 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/util/hist.c | 9 ++++++---
 tools/perf/util/hist.h | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)
tools/perf/util/hist.c +6 -3
index 2b9cc91..12f2d79 100644
@@ -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;
 
tools/perf/util/hist.h +3 -0
index bc90044..1c7544a 100644
@@ -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 {
maintainer
#62 lore raw
In reply to Jiri Olsa
Quoted 8 lines · Jiri Olsa

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?

Quoted 52 lines

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(-)
#63 lore raw
Quoted 7 lines · Namhyung Kim
Quoted 6 lines · Jiri Olsa

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.

Quoted 6 lines
Quoted 2 lines

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

#64 lore raw
In reply to Jiri Olsa
Quoted 6 lines · Jiri Olsa

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.

Quoted 8 lines

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

maintainer
#65 lore raw

Hi Jiri,

Quoted 9 lines · Jiri Olsa
Quoted 8 lines · Jiri Olsa

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

#66 lore raw
Quoted 10 lines · Namhyung Kim

Hi Jiri,

Quoted 7 lines · Jiri Olsa
Quoted 6 lines · Jiri Olsa

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.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

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

#67 lore raw

Em Mon, Jan 25, 2016 at 03:37:43PM +0100, Jiri Olsa escreveu:

Quoted 20 lines · Namhyung Kim
Quoted 10 lines

Hi Jiri,

Quoted 7 lines · Jiri Olsa
Quoted 6 lines · Jiri Olsa

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.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

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.

Quoted 5 lines

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

#68 lore raw

Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

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 <[email protected]>
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.

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

#69 lore raw
In reply to Arnaldo Carvalho de Melo

Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

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

#70 lore raw
Quoted 15 lines · Arnaldo Carvalho de Melo

Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

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.

Quoted 5 lines

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

#71 lore raw
Quoted 16 lines · Jiri Olsa
Quoted 15 lines · Arnaldo Carvalho de Melo

Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 8 lines

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.

Quoted 7 lines
Quoted 5 lines

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