Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301422 > unrolled thread

[PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields

Started byNamhyung Kim <namhyung@kernel.org>
First post2016-01-05 12:00 +0100
Last post2016-01-09 17:30 +0100
Articles 16 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields Namhyung Kim <namhyung@kernel.org> - 2016-01-05 12:00 +0100
    [PATCH v2 3/5] perf tools: Add document for dynamic sort keys Namhyung Kim <namhyung@kernel.org> - 2016-01-05 12:00 +0100
      [tip:perf/core] perf report:   Add documentation for dynamic sort keys tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-01-09 17:30 +0100
    [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name Namhyung Kim <namhyung@kernel.org> - 2016-01-05 12:00 +0100
      Re: [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys  for field name Jiri Olsa <jolsa@redhat.com> - 2016-01-05 15:30 +0100
      [tip:perf/core] perf tools:   Add all matching dynamic sort keys for field name tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-01-09 17:40 +0100
    [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields Namhyung Kim <namhyung@kernel.org> - 2016-01-05 12:10 +0100
      Re: [PATCH v2 4/5] perf tools: Support dynamic sort keys for  -F/--fields Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-05 23:20 +0100
        Re: [PATCH v2 4/5] perf tools: Support dynamic sort keys for  -F/--fields Namhyung Kim <namhyung@kernel.org> - 2016-01-06 01:00 +0100
    [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields Namhyung Kim <namhyung@kernel.org> - 2016-01-05 12:10 +0100
      Re: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace  fields Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-05 23:30 +0100
        Re: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace  fields Namhyung Kim <namhyung@kernel.org> - 2016-01-06 01:10 +0100
          Re: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace  fields Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-06 03:00 +0100
    Re: [PATCH v2 1/5] perf tools: Fix segfault when using -s  trace_fields Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-05 23:00 +0100
      Re: [PATCH v2 1/5] perf tools: Fix segfault when using -s  trace_fields Namhyung Kim <namhyung@kernel.org> - 2016-01-06 00:40 +0100
    [tip:perf/core] perf tools: Add 'trace_fields' dynamic sort key tip-bot for Namhyung Kim <tipbot@zytor.com> - 2016-01-09 17:30 +0100

#1301422 — [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-05 12:00 +0100
Subject[PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields
Message-ID<qNxvk-Wb-9@gated-at.bofh.it>
When the 'trace_fields' sort key is used explicitly for non-tracepoint
events, it'll get segfault since it assumed evsel->tp_format was set.
Skip those events in add_all_dynamic_fields().

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/sort.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index e558e87cafaf..59c4c8586d79 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1955,6 +1955,9 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
 	struct perf_evsel *evsel;
 
 	evlist__for_each(evlist, evsel) {
+		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
+			continue;
+
 		ret = add_evsel_fields(evsel, raw_trace);
 		if (ret < 0)
 			return ret;
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1301425 — [PATCH v2 3/5] perf tools: Add document for dynamic sort keys

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-05 12:00 +0100
Subject[PATCH v2 3/5] perf tools: Add document for dynamic sort keys
Message-ID<qNxvl-Wb-23@gated-at.bofh.it>
In reply to#1301422
Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-report.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index ae7cd91727f6..8a301f6afb37 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -117,6 +117,30 @@ OPTIONS
 	And default sort keys are changed to comm, dso_from, symbol_from, dso_to
 	and symbol_to, see '--branch-stack'.
 
+	If the data file has tracepoint event(s), following (dynamic) sort keys
+	are also available:
+	trace, trace_fields, [<event>.]<field>[/raw]
+
+	- trace: pretty printed trace output in a single column
+	- trace_fields: fields in tracepoints in separate columns
+	- <field name>: optional event and field name for a specific field
+
+	The last form consists of event and field names.  If event name is
+	omitted, it searches all events for matching field name.  The matched
+	field will be shown only for the event has the field.  The event name
+	supports substring match so user doesn't need to specify full subsystem
+	and event name everytime.  For example, 'sched:sched_switch' event can
+	be shortened to 'switch' as long as it's not ambiguous.  Also event can
+	be specified by its index (starting from 1) preceded by the '%'.
+	So '%1' is the first event, '%2' is the second, and so on.
+
+	The field name can have '/raw' suffix which disables pretty printing
+	and shows raw field value like hex numbers.  The --raw-trace option
+	has the same effect for all dynamic sort keys.
+
+	The default sort keys are changed to 'trace' if all events in the data
+	file are tracepoint.
+
 -F::
 --fields=::
 	Specify output field - multiple keys can be specified in CSV format.
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1305276 — [tip:perf/core] perf report: Add documentation for dynamic sort keys

Fromtip-bot for Namhyung Kim <tipbot@zytor.com>
Date2016-01-09 17:30 +0100
Subject[tip:perf/core] perf report: Add documentation for dynamic sort keys
Message-ID<qP4yU-83p-49@gated-at.bofh.it>
In reply to#1301425
Commit-ID:  4c96bee03247c6eab27287fa66457a231b9fab79
Gitweb:     http://git.kernel.org/tip/4c96bee03247c6eab27287fa66457a231b9fab79
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Tue, 5 Jan 2016 19:58:36 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:14 -0300

perf report: Add documentation for dynamic sort keys

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/1451991518-25673-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-report.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index ae7cd91..8a301f6 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -117,6 +117,30 @@ OPTIONS
 	And default sort keys are changed to comm, dso_from, symbol_from, dso_to
 	and symbol_to, see '--branch-stack'.
 
+	If the data file has tracepoint event(s), following (dynamic) sort keys
+	are also available:
+	trace, trace_fields, [<event>.]<field>[/raw]
+
+	- trace: pretty printed trace output in a single column
+	- trace_fields: fields in tracepoints in separate columns
+	- <field name>: optional event and field name for a specific field
+
+	The last form consists of event and field names.  If event name is
+	omitted, it searches all events for matching field name.  The matched
+	field will be shown only for the event has the field.  The event name
+	supports substring match so user doesn't need to specify full subsystem
+	and event name everytime.  For example, 'sched:sched_switch' event can
+	be shortened to 'switch' as long as it's not ambiguous.  Also event can
+	be specified by its index (starting from 1) preceded by the '%'.
+	So '%1' is the first event, '%2' is the second, and so on.
+
+	The field name can have '/raw' suffix which disables pretty printing
+	and shows raw field value like hex numbers.  The --raw-trace option
+	has the same effect for all dynamic sort keys.
+
+	The default sort keys are changed to 'trace' if all events in the data
+	file are tracepoint.
+
 -F::
 --fields=::
 	Specify output field - multiple keys can be specified in CSV format.

[toc] | [prev] | [next] | [standalone]


#1301434 — [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-05 12:00 +0100
Subject[PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name
Message-ID<qNxvm-Wb-45@gated-at.bofh.it>
In reply to#1301422
When a perf.data file has multiple events, it's likely to be similar
(tracepoint) events.  In that case, they might have same field name so
add all of them to sort keys instead of bailing out.

In addition, it contains a trivial whitespace fix at callsite of
add_all_dynamic_fields().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/sort.c | 50 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 59c4c8586d79..a8a958827e39 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1863,10 +1863,9 @@ static int parse_field_name(char *str, char **event, char **field, char **opt)
 }
 
 /* find match evsel using a given event name.  The event name can be:
- *   1. NULL - only valid for single event session
- *   2. '%' + event index (e.g. '%1' for first event)
- *   3. full event name (e.g. sched:sched_switch)
- *   4. partial event name (should not contain ':')
+ *   1. '%' + event index (e.g. '%1' for first event)
+ *   2. full event name (e.g. sched:sched_switch)
+ *   3. partial event name (should not contain ':')
  */
 static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_name)
 {
@@ -1875,16 +1874,6 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
 	bool full_name;
 
 	/* case 1 */
-	if (event_name == NULL) {
-		if (evlist->nr_entries != 1) {
-			pr_debug("event name should be given\n");
-			return NULL;
-		}
-
-		return perf_evlist__first(evlist);
-	}
-
-	/* case 2 */
 	if (event_name[0] == '%') {
 		int nr = strtol(event_name+1, NULL, 0);
 
@@ -1900,10 +1889,10 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
 
 	full_name = !!strchr(event_name, ':');
 	evlist__for_each(evlist, pos) {
-		/* case 3 */
+		/* case 2 */
 		if (full_name && !strcmp(pos->name, event_name))
 			return pos;
-		/* case 4 */
+		/* case 3 */
 		if (!full_name && strstr(pos->name, event_name)) {
 			if (evsel) {
 				pr_debug("'%s' event is ambiguous: it can be %s or %s\n",
@@ -1965,6 +1954,28 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
 	return 0;
 }
 
+static int add_all_matching_fields(struct perf_evlist *evlist,
+				   char *field_name, bool raw_trace)
+{
+	int ret = -ESRCH;
+	struct perf_evsel *evsel;
+	struct format_field *field;
+
+	evlist__for_each(evlist, evsel) {
+		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
+			continue;
+
+		field = pevent_find_any_field(evsel->tp_format, field_name);
+		if (field == NULL)
+			continue;
+
+		ret = __dynamic_dimension__add(evsel, field, raw_trace);
+		if (ret < 0)
+			break;
+	}
+	return ret;
+}
+
 static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 {
 	char *str, *event_name, *field_name, *opt_name;
@@ -1995,7 +2006,12 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 	}
 
 	if (!strcmp(field_name, "trace_fields")) {
-		ret = add_all_dynamic_fields(evlist ,raw_trace);
+		ret = add_all_dynamic_fields(evlist, raw_trace);
+		goto out;
+	}
+
+	if (event_name == NULL) {
+		ret = add_all_matching_fields(evlist, field_name, raw_trace);
 		goto out;
 	}
 
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1301567 — Re: [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name

FromJiri Olsa <jolsa@redhat.com>
Date2016-01-05 15:30 +0100
SubjectRe: [PATCH v2 2/5] perf tools: Add all matching dynamic sort keys for field name
Message-ID<qNAMz-3Zq-35@gated-at.bofh.it>
In reply to#1301434
On Tue, Jan 05, 2016 at 07:58:35PM +0900, Namhyung Kim wrote:
> When a perf.data file has multiple events, it's likely to be similar
> (tracepoint) events.  In that case, they might have same field name so
> add all of them to sort keys instead of bailing out.
> 
> In addition, it contains a trivial whitespace fix at callsite of
> add_all_dynamic_fields().
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1305287 — [tip:perf/core] perf tools: Add all matching dynamic sort keys for field name

Fromtip-bot for Namhyung Kim <tipbot@zytor.com>
Date2016-01-09 17:40 +0100
Subject[tip:perf/core] perf tools: Add all matching dynamic sort keys for field name
Message-ID<qP4Iy-87R-9@gated-at.bofh.it>
In reply to#1301434
Commit-ID:  9735be24ec086fbccee321471cc21dedefa956a6
Gitweb:     http://git.kernel.org/tip/9735be24ec086fbccee321471cc21dedefa956a6
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Tue, 5 Jan 2016 19:58:35 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:14 -0300

perf tools: Add all matching dynamic sort keys for field name

When a perf.data file has multiple events, it's likely to be similar
(tracepoint) events.  In that case, they might have same field name so
add all of them to sort keys instead of bailing out.

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/1451991518-25673-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 48 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 4b4b1c5..04e2a5c 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1863,10 +1863,9 @@ static int parse_field_name(char *str, char **event, char **field, char **opt)
 }
 
 /* find match evsel using a given event name.  The event name can be:
- *   1. NULL - only valid for single event session
- *   2. '%' + event index (e.g. '%1' for first event)
- *   3. full event name (e.g. sched:sched_switch)
- *   4. partial event name (should not contain ':')
+ *   1. '%' + event index (e.g. '%1' for first event)
+ *   2. full event name (e.g. sched:sched_switch)
+ *   3. partial event name (should not contain ':')
  */
 static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_name)
 {
@@ -1875,16 +1874,6 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
 	bool full_name;
 
 	/* case 1 */
-	if (event_name == NULL) {
-		if (evlist->nr_entries != 1) {
-			pr_debug("event name should be given\n");
-			return NULL;
-		}
-
-		return perf_evlist__first(evlist);
-	}
-
-	/* case 2 */
 	if (event_name[0] == '%') {
 		int nr = strtol(event_name+1, NULL, 0);
 
@@ -1900,10 +1889,10 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
 
 	full_name = !!strchr(event_name, ':');
 	evlist__for_each(evlist, pos) {
-		/* case 3 */
+		/* case 2 */
 		if (full_name && !strcmp(pos->name, event_name))
 			return pos;
-		/* case 4 */
+		/* case 3 */
 		if (!full_name && strstr(pos->name, event_name)) {
 			if (evsel) {
 				pr_debug("'%s' event is ambiguous: it can be %s or %s\n",
@@ -1965,6 +1954,28 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
 	return 0;
 }
 
+static int add_all_matching_fields(struct perf_evlist *evlist,
+				   char *field_name, bool raw_trace)
+{
+	int ret = -ESRCH;
+	struct perf_evsel *evsel;
+	struct format_field *field;
+
+	evlist__for_each(evlist, evsel) {
+		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
+			continue;
+
+		field = pevent_find_any_field(evsel->tp_format, field_name);
+		if (field == NULL)
+			continue;
+
+		ret = __dynamic_dimension__add(evsel, field, raw_trace);
+		if (ret < 0)
+			break;
+	}
+	return ret;
+}
+
 static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 {
 	char *str, *event_name, *field_name, *opt_name;
@@ -1999,6 +2010,11 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 		goto out;
 	}
 
+	if (event_name == NULL) {
+		ret = add_all_matching_fields(evlist, field_name, raw_trace);
+		goto out;
+	}
+
 	evsel = find_evsel(evlist, event_name);
 	if (evsel == NULL) {
 		pr_debug("Cannot find event: %s\n", event_name);

[toc] | [prev] | [next] | [standalone]


#1301445 — [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-05 12:10 +0100
Subject[PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields
Message-ID<qNxF0-1fC-29@gated-at.bofh.it>
In reply to#1301422
Now dynamic sort keys are supported for tracepoint events, add it to
output fields too.

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/sort.c | 51 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index a8a958827e39..07312ceed6eb 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1908,7 +1908,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
 
 static int __dynamic_dimension__add(struct perf_evsel *evsel,
 				    struct format_field *field,
-				    bool raw_trace)
+				    bool raw_trace, bool is_sort_key)
 {
 	struct hpp_dynamic_entry *hde;
 
@@ -1918,18 +1918,24 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel,
 
 	hde->raw_trace = raw_trace;
 
-	perf_hpp__register_sort_field(&hde->hpp);
+	if (is_sort_key)
+		perf_hpp__register_sort_field(&hde->hpp);
+	else
+		perf_hpp__column_register(&hde->hpp);
+
 	return 0;
 }
 
-static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
+static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace,
+			    bool is_sort_key)
 {
 	int ret;
 	struct format_field *field;
 
 	field = evsel->tp_format->format.fields;
 	while (field) {
-		ret = __dynamic_dimension__add(evsel, field, raw_trace);
+		ret = __dynamic_dimension__add(evsel, field, raw_trace,
+					       is_sort_key);
 		if (ret < 0)
 			return ret;
 
@@ -1938,7 +1944,8 @@ static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
 	return 0;
 }
 
-static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
+static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace,
+				  bool is_sort_key)
 {
 	int ret;
 	struct perf_evsel *evsel;
@@ -1947,7 +1954,7 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
 		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
 			continue;
 
-		ret = add_evsel_fields(evsel, raw_trace);
+		ret = add_evsel_fields(evsel, raw_trace, is_sort_key);
 		if (ret < 0)
 			return ret;
 	}
@@ -1955,7 +1962,8 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
 }
 
 static int add_all_matching_fields(struct perf_evlist *evlist,
-				   char *field_name, bool raw_trace)
+				   char *field_name, bool raw_trace,
+				   bool is_sort_key)
 {
 	int ret = -ESRCH;
 	struct perf_evsel *evsel;
@@ -1969,14 +1977,16 @@ static int add_all_matching_fields(struct perf_evlist *evlist,
 		if (field == NULL)
 			continue;
 
-		ret = __dynamic_dimension__add(evsel, field, raw_trace);
+		ret = __dynamic_dimension__add(evsel, field, raw_trace,
+					       is_sort_key);
 		if (ret < 0)
 			break;
 	}
 	return ret;
 }
 
-static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
+static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok,
+			     bool is_sort_key)
 {
 	char *str, *event_name, *field_name, *opt_name;
 	struct perf_evsel *evsel;
@@ -2006,12 +2016,13 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 	}
 
 	if (!strcmp(field_name, "trace_fields")) {
-		ret = add_all_dynamic_fields(evlist, raw_trace);
+		ret = add_all_dynamic_fields(evlist, raw_trace, is_sort_key);
 		goto out;
 	}
 
 	if (event_name == NULL) {
-		ret = add_all_matching_fields(evlist, field_name, raw_trace);
+		ret = add_all_matching_fields(evlist, field_name, raw_trace,
+					      is_sort_key);
 		goto out;
 	}
 
@@ -2029,7 +2040,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 	}
 
 	if (!strcmp(field_name, "*")) {
-		ret = add_evsel_fields(evsel, raw_trace);
+		ret = add_evsel_fields(evsel, raw_trace, is_sort_key);
 	} else {
 		field = pevent_find_any_field(evsel->tp_format, field_name);
 		if (field == NULL) {
@@ -2038,7 +2049,8 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 			return -ENOENT;
 		}
 
-		ret = __dynamic_dimension__add(evsel, field, raw_trace);
+		ret = __dynamic_dimension__add(evsel, field, raw_trace,
+					       is_sort_key);
 	}
 
 out:
@@ -2182,7 +2194,7 @@ static int sort_dimension__add(const char *tok,
 		return 0;
 	}
 
-	if (!add_dynamic_entry(evlist, tok))
+	if (!add_dynamic_entry(evlist, tok, true))
 		return 0;
 
 	return -ESRCH;
@@ -2387,7 +2399,7 @@ void sort__setup_elide(FILE *output)
 	}
 }
 
-static int output_field_add(char *tok)
+static int output_field_add(struct perf_evlist *evlist, char *tok)
 {
 	unsigned int i;
 
@@ -2427,6 +2439,9 @@ static int output_field_add(char *tok)
 		return __sort_dimension__add_output(sd);
 	}
 
+	if (!add_dynamic_entry(evlist, tok, false))
+		return 0;
+
 	return -ESRCH;
 }
 
@@ -2452,7 +2467,7 @@ bool is_strict_order(const char *order)
 	return order && (*order != '+');
 }
 
-static int __setup_output_field(void)
+static int __setup_output_field(struct perf_evlist *evlist)
 {
 	char *tmp, *tok, *str, *strp;
 	int ret = -EINVAL;
@@ -2476,7 +2491,7 @@ static int __setup_output_field(void)
 
 	for (tok = strtok_r(strp, ", ", &tmp);
 			tok; tok = strtok_r(NULL, ", ", &tmp)) {
-		ret = output_field_add(tok);
+		ret = output_field_add(evlist, tok);
 		if (ret == -EINVAL) {
 			error("Invalid --fields key: `%s'", tok);
 			break;
@@ -2513,7 +2528,7 @@ int setup_sorting(struct perf_evlist *evlist)
 	if (sort__mode != SORT_MODE__DIFF)
 		perf_hpp__init();
 
-	err = __setup_output_field();
+	err = __setup_output_field(evlist);
 	if (err < 0)
 		return err;
 
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302245 — Re: [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-01-05 23:20 +0100
SubjectRe: [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields
Message-ID<qNI7n-Cl-11@gated-at.bofh.it>
In reply to#1301445
Em Tue, Jan 05, 2016 at 07:58:37PM +0900, Namhyung Kim escreveu:
> Now dynamic sort keys are supported for tracepoint events, add it to
> output fields too.

Must be the end of the day, but:

  [root@zoo ~]# perf report -h -F -s

   Usage: perf report [<options>]

    -F, --fields <key[,keys...]>
                          output field(s): overhead, period, sample plus all of sort keys
    -s, --sort <key[,key2...]>
                          sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ... Please refer the man page for the complete list.

  [root@zoo ~]#

So, with this file, for instance:

  [root@zoo ~]# perf evlist -v
  sched:sched_switch: type: 2, size: 112, config: 0x10b, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
  [root@zoo ~]#

I thought that these would be equivalent:

  [root@zoo ~]# perf report -s prev_comm,next_comm | head -20 | tail -15
  # Samples: 27K of event 'sched:sched_switch'
  # Event count (approx.): 27997
  #
  # Overhead         prev_comm         next_comm
  # ........  ................  ................
  #
    10.97%           firefox         swapper/0
    10.97%         swapper/0           firefox
    10.23%          Xorg.bin         swapper/2
    10.23%         swapper/2          Xorg.bin
    10.20%           firefox         swapper/3
    10.20%         swapper/3           firefox
     5.75%         swapper/1          Xorg.bin
     5.74%          Xorg.bin         swapper/1
     3.93%          Xorg.bin         swapper/0
  [root@zoo ~]#

  [root@zoo ~]# perf report -s prev_comm,next_comm -F overhead | head -20 | tail -15
  # Samples: 27K of event 'sched:sched_switch'
  # Event count (approx.): 27997
  #
  # Overhead         prev_comm         next_comm
  # ........  ................  ................
  #
     0.05%             xchat         swapper/1
     0.11%             xchat         swapper/0
     0.01%        watchdog/3         swapper/3
     0.01%        watchdog/2         swapper/2
     0.01%        watchdog/1         swapper/1
     0.01%        watchdog/0         swapper/0
     0.01%             virsh         swapper/2
     0.08%               tor         swapper/3
     0.02%               tor         swapper/1
  [root@zoo ~]#

What am I doing wrong or didn't understood about those options?

- Arnaldo
 
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/sort.c | 51 ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 33 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index a8a958827e39..07312ceed6eb 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1908,7 +1908,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
>  
>  static int __dynamic_dimension__add(struct perf_evsel *evsel,
>  				    struct format_field *field,
> -				    bool raw_trace)
> +				    bool raw_trace, bool is_sort_key)
>  {
>  	struct hpp_dynamic_entry *hde;
>  
> @@ -1918,18 +1918,24 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel,
>  
>  	hde->raw_trace = raw_trace;
>  
> -	perf_hpp__register_sort_field(&hde->hpp);
> +	if (is_sort_key)
> +		perf_hpp__register_sort_field(&hde->hpp);
> +	else
> +		perf_hpp__column_register(&hde->hpp);
> +
>  	return 0;
>  }
>  
> -static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
> +static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace,
> +			    bool is_sort_key)
>  {
>  	int ret;
>  	struct format_field *field;
>  
>  	field = evsel->tp_format->format.fields;
>  	while (field) {
> -		ret = __dynamic_dimension__add(evsel, field, raw_trace);
> +		ret = __dynamic_dimension__add(evsel, field, raw_trace,
> +					       is_sort_key);
>  		if (ret < 0)
>  			return ret;
>  
> @@ -1938,7 +1944,8 @@ static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
>  	return 0;
>  }
>  
> -static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
> +static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace,
> +				  bool is_sort_key)
>  {
>  	int ret;
>  	struct perf_evsel *evsel;
> @@ -1947,7 +1954,7 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
>  		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
>  			continue;
>  
> -		ret = add_evsel_fields(evsel, raw_trace);
> +		ret = add_evsel_fields(evsel, raw_trace, is_sort_key);
>  		if (ret < 0)
>  			return ret;
>  	}
> @@ -1955,7 +1962,8 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
>  }
>  
>  static int add_all_matching_fields(struct perf_evlist *evlist,
> -				   char *field_name, bool raw_trace)
> +				   char *field_name, bool raw_trace,
> +				   bool is_sort_key)
>  {
>  	int ret = -ESRCH;
>  	struct perf_evsel *evsel;
> @@ -1969,14 +1977,16 @@ static int add_all_matching_fields(struct perf_evlist *evlist,
>  		if (field == NULL)
>  			continue;
>  
> -		ret = __dynamic_dimension__add(evsel, field, raw_trace);
> +		ret = __dynamic_dimension__add(evsel, field, raw_trace,
> +					       is_sort_key);
>  		if (ret < 0)
>  			break;
>  	}
>  	return ret;
>  }
>  
> -static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
> +static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok,
> +			     bool is_sort_key)
>  {
>  	char *str, *event_name, *field_name, *opt_name;
>  	struct perf_evsel *evsel;
> @@ -2006,12 +2016,13 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
>  	}
>  
>  	if (!strcmp(field_name, "trace_fields")) {
> -		ret = add_all_dynamic_fields(evlist, raw_trace);
> +		ret = add_all_dynamic_fields(evlist, raw_trace, is_sort_key);
>  		goto out;
>  	}
>  
>  	if (event_name == NULL) {
> -		ret = add_all_matching_fields(evlist, field_name, raw_trace);
> +		ret = add_all_matching_fields(evlist, field_name, raw_trace,
> +					      is_sort_key);
>  		goto out;
>  	}
>  
> @@ -2029,7 +2040,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
>  	}
>  
>  	if (!strcmp(field_name, "*")) {
> -		ret = add_evsel_fields(evsel, raw_trace);
> +		ret = add_evsel_fields(evsel, raw_trace, is_sort_key);
>  	} else {
>  		field = pevent_find_any_field(evsel->tp_format, field_name);
>  		if (field == NULL) {
> @@ -2038,7 +2049,8 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
>  			return -ENOENT;
>  		}
>  
> -		ret = __dynamic_dimension__add(evsel, field, raw_trace);
> +		ret = __dynamic_dimension__add(evsel, field, raw_trace,
> +					       is_sort_key);
>  	}
>  
>  out:
> @@ -2182,7 +2194,7 @@ static int sort_dimension__add(const char *tok,
>  		return 0;
>  	}
>  
> -	if (!add_dynamic_entry(evlist, tok))
> +	if (!add_dynamic_entry(evlist, tok, true))
>  		return 0;
>  
>  	return -ESRCH;
> @@ -2387,7 +2399,7 @@ void sort__setup_elide(FILE *output)
>  	}
>  }
>  
> -static int output_field_add(char *tok)
> +static int output_field_add(struct perf_evlist *evlist, char *tok)
>  {
>  	unsigned int i;
>  
> @@ -2427,6 +2439,9 @@ static int output_field_add(char *tok)
>  		return __sort_dimension__add_output(sd);
>  	}
>  
> +	if (!add_dynamic_entry(evlist, tok, false))
> +		return 0;
> +
>  	return -ESRCH;
>  }
>  
> @@ -2452,7 +2467,7 @@ bool is_strict_order(const char *order)
>  	return order && (*order != '+');
>  }
>  
> -static int __setup_output_field(void)
> +static int __setup_output_field(struct perf_evlist *evlist)
>  {
>  	char *tmp, *tok, *str, *strp;
>  	int ret = -EINVAL;
> @@ -2476,7 +2491,7 @@ static int __setup_output_field(void)
>  
>  	for (tok = strtok_r(strp, ", ", &tmp);
>  			tok; tok = strtok_r(NULL, ", ", &tmp)) {
> -		ret = output_field_add(tok);
> +		ret = output_field_add(evlist, tok);
>  		if (ret == -EINVAL) {
>  			error("Invalid --fields key: `%s'", tok);
>  			break;
> @@ -2513,7 +2528,7 @@ int setup_sorting(struct perf_evlist *evlist)
>  	if (sort__mode != SORT_MODE__DIFF)
>  		perf_hpp__init();
>  
> -	err = __setup_output_field();
> +	err = __setup_output_field(evlist);
>  	if (err < 0)
>  		return err;
>  
> -- 
> 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302277 — Re: [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-06 01:00 +0100
SubjectRe: [PATCH v2 4/5] perf tools: Support dynamic sort keys for -F/--fields
Message-ID<qNJG9-1vi-3@gated-at.bofh.it>
In reply to#1302245
On Tue, Jan 05, 2016 at 07:16:43PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 05, 2016 at 07:58:37PM +0900, Namhyung Kim escreveu:
> > Now dynamic sort keys are supported for tracepoint events, add it to
> > output fields too.
> 
> Must be the end of the day, but:
> 
>   [root@zoo ~]# perf report -h -F -s
> 
>    Usage: perf report [<options>]
> 
>     -F, --fields <key[,keys...]>
>                           output field(s): overhead, period, sample plus all of sort keys
>     -s, --sort <key[,key2...]>
>                           sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ... Please refer the man page for the complete list.
> 
>   [root@zoo ~]#
> 
> So, with this file, for instance:
> 
>   [root@zoo ~]# perf evlist -v
>   sched:sched_switch: type: 2, size: 112, config: 0x10b, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
>   [root@zoo ~]#
> 
> I thought that these would be equivalent:
> 
>   [root@zoo ~]# perf report -s prev_comm,next_comm | head -20 | tail -15
>   # Samples: 27K of event 'sched:sched_switch'
>   # Event count (approx.): 27997
>   #
>   # Overhead         prev_comm         next_comm
>   # ........  ................  ................
>   #
>     10.97%           firefox         swapper/0
>     10.97%         swapper/0           firefox
>     10.23%          Xorg.bin         swapper/2
>     10.23%         swapper/2          Xorg.bin
>     10.20%           firefox         swapper/3
>     10.20%         swapper/3           firefox
>      5.75%         swapper/1          Xorg.bin
>      5.74%          Xorg.bin         swapper/1
>      3.93%          Xorg.bin         swapper/0
>   [root@zoo ~]#
> 
>   [root@zoo ~]# perf report -s prev_comm,next_comm -F overhead | head -20 | tail -15
>   # Samples: 27K of event 'sched:sched_switch'
>   # Event count (approx.): 27997
>   #
>   # Overhead         prev_comm         next_comm
>   # ........  ................  ................
>   #
>      0.05%             xchat         swapper/1
>      0.11%             xchat         swapper/0
>      0.01%        watchdog/3         swapper/3
>      0.01%        watchdog/2         swapper/2
>      0.01%        watchdog/1         swapper/1
>      0.01%        watchdog/0         swapper/0
>      0.01%             virsh         swapper/2
>      0.08%               tor         swapper/3
>      0.02%               tor         swapper/1
>   [root@zoo ~]#
> 
> What am I doing wrong or didn't understood about those options?

Yes, this is subtle.  The --sort option didn't really sort data but
just aggregate it.  By adding -F/--fields option, the aggregation and
sorting can be separated.  Behavior of the -s/--sort option is kept if
it's not used with -F/--fields (for backward compatibility).  However
if it used with -F/--fields, it has the original meaning of sorting.

IOW, 'perf report -s prev_comm,next_comm' is actually same as
     'perf report -F overhead,prev_comm,next_comm -s overhead'.

You run 'perf report -F overhead -s prev_com,next_comm', so it sorts
the data using alphabetical order of prev_comm and then next_comm (But
it should be reversed, will fix).

Please see the description of the original patch posting.

  https://lkml.org/lkml/2014/5/19/84


Thanks,
Namhyung


> 
> - Arnaldo
>  
> > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/util/sort.c | 51 ++++++++++++++++++++++++++++++++------------------
> >  1 file changed, 33 insertions(+), 18 deletions(-)
> > 
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index a8a958827e39..07312ceed6eb 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -1908,7 +1908,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
> >  
> >  static int __dynamic_dimension__add(struct perf_evsel *evsel,
> >  				    struct format_field *field,
> > -				    bool raw_trace)
> > +				    bool raw_trace, bool is_sort_key)
> >  {
> >  	struct hpp_dynamic_entry *hde;
> >  
> > @@ -1918,18 +1918,24 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel,
> >  
> >  	hde->raw_trace = raw_trace;
> >  
> > -	perf_hpp__register_sort_field(&hde->hpp);
> > +	if (is_sort_key)
> > +		perf_hpp__register_sort_field(&hde->hpp);
> > +	else
> > +		perf_hpp__column_register(&hde->hpp);
> > +
> >  	return 0;
> >  }
> >  
> > -static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
> > +static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace,
> > +			    bool is_sort_key)
> >  {
> >  	int ret;
> >  	struct format_field *field;
> >  
> >  	field = evsel->tp_format->format.fields;
> >  	while (field) {
> > -		ret = __dynamic_dimension__add(evsel, field, raw_trace);
> > +		ret = __dynamic_dimension__add(evsel, field, raw_trace,
> > +					       is_sort_key);
> >  		if (ret < 0)
> >  			return ret;
> >  
> > @@ -1938,7 +1944,8 @@ static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
> >  	return 0;
> >  }
> >  
> > -static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
> > +static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace,
> > +				  bool is_sort_key)
> >  {
> >  	int ret;
> >  	struct perf_evsel *evsel;
> > @@ -1947,7 +1954,7 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
> >  		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
> >  			continue;
> >  
> > -		ret = add_evsel_fields(evsel, raw_trace);
> > +		ret = add_evsel_fields(evsel, raw_trace, is_sort_key);
> >  		if (ret < 0)
> >  			return ret;
> >  	}
> > @@ -1955,7 +1962,8 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
> >  }
> >  
> >  static int add_all_matching_fields(struct perf_evlist *evlist,
> > -				   char *field_name, bool raw_trace)
> > +				   char *field_name, bool raw_trace,
> > +				   bool is_sort_key)
> >  {
> >  	int ret = -ESRCH;
> >  	struct perf_evsel *evsel;
> > @@ -1969,14 +1977,16 @@ static int add_all_matching_fields(struct perf_evlist *evlist,
> >  		if (field == NULL)
> >  			continue;
> >  
> > -		ret = __dynamic_dimension__add(evsel, field, raw_trace);
> > +		ret = __dynamic_dimension__add(evsel, field, raw_trace,
> > +					       is_sort_key);
> >  		if (ret < 0)
> >  			break;
> >  	}
> >  	return ret;
> >  }
> >  
> > -static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
> > +static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok,
> > +			     bool is_sort_key)
> >  {
> >  	char *str, *event_name, *field_name, *opt_name;
> >  	struct perf_evsel *evsel;
> > @@ -2006,12 +2016,13 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
> >  	}
> >  
> >  	if (!strcmp(field_name, "trace_fields")) {
> > -		ret = add_all_dynamic_fields(evlist, raw_trace);
> > +		ret = add_all_dynamic_fields(evlist, raw_trace, is_sort_key);
> >  		goto out;
> >  	}
> >  
> >  	if (event_name == NULL) {
> > -		ret = add_all_matching_fields(evlist, field_name, raw_trace);
> > +		ret = add_all_matching_fields(evlist, field_name, raw_trace,
> > +					      is_sort_key);
> >  		goto out;
> >  	}
> >  
> > @@ -2029,7 +2040,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
> >  	}
> >  
> >  	if (!strcmp(field_name, "*")) {
> > -		ret = add_evsel_fields(evsel, raw_trace);
> > +		ret = add_evsel_fields(evsel, raw_trace, is_sort_key);
> >  	} else {
> >  		field = pevent_find_any_field(evsel->tp_format, field_name);
> >  		if (field == NULL) {
> > @@ -2038,7 +2049,8 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
> >  			return -ENOENT;
> >  		}
> >  
> > -		ret = __dynamic_dimension__add(evsel, field, raw_trace);
> > +		ret = __dynamic_dimension__add(evsel, field, raw_trace,
> > +					       is_sort_key);
> >  	}
> >  
> >  out:
> > @@ -2182,7 +2194,7 @@ static int sort_dimension__add(const char *tok,
> >  		return 0;
> >  	}
> >  
> > -	if (!add_dynamic_entry(evlist, tok))
> > +	if (!add_dynamic_entry(evlist, tok, true))
> >  		return 0;
> >  
> >  	return -ESRCH;
> > @@ -2387,7 +2399,7 @@ void sort__setup_elide(FILE *output)
> >  	}
> >  }
> >  
> > -static int output_field_add(char *tok)
> > +static int output_field_add(struct perf_evlist *evlist, char *tok)
> >  {
> >  	unsigned int i;
> >  
> > @@ -2427,6 +2439,9 @@ static int output_field_add(char *tok)
> >  		return __sort_dimension__add_output(sd);
> >  	}
> >  
> > +	if (!add_dynamic_entry(evlist, tok, false))
> > +		return 0;
> > +
> >  	return -ESRCH;
> >  }
> >  
> > @@ -2452,7 +2467,7 @@ bool is_strict_order(const char *order)
> >  	return order && (*order != '+');
> >  }
> >  
> > -static int __setup_output_field(void)
> > +static int __setup_output_field(struct perf_evlist *evlist)
> >  {
> >  	char *tmp, *tok, *str, *strp;
> >  	int ret = -EINVAL;
> > @@ -2476,7 +2491,7 @@ static int __setup_output_field(void)
> >  
> >  	for (tok = strtok_r(strp, ", ", &tmp);
> >  			tok; tok = strtok_r(NULL, ", ", &tmp)) {
> > -		ret = output_field_add(tok);
> > +		ret = output_field_add(evlist, tok);
> >  		if (ret == -EINVAL) {
> >  			error("Invalid --fields key: `%s'", tok);
> >  			break;
> > @@ -2513,7 +2528,7 @@ int setup_sorting(struct perf_evlist *evlist)
> >  	if (sort__mode != SORT_MODE__DIFF)
> >  		perf_hpp__init();
> >  
> > -	err = __setup_output_field();
> > +	err = __setup_output_field(evlist);
> >  	if (err < 0)
> >  		return err;
> >  
> > -- 
> > 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1301447 — [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-05 12:10 +0100
Subject[PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields
Message-ID<qNxF0-1fC-31@gated-at.bofh.it>
In reply to#1301422
To use dynamic sort keys, it might be good to add an option to see the
list of field names.

  $ perf evlist -T -i perf.data.sched
  sched:sched_switch: trace_fields=prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
  sched:sched_stat_wait: trace_fields=comm,pid,delay
  sched:sched_stat_sleep: trace_fields=comm,pid,delay
  sched:sched_stat_iowait: trace_fields=comm,pid,delay
  sched:sched_stat_runtime: trace_fields=comm,pid,runtime,vruntime
  sched:sched_process_fork: trace_fields=parent_comm,parent_pid,child_comm,child_pid
  sched:sched_wakeup: trace_fields=comm,pid,prio,success,target_cpu
  sched:sched_wakeup_new: trace_fields=comm,pid,prio,success,target_cpu
  sched:sched_migrate_task: trace_fields=comm,pid,prio,orig_cpu,dest_cpu

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-evlist.txt |  4 ++++
 tools/perf/builtin-evlist.c              |  1 +
 tools/perf/util/evsel.c                  | 23 +++++++++++++++++++++++
 tools/perf/util/evsel.h                  |  1 +
 4 files changed, 29 insertions(+)

diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
index 1ceb3700ffbb..b0d99c276cf5 100644
--- a/tools/perf/Documentation/perf-evlist.txt
+++ b/tools/perf/Documentation/perf-evlist.txt
@@ -32,6 +32,10 @@ OPTIONS
 --group::
 	Show event group information.
 
+-T::
+--trace::
+	Show tracepoint field names.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-list[1],
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 08a7d36a2cf8..2820bb2d8cf8 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -49,6 +49,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN('g', "group", &details.event_group,
 		    "Show event group information"),
 	OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
+	OPT_BOOLEAN('T', "trace", &details.trace, "Show tracepoint fields"),
 	OPT_END()
 	};
 	const char * const evlist_usage[] = {
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 544e4400de13..174d0029e038 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2298,6 +2298,29 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
 		printed += comma_fprintf(fp, &first, " %s=%" PRIu64,
 					 term, (u64)evsel->attr.sample_freq);
 	}
+
+	if (details->trace) {
+		struct format_field *field;
+
+		if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
+			printed += comma_fprintf(fp, &first, " (not a tracepoint)");
+			goto out;
+		}
+
+		field = evsel->tp_format->format.fields;
+		if (field == NULL) {
+			printed += comma_fprintf(fp, &first, " (no trace field)");
+			goto out;
+		}
+
+		printed += comma_fprintf(fp, &first, " trace_fields=%s", field->name);
+
+		field = field->next;
+		while (field) {
+			printed += comma_fprintf(fp, &first, "%s", field->name);
+			field = field->next;
+		}
+	}
 out:
 	fputc('\n', fp);
 	return ++printed;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 5ded1fc0341e..9b36dd584d4a 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -369,6 +369,7 @@ struct perf_attr_details {
 	bool verbose;
 	bool event_group;
 	bool force;
+	bool trace;
 };
 
 int perf_evsel__fprintf(struct perf_evsel *evsel,
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302247 — Re: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-01-05 23:30 +0100
SubjectRe: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields
Message-ID<qNIh3-FU-1@gated-at.bofh.it>
In reply to#1301447
Em Tue, Jan 05, 2016 at 07:58:38PM +0900, Namhyung Kim escreveu:
> To use dynamic sort keys, it might be good to add an option to see the
> list of field names.
> 
>   $ perf evlist -T -i perf.data.sched

Humm, I think here we should just use --trace_fields, like what appears
in the output for each line below, and also as is the case for the '-s
trace_fields' case, ok?

With:

  $ . ~/git/linux/tools/perf/perf-completion.sh 
  [acme@zoo linux]$ perf evlist --
  --force    --freq     --group    --input    --verbose  
  [acme@zoo linux]$ perf evlist --

We can autocomplete it from --t<TAB> anyway :)

Unsure about '-T', perhaps this is so specialized, that can remain with
just the long option?

Perhaps we can add a tip, when we run:

  perf evlist

And there are tracepoint events, something like:

  perf evlist -v
  sched:sched_switch ...
  # Tip use 'perf evlist --trace_fields' to show fields for events such
  # as "sched:sched_switch"

- Arnaldo

>   sched:sched_switch: trace_fields=prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
>   sched:sched_stat_wait: trace_fields=comm,pid,delay
>   sched:sched_stat_sleep: trace_fields=comm,pid,delay
>   sched:sched_stat_iowait: trace_fields=comm,pid,delay
>   sched:sched_stat_runtime: trace_fields=comm,pid,runtime,vruntime
>   sched:sched_process_fork: trace_fields=parent_comm,parent_pid,child_comm,child_pid
>   sched:sched_wakeup: trace_fields=comm,pid,prio,success,target_cpu
>   sched:sched_wakeup_new: trace_fields=comm,pid,prio,success,target_cpu
>   sched:sched_migrate_task: trace_fields=comm,pid,prio,orig_cpu,dest_cpu
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/Documentation/perf-evlist.txt |  4 ++++
>  tools/perf/builtin-evlist.c              |  1 +
>  tools/perf/util/evsel.c                  | 23 +++++++++++++++++++++++
>  tools/perf/util/evsel.h                  |  1 +
>  4 files changed, 29 insertions(+)
> 
> diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
> index 1ceb3700ffbb..b0d99c276cf5 100644
> --- a/tools/perf/Documentation/perf-evlist.txt
> +++ b/tools/perf/Documentation/perf-evlist.txt
> @@ -32,6 +32,10 @@ OPTIONS
>  --group::
>  	Show event group information.
>  
> +-T::
> +--trace::
> +	Show tracepoint field names.
> +
>  SEE ALSO
>  --------
>  linkperf:perf-record[1], linkperf:perf-list[1],
> diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
> index 08a7d36a2cf8..2820bb2d8cf8 100644
> --- a/tools/perf/builtin-evlist.c
> +++ b/tools/perf/builtin-evlist.c
> @@ -49,6 +49,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
>  	OPT_BOOLEAN('g', "group", &details.event_group,
>  		    "Show event group information"),
>  	OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
> +	OPT_BOOLEAN('T', "trace", &details.trace, "Show tracepoint fields"),
>  	OPT_END()
>  	};
>  	const char * const evlist_usage[] = {
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 544e4400de13..174d0029e038 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2298,6 +2298,29 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
>  		printed += comma_fprintf(fp, &first, " %s=%" PRIu64,
>  					 term, (u64)evsel->attr.sample_freq);
>  	}
> +
> +	if (details->trace) {
> +		struct format_field *field;
> +
> +		if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
> +			printed += comma_fprintf(fp, &first, " (not a tracepoint)");
> +			goto out;
> +		}
> +
> +		field = evsel->tp_format->format.fields;
> +		if (field == NULL) {
> +			printed += comma_fprintf(fp, &first, " (no trace field)");
> +			goto out;
> +		}
> +
> +		printed += comma_fprintf(fp, &first, " trace_fields=%s", field->name);
> +
> +		field = field->next;
> +		while (field) {
> +			printed += comma_fprintf(fp, &first, "%s", field->name);
> +			field = field->next;
> +		}
> +	}
>  out:
>  	fputc('\n', fp);
>  	return ++printed;
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 5ded1fc0341e..9b36dd584d4a 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -369,6 +369,7 @@ struct perf_attr_details {
>  	bool verbose;
>  	bool event_group;
>  	bool force;
> +	bool trace;
>  };
>  
>  int perf_evsel__fprintf(struct perf_evsel *evsel,
> -- 
> 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302284 — Re: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-06 01:10 +0100
SubjectRe: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields
Message-ID<qNJPQ-1OH-9@gated-at.bofh.it>
In reply to#1302247
On Tue, Jan 05, 2016 at 07:23:33PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 05, 2016 at 07:58:38PM +0900, Namhyung Kim escreveu:
> > To use dynamic sort keys, it might be good to add an option to see the
> > list of field names.
> > 
> >   $ perf evlist -T -i perf.data.sched
> 
> Humm, I think here we should just use --trace_fields, like what appears
> in the output for each line below, and also as is the case for the '-s
> trace_fields' case, ok?

OK

> 
> With:
> 
>   $ . ~/git/linux/tools/perf/perf-completion.sh 
>   [acme@zoo linux]$ perf evlist --
>   --force    --freq     --group    --input    --verbose  
>   [acme@zoo linux]$ perf evlist --
> 
> We can autocomplete it from --t<TAB> anyway :)
> 
> Unsure about '-T', perhaps this is so specialized, that can remain with
> just the long option?

OK

> 
> Perhaps we can add a tip, when we run:
> 
>   perf evlist
> 
> And there are tracepoint events, something like:
> 
>   perf evlist -v
>   sched:sched_switch ...
>   # Tip use 'perf evlist --trace_fields' to show fields for events such
>   # as "sched:sched_switch"

OK, it'd display this only the evlist has tracepoints.  How about this oneliner?

  # Tip: use 'perf evlist --trace_fields' to show fields for tracepoint events

Thanks,
Namhyung


> 
> - Arnaldo
> 
> >   sched:sched_switch: trace_fields=prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
> >   sched:sched_stat_wait: trace_fields=comm,pid,delay
> >   sched:sched_stat_sleep: trace_fields=comm,pid,delay
> >   sched:sched_stat_iowait: trace_fields=comm,pid,delay
> >   sched:sched_stat_runtime: trace_fields=comm,pid,runtime,vruntime
> >   sched:sched_process_fork: trace_fields=parent_comm,parent_pid,child_comm,child_pid
> >   sched:sched_wakeup: trace_fields=comm,pid,prio,success,target_cpu
> >   sched:sched_wakeup_new: trace_fields=comm,pid,prio,success,target_cpu
> >   sched:sched_migrate_task: trace_fields=comm,pid,prio,orig_cpu,dest_cpu
> > 
> > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/Documentation/perf-evlist.txt |  4 ++++
> >  tools/perf/builtin-evlist.c              |  1 +
> >  tools/perf/util/evsel.c                  | 23 +++++++++++++++++++++++
> >  tools/perf/util/evsel.h                  |  1 +
> >  4 files changed, 29 insertions(+)
> > 
> > diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
> > index 1ceb3700ffbb..b0d99c276cf5 100644
> > --- a/tools/perf/Documentation/perf-evlist.txt
> > +++ b/tools/perf/Documentation/perf-evlist.txt
> > @@ -32,6 +32,10 @@ OPTIONS
> >  --group::
> >  	Show event group information.
> >  
> > +-T::
> > +--trace::
> > +	Show tracepoint field names.
> > +
> >  SEE ALSO
> >  --------
> >  linkperf:perf-record[1], linkperf:perf-list[1],
> > diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
> > index 08a7d36a2cf8..2820bb2d8cf8 100644
> > --- a/tools/perf/builtin-evlist.c
> > +++ b/tools/perf/builtin-evlist.c
> > @@ -49,6 +49,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
> >  	OPT_BOOLEAN('g', "group", &details.event_group,
> >  		    "Show event group information"),
> >  	OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
> > +	OPT_BOOLEAN('T', "trace", &details.trace, "Show tracepoint fields"),
> >  	OPT_END()
> >  	};
> >  	const char * const evlist_usage[] = {
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index 544e4400de13..174d0029e038 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -2298,6 +2298,29 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
> >  		printed += comma_fprintf(fp, &first, " %s=%" PRIu64,
> >  					 term, (u64)evsel->attr.sample_freq);
> >  	}
> > +
> > +	if (details->trace) {
> > +		struct format_field *field;
> > +
> > +		if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
> > +			printed += comma_fprintf(fp, &first, " (not a tracepoint)");
> > +			goto out;
> > +		}
> > +
> > +		field = evsel->tp_format->format.fields;
> > +		if (field == NULL) {
> > +			printed += comma_fprintf(fp, &first, " (no trace field)");
> > +			goto out;
> > +		}
> > +
> > +		printed += comma_fprintf(fp, &first, " trace_fields=%s", field->name);
> > +
> > +		field = field->next;
> > +		while (field) {
> > +			printed += comma_fprintf(fp, &first, "%s", field->name);
> > +			field = field->next;
> > +		}
> > +	}
> >  out:
> >  	fputc('\n', fp);
> >  	return ++printed;
> > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> > index 5ded1fc0341e..9b36dd584d4a 100644
> > --- a/tools/perf/util/evsel.h
> > +++ b/tools/perf/util/evsel.h
> > @@ -369,6 +369,7 @@ struct perf_attr_details {
> >  	bool verbose;
> >  	bool event_group;
> >  	bool force;
> > +	bool trace;
> >  };
> >  
> >  int perf_evsel__fprintf(struct perf_evsel *evsel,
> > -- 
> > 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302329 — Re: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-01-06 03:00 +0100
SubjectRe: [PATCH v2 5/5] perf evlist: Add -T/--trace option to show trace fields
Message-ID<qNLyi-2LD-1@gated-at.bofh.it>
In reply to#1302284
Em Wed, Jan 06, 2016 at 09:00:31AM +0900, Namhyung Kim escreveu:
> On Tue, Jan 05, 2016 at 07:23:33PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Jan 05, 2016 at 07:58:38PM +0900, Namhyung Kim escreveu:
> > > To use dynamic sort keys, it might be good to add an option to see the
> > > list of field names.
> > > 
> > >   $ perf evlist -T -i perf.data.sched
> > 
> > Humm, I think here we should just use --trace_fields, like what appears
> > in the output for each line below, and also as is the case for the '-s
> > trace_fields' case, ok?
> 
> OK
> 
> > 
> > With:
> > 
> >   $ . ~/git/linux/tools/perf/perf-completion.sh 
> >   [acme@zoo linux]$ perf evlist --
> >   --force    --freq     --group    --input    --verbose  
> >   [acme@zoo linux]$ perf evlist --
> > 
> > We can autocomplete it from --t<TAB> anyway :)
> > 
> > Unsure about '-T', perhaps this is so specialized, that can remain with
> > just the long option?
> 
> OK
> 
> > 
> > Perhaps we can add a tip, when we run:
> > 
> >   perf evlist
> > 
> > And there are tracepoint events, something like:
> > 
> >   perf evlist -v
> >   sched:sched_switch ...
> >   # Tip use 'perf evlist --trace_fields' to show fields for events such
> >   # as "sched:sched_switch"
> 
> OK, it'd display this only the evlist has tracepoints.  How about this oneliner?
> 
>   # Tip: use 'perf evlist --trace_fields' to show fields for tracepoint events

