linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: rostedt@goodmis.org, acme@redhat.com, jolsa@kernel.org,
	peterz@infradead.org, tglx@linutronix.de, wangnan0@huawei.com,
	namhyung@kernel.org, dsahern@gmail.com, hpa@zytor.com,
	andi@firstfloor.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org, fweisbec@gmail.com
Subject: [tip:perf/core] perf tools: Pass evlist to setup_sorting()
Date: Sat, 9 Jan 2016 08:23:27 -0800	[thread overview]
Message-ID: <tip-40184c46a3055a97e2efa69da6f17c05bff4b776@git.kernel.org> (raw)
In-Reply-To: <1450804030-29193-5-git-send-email-namhyung@kernel.org>

Commit-ID:  40184c46a3055a97e2efa69da6f17c05bff4b776
Gitweb:     http://git.kernel.org/tip/40184c46a3055a97e2efa69da6f17c05bff4b776
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 23 Dec 2015 02:07:01 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:11 -0300

perf tools: Pass evlist to setup_sorting()

This is a preparation to support dynamic sort keys for tracepoint
events.  Dynamic sort keys can be created for specific fields in trace
events so it needs the event information.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1450804030-29193-5-git-send-email-namhyung@kernel.org
[ Moving the evlist creation earlier in top was split to a previous patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-annotate.c     |  2 +-
 tools/perf/builtin-diff.c         |  2 +-
 tools/perf/builtin-report.c       |  2 +-
 tools/perf/builtin-top.c          |  2 +-
 tools/perf/tests/hists_cumulate.c |  8 ++++----
 tools/perf/tests/hists_filter.c   |  2 +-
 tools/perf/tests/hists_link.c     |  2 +-
 tools/perf/tests/hists_output.c   | 10 +++++-----
 tools/perf/util/sort.c            | 15 +++++++++------
 tools/perf/util/sort.h            |  5 +++--
 10 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index b5b8db0..cc5c126 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (ret < 0)
 		goto out_delete;
 
-	if (setup_sorting() < 0)
+	if (setup_sorting(NULL) < 0)
 		usage_with_options(annotate_usage, options);
 
 	if (annotate.use_stdio)
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 69f5b1fe..8706383 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	sort__mode = SORT_MODE__DIFF;
 
-	if (setup_sorting() < 0)
+	if (setup_sorting(NULL) < 0)
 		usage_with_options(diff_usage, options);
 
 	setup_pager();
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 2a7330b..ea53c81 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -897,7 +897,7 @@ repeat:
 		symbol_conf.cumulate_callchain = false;
 	}
 