Sure, I tried using the name of the existing event, "sched:sched_switch"
in this case, to get even closer to what to pass to --trace_fields :-)
 
> Thanks,
> Namhyung
> 
> 
> > 
> > - Arnaldo
> > 
> > >   sched:sched_switch: trace_fields=prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
> > >   sched:sched_stat_wait: trace_fields=comm,pid,delay
> > >   sched:sched_stat_sleep: trace_fields=comm,pid,delay
> > >   sched:sched_stat_iowait: trace_fields=comm,pid,delay
> > >   sched:sched_stat_runtime: trace_fields=comm,pid,runtime,vruntime
> > >   sched:sched_process_fork: trace_fields=parent_comm,parent_pid,child_comm,child_pid
> > >   sched:sched_wakeup: trace_fields=comm,pid,prio,success,target_cpu
> > >   sched:sched_wakeup_new: trace_fields=comm,pid,prio,success,target_cpu
> > >   sched:sched_migrate_task: trace_fields=comm,pid,prio,orig_cpu,dest_cpu
> > > 
> > > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > ---
> > >  tools/perf/Documentation/perf-evlist.txt |  4 ++++
> > >  tools/perf/builtin-evlist.c              |  1 +
> > >  tools/perf/util/evsel.c                  | 23 +++++++++++++++++++++++
> > >  tools/perf/util/evsel.h                  |  1 +
> > >  4 files changed, 29 insertions(+)
> > > 
> > > diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
> > > index 1ceb3700ffbb..b0d99c276cf5 100644
> > > --- a/tools/perf/Documentation/perf-evlist.txt
> > > +++ b/tools/perf/Documentation/perf-evlist.txt
> > > @@ -32,6 +32,10 @@ OPTIONS
> > >  --group::
> > >  	Show event group information.
> > >  
> > > +-T::
> > > +--trace::
> > > +	Show tracepoint field names.
> > > +
> > >  SEE ALSO
> > >  --------
> > >  linkperf:perf-record[1], linkperf:perf-list[1],
> > > diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
> > > index 08a7d36a2cf8..2820bb2d8cf8 100644
> > > --- a/tools/perf/builtin-evlist.c
> > > +++ b/tools/perf/builtin-evlist.c
> > > @@ -49,6 +49,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
> > >  	OPT_BOOLEAN('g', "group", &details.event_group,
> > >  		    "Show event group information"),
> > >  	OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
> > > +	OPT_BOOLEAN('T', "trace", &details.trace, "Show tracepoint fields"),
> > >  	OPT_END()
> > >  	};
> > >  	const char * const evlist_usage[] = {
> > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > > index 544e4400de13..174d0029e038 100644
> > > --- a/tools/perf/util/evsel.c
> > > +++ b/tools/perf/util/evsel.c
> > > @@ -2298,6 +2298,29 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
> > >  		printed += comma_fprintf(fp, &first, " %s=%" PRIu64,
> > >  					 term, (u64)evsel->attr.sample_freq);
> > >  	}
> > > +
> > > +	if (details->trace) {
> > > +		struct format_field *field;
> > > +
> > > +		if (evsel->attr.type != PERF_TYPE_TRACEPOINT) {
> > > +			printed += comma_fprintf(fp, &first, " (not a tracepoint)");
> > > +			goto out;
> > > +		}
> > > +
> > > +		field = evsel->tp_format->format.fields;
> > > +		if (field == NULL) {
> > > +			printed += comma_fprintf(fp, &first, " (no trace field)");
> > > +			goto out;
> > > +		}
> > > +
> > > +		printed += comma_fprintf(fp, &first, " trace_fields=%s", field->name);
> > > +
> > > +		field = field->next;
> > > +		while (field) {
> > > +			printed += comma_fprintf(fp, &first, "%s", field->name);
> > > +			field = field->next;
> > > +		}
> > > +	}
> > >  out:
> > >  	fputc('\n', fp);
> > >  	return ++printed;
> > > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> > > index 5ded1fc0341e..9b36dd584d4a 100644
> > > --- a/tools/perf/util/evsel.h
> > > +++ b/tools/perf/util/evsel.h
> > > @@ -369,6 +369,7 @@ struct perf_attr_details {
> > >  	bool verbose;
> > >  	bool event_group;
> > >  	bool force;
> > > +	bool trace;
> > >  };
> > >  
> > >  int perf_evsel__fprintf(struct perf_evsel *evsel,
> > > -- 
> > > 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302236 — Re: [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-01-05 23:00 +0100
SubjectRe: [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields
Message-ID<qNHO2-gg-3@gated-at.bofh.it>
In reply to#1301422
Em Tue, Jan 05, 2016 at 07:58:34PM +0900, Namhyung Kim escreveu:
> When the 'trace_fields' sort key is used explicitly for non-tracepoint
> events, it'll get segfault since it assumed evsel->tp_format was set.
> Skip those events in add_all_dynamic_fields().
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Merged with the patch introducing this problem, that I hadn't sent to
Ingo,

- Arnaldo

> ---
>  tools/perf/util/sort.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index e558e87cafaf..59c4c8586d79 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1955,6 +1955,9 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
>  	struct perf_evsel *evsel;
>  
>  	evlist__for_each(evlist, evsel) {
> +		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
> +			continue;
> +
>  		ret = add_evsel_fields(evsel, raw_trace);
>  		if (ret < 0)
>  			return ret;
> -- 
> 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302271 — Re: [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-06 00:40 +0100
SubjectRe: [PATCH v2 1/5] perf tools: Fix segfault when using -s trace_fields
Message-ID<qNJmN-1oM-13@gated-at.bofh.it>
In reply to#1302236
On Tue, Jan 05, 2016 at 06:50:02PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 05, 2016 at 07:58:34PM +0900, Namhyung Kim escreveu:
> > When the 'trace_fields' sort key is used explicitly for non-tracepoint
> > events, it'll get segfault since it assumed evsel->tp_format was set.
> > Skip those events in add_all_dynamic_fields().
> > 
> > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Merged with the patch introducing this problem, that I hadn't sent to
> Ingo,

Thanks for doing that!
Namhyung


> 
> > ---
> >  tools/perf/util/sort.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index e558e87cafaf..59c4c8586d79 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -1955,6 +1955,9 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
> >  	struct perf_evsel *evsel;
> >  
> >  	evlist__for_each(evlist, evsel) {
> > +		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
> > +			continue;
> > +
> >  		ret = add_evsel_fields(evsel, raw_trace);
> >  		if (ret < 0)
> >  			return ret;
> > -- 
> > 2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1305277 — [tip:perf/core] perf tools: Add 'trace_fields' dynamic sort key

Fromtip-bot for Namhyung Kim <tipbot@zytor.com>
Date2016-01-09 17:30 +0100
Subject[tip:perf/core] perf tools: Add 'trace_fields' dynamic sort key
Message-ID<qP4yV-83p-55@gated-at.bofh.it>
In reply to#1301422
Commit-ID:  2e422fd1e4b0a1c0ca11d360be2147c87911dd1a
Gitweb:     http://git.kernel.org/tip/2e422fd1e4b0a1c0ca11d360be2147c87911dd1a
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 23 Dec 2015 02:07:09 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Jan 2016 20:11:13 -0300

perf tools: Add 'trace_fields' dynamic sort key

The 'trace_fields' sort key is similar as 'trace' sort key, but it shows
each fields separately.  Each event will get different columns as their
fields.

  $ perf report -s trace_fields --stdio
  # To display the perf.data header info, please use --header/--header-only options.
  #
  #
  # Total Lost Samples: 0
  #
  # Samples: 20K of event 'kmem:kmalloc'
  # Event count (approx.): 20533
  #
  # Overhead  Command           call_site                 ptr  bytes_req  bytes_alloc            gfp_flags
  # ........  .......  ..................  ..................  .........  ...........  ...................
  #
      99.89%  perf       ffffffffa01d4396  0xffff8803ffb79720         96           96    GFP_NOFS|GFP_ZERO
       0.06%  sleep      ffffffff8114e1cd  0xffff8803d228a000       4096         4096           GFP_KERNEL
       0.03%  perf       ffffffff811d6ae6  0xffff8803f7678f00        240          256  GFP_KERNEL|GFP_ZERO
       0.00%  perf       ffffffff812263c1  0xffff880406172380        128          128           GFP_KERNEL
       0.00%  perf       ffffffff812264b9  0xffff8803ffac1600        504          512           GFP_KERNEL
       0.00%  perf       ffffffff81226634  0xffff880401dc5280         28           32           GFP_KERNEL
       0.00%  sleep      ffffffff81226da9  0xffff8803ffac3a00        392          512           GFP_KERNEL

  # Samples: 20K of event 'kmem:kfree'
  # Event count (approx.): 20597
  #
  # Overhead           call_site                 ptr
  # ........  ..................  ..................
  #
      99.58%    ffffffffa01d85ad  0xffff8803ffb79720
       0.07%    ffffffff81443f5c  0xffff8803f7669400
       0.02%    ffffffff811d5753  0xffff8803f7678f00
       0.01%    ffffffff81443f5c  0xffff8803f766be00
       0.01%    ffffffff8114e359  0xffff8803d228a000
       0.01%    ffffffff81443f5c  0xffff8800d156dc00
       0.01%    ffffffff81443f5c  0xffff8803f7669400
       0.01%    ffffffff8114e359  0xffff8803d228a000
       0.01%    ffffffff8114e359  0xffff8803d228a000
       0.01%    ffffffff8114e359  0xffff8803d228a000

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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-13-git-send-email-namhyung@kernel.org
[ Combined with "perf tools: Fix segfault when using -s trace_fields" ]
Link: http://lkml.kernel.org/r/1451991518-25673-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 47 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index fd56223..79aa71d 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1932,6 +1932,38 @@ static int __dynamic_dimension__add(struct perf_evsel *evsel,
 	return 0;
 }
 
+static int add_evsel_fields(struct perf_evsel *evsel, bool raw_trace)
+{
+	int ret;
+	struct format_field *field;
+
+	field = evsel->tp_format->format.fields;
+	while (field) {
+		ret = __dynamic_dimension__add(evsel, field, raw_trace);
+		if (ret < 0)
+			return ret;
+
+		field = field->next;
+	}
+	return 0;
+}
+
+static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace)
+{
+	int ret;
+	struct perf_evsel *evsel;
+
+	evlist__for_each(evlist, evsel) {
+		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
+			continue;
+
+		ret = add_evsel_fields(evsel, raw_trace);
+		if (ret < 0)
+			return ret;
+	}
+	return 0;
+}
+
 static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 {
 	char *str, *event_name, *field_name, *opt_name;
@@ -1961,6 +1993,11 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 		raw_trace = true;
 	}
 
+	if (!strcmp(field_name, "trace_fields")) {
+		ret = add_all_dynamic_fields(evlist, raw_trace);
+		goto out;
+	}
+
 	evsel = find_evsel(evlist, event_name);
 	if (evsel == NULL) {
 		pr_debug("Cannot find event: %s\n", event_name);
@@ -1975,15 +2012,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 	}
 
 	if (!strcmp(field_name, "*")) {
-		field = evsel->tp_format->format.fields;
-
-		while (field) {
-			ret = __dynamic_dimension__add(evsel, field, raw_trace);
-			if (ret < 0)
-				goto out;
-
-			field = field->next;
-		}
+		ret = add_evsel_fields(evsel, raw_trace);
 	} else {
 		field = pevent_find_any_field(evsel->tp_format, field_name);
 		if (field == NULL) {

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web