-	if (setup_sorting() < 0) {
+	if (setup_sorting(session->evlist) < 0) {
 		if (sort_order)
 			parse_options_usage(report_usage, options, "s", 1);
 		if (field_order)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 4e913d8..0058259 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1241,7 +1241,7 @@ 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 (setup_sorting() < 0) {
+	if (setup_sorting(top.evlist) < 0) {
 		if (sort_order)
 			parse_options_usage(top_usage, options, "s", 1);
 		if (field_order)
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index 8292948..e360892 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
 	symbol_conf.cumulate_callchain = false;
 	perf_evsel__reset_sample_bit(evsel, CALLCHAIN);
 
-	setup_sorting();
+	setup_sorting(NULL);
 	callchain_register_param(&callchain_param);
 
 	err = add_hist_entries(hists, machine);
@@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
 	symbol_conf.cumulate_callchain = false;
 	perf_evsel__set_sample_bit(evsel, CALLCHAIN);
 
-	setup_sorting();
+	setup_sorting(NULL);
 	callchain_register_param(&callchain_param);
 
 	err = add_hist_entries(hists, machine);
@@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
 	symbol_conf.cumulate_callchain = true;
 	perf_evsel__reset_sample_bit(evsel, CALLCHAIN);
 
-	setup_sorting();
+	setup_sorting(NULL);
 	callchain_register_param(&callchain_param);
 
 	err = add_hist_entries(hists, machine);
@@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
 	symbol_conf.cumulate_callchain = true;
 	perf_evsel__set_sample_bit(evsel, CALLCHAIN);
 
-	setup_sorting();
+	setup_sorting(NULL);
 	callchain_register_param(&callchain_param);
 
 	err = add_hist_entries(hists, machine);
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index ccb5b49..2a784be 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -122,7 +122,7 @@ int test__hists_filter(int subtest __maybe_unused)
 		goto out;
 
 	/* default sort order (comm,dso,sym) will be used */
-	if (setup_sorting() < 0)
+	if (setup_sorting(NULL) < 0)
 		goto out;
 
 	machines__init(&machines);
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 9eac98d..c764d69 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -294,7 +294,7 @@ int test__hists_link(int subtest __maybe_unused)
 		goto out;
 
 	/* default sort order (comm,dso,sym) will be used */
-	if (setup_sorting() < 0)
+	if (setup_sorting(NULL) < 0)
 		goto out;
 
 	machines__init(&machines);
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index 248beec..ebe6cd4 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -134,7 +134,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
 	field_order = NULL;
 	sort_order = NULL; /* equivalent to sort_order = "comm,dso,sym" */
 
-	setup_sorting();
+	setup_sorting(NULL);
 
 	/*
 	 * expected output:
@@ -236,7 +236,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
 	field_order = "overhead,cpu";
 	sort_order = "pid";
 
-	setup_sorting();
+	setup_sorting(NULL);
 
 	/*
 	 * expected output:
@@ -292,7 +292,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
 	field_order = "comm,overhead,dso";
 	sort_order = NULL;
 
-	setup_sorting();
+	setup_sorting(NULL);
 
 	/*
 	 * expected output:
@@ -366,7 +366,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
 	field_order = "dso,sym,comm,overhead,dso";
 	sort_order = "sym";
 
-	setup_sorting();
+	setup_sorting(NULL);
 
 	/*
 	 * expected output:
@@ -468,7 +468,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine)
 	field_order = "cpu,pid,comm,dso,sym";
 	sort_order = "dso,pid";
 
-	setup_sorting();
+	setup_sorting(NULL);
 
 	/*
 	 * expected output:
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 2d8ccd4..0c038a2 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -4,6 +4,8 @@
 #include "comm.h"
 #include "symbol.h"
 #include "evsel.h"
+#include "evlist.h"
+#include <traceevent/event-parse.h>
 
 regex_t		parent_regex;
 const char	default_parent_pattern[] = "^sys_|^do_page_fault";
@@ -1583,7 +1585,8 @@ int hpp_dimension__add_output(unsigned col)
 	return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
 }
 
-int sort_dimension__add(const char *tok)
+static int sort_dimension__add(const char *tok,
+			       struct perf_evlist *evlist __maybe_unused)
 {
 	unsigned int i;
 
@@ -1712,7 +1715,7 @@ static int setup_sort_order(void)
 	return 0;
 }
 
-static int __setup_sorting(void)
+static int __setup_sorting(struct perf_evlist *evlist)
 {
 	char *tmp, *tok, *str;
 	const char *sort_keys;
@@ -1743,7 +1746,7 @@ static int __setup_sorting(void)
 
 	for (tok = strtok_r(str, ", ", &tmp);
 			tok; tok = strtok_r(NULL, ", ", &tmp)) {
-		ret = sort_dimension__add(tok);
+		ret = sort_dimension__add(tok, evlist);
 		if (ret == -EINVAL) {
 			error("Invalid --sort key: `%s'", tok);
 			break;
@@ -1954,16 +1957,16 @@ out:
 	return ret;
 }
 
-int setup_sorting(void)
+int setup_sorting(struct perf_evlist *evlist)
 {
 	int err;
 
-	err = __setup_sorting();
+	err = __setup_sorting(evlist);
 	if (err < 0)
 		return err;
 
 	if (parent_pattern != default_parent_pattern) {
-		err = sort_dimension__add("parent");
+		err = sort_dimension__add("parent", evlist);
 		if (err < 0)
 			return err;
 	}
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index d298987..1a00f1e 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -226,10 +226,11 @@ struct sort_entry {
 extern struct sort_entry sort_thread;
 extern struct list_head hist_entry__sort_list;
 
-int setup_sorting(void);
+struct perf_evlist;
+struct pevent;
+int setup_sorting(struct perf_evlist *evlist);
 int setup_output_field(void);
 void reset_output_field(void);
-extern int sort_dimension__add(const char *);
 void sort__setup_elide(FILE *fp);
 void perf_hpp__set_elide(int idx, bool elide);
 

  parent reply	other threads:[~2016-01-09 16:24 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 17:06 [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v4) Namhyung Kim
2015-12-22 17:06 ` [PATCH 01/13] perf hist: Pass struct sample to __hists__add_entry() Namhyung Kim
2016-01-09 16:22   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:06 ` [PATCH 02/13] perf hist: Save raw_data/size for tracepoint events Namhyung Kim
2015-12-23 21:43   ` Arnaldo Carvalho de Melo
2015-12-24  0:45     ` Namhyung Kim
2015-12-24  1:19       ` Arnaldo Carvalho de Melo
2015-12-24  1:05     ` [PATCH v4.1 " Namhyung Kim
2015-12-24  1:39       ` Arnaldo Carvalho de Melo
2015-12-24  2:16         ` [PATCH v4.2 " Namhyung Kim
2016-01-09 16:22           ` [tip:perf/core] perf hist: Save raw_data/ size " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 03/13] tools lib traceevent: Factor out and export print_event_field[s] Namhyung Kim
2015-12-23  8:50   ` Wangnan (F)
2015-12-23 13:08   ` [PATCH v4.1 " Namhyung Kim
2016-01-04 15:31     ` Steven Rostedt
2016-01-04 18:34       ` Arnaldo Carvalho de Melo
2016-01-09 16:22     ` [tip:perf/core] tools lib traceevent: Factor out and export print_event_field[s]() tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 04/13] perf tools: Pass evlist to setup_sorting() Namhyung Kim
2016-01-09 16:23   ` [tip:perf/core] perf top: Create the evlist sooner tip-bot for Namhyung Kim
2016-01-09 16:23   ` tip-bot for Namhyung Kim [this message]
2015-12-22 17:07 ` [PATCH 05/13] perf tools: Add dynamic sort key for tracepoint events Namhyung Kim
2016-01-04 15:04   ` Arnaldo Carvalho de Melo
2016-01-09 16:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 06/13] perf tools: Try to show pretty printed output for dynamic sort keys Namhyung Kim
2016-01-04 15:16   ` Arnaldo Carvalho de Melo
2016-01-09 16:24   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 07/13] perf tools: Add 'trace' sort key Namhyung Kim
2016-01-09 16:24   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 08/13] perf tools: Add --raw-trace option Namhyung Kim
2016-01-09 16:24   ` [tip:perf/core] perf report/top: " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 09/13] perf tools: Support shortcuts for events in dynamic sort keys Namhyung Kim
2016-01-09 16:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 10/13] perf tools: Support '<event>.*' dynamic sort key Namhyung Kim
2016-01-09 16:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 11/13] perf tools: Skip dynamic fields not defined for current event Namhyung Kim
2016-01-09 16:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 12/13] perf tools: Add 'trace_fields' dynamic sort key Namhyung Kim
2016-01-05 10:58   ` [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name Namhyung Kim
2016-01-05 14:20       ` Jiri Olsa
2016-01-09 16:28       ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 3/5] perf tools: Add document for dynamic sort keys Namhyung Kim
2016-01-09 16:28       ` [tip:perf/core] perf report: Add documentation " tip-bot for Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields Namhyung Kim
2016-01-05 22:16       ` Arnaldo Carvalho de Melo
2016-01-05 23:57         ` Namhyung Kim
2016-01-05 10:58     ` [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields Namhyung Kim
2016-01-05 22:23       ` Arnaldo Carvalho de Melo
2016-01-06  0:00         ` Namhyung Kim
2016-01-06  1:52           ` Arnaldo Carvalho de Melo
2016-01-05 21:50     ` [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields Arnaldo Carvalho de Melo
2016-01-05 23:39       ` Namhyung Kim
2016-01-09 16:26     ` [tip:perf/core] perf tools: Add 'trace_fields' dynamic sort key tip-bot for Namhyung Kim
2015-12-22 17:07 ` [PATCH 13/13] perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events Namhyung Kim
2016-01-09 16:26   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-12-23  8:46 ` [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v4) Jiri Olsa
2015-12-23 13:10   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-40184c46a3055a97e2efa69da6f17c05bff4b776@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).