public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Andi Kleen <andi@firstfloor.org>, Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 08/10] perf tools: Add --raw-trace option
Date: Wed, 16 Dec 2015 00:35:41 +0900	[thread overview]
Message-ID: <1450193743-4409-9-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1450193743-4409-1-git-send-email-namhyung@kernel.org>

The --raw-trace option is to prevent pretty printing by event's
print_fmt or plugin.  Besides that, each dynamic sort key now receives
'raw' suffix separated by '/' to apply the raw trace to a specific
field.

  $ perf report -s comm,kmem:kmalloc.gfp_flags
  ...
  # Overhead  Command            gfp_flags
  # ........  .......  ...................
  #
      99.89%  perf       GFP_NOFS|GFP_ZERO
       0.06%  sleep             GFP_KERNEL
       0.03%  perf     GFP_KERNEL|GFP_ZERO
       0.01%  perf              GFP_KERNEL

Now

  $ perf report -s comm,kmem:kmalloc.gfp_flags --raw-trace
or
  $ perf report -s comm,kmem:kmalloc.gfp_flags/raw
  ...
  # Overhead  Command   gfp_flags
  # ........  .......  ..........
  #
      99.89%  perf          32848
       0.06%  sleep           208
       0.03%  perf          32976
       0.01%  perf            208

Suggested-by: Jiri Olsa <jolsa@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-report.txt |  3 +++
 tools/perf/Documentation/perf-top.txt    |  3 +++
 tools/perf/builtin-report.c              |  2 ++
 tools/perf/builtin-top.c                 |  2 ++
 tools/perf/util/sort.c                   | 30 +++++++++++++++++++++++++++---
 tools/perf/util/symbol.h                 |  3 ++-
 6 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index dab99ed2b339..ae7cd91727f6 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -371,6 +371,9 @@ include::itrace.txt[]
 --socket-filter::
 	Only report the samples on the processor socket that match with this filter
 
+--raw-trace::
+	When displaying traceevent output, do not use print fmt or plugins.
+
 include::callchain-overhead-calculation.txt[]
 
 SEE ALSO
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 556cec09bf50..b0e60e17db38 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -230,6 +230,9 @@ Default is to monitor all CPUS.
 	The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
 	Note that this feature may not be available on all processors.
 
+--raw-trace::
+	When displaying traceevent output, do not use print fmt or plugins.
+
 INTERACTIVE PROMPTING KEYS
 --------------------------
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3b8eb77d586d..6138bd9d7402 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -788,6 +788,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "Show callgraph from reference event"),
 	OPT_INTEGER(0, "socket-filter", &report.socket_filter,
 		    "only show processor socket that match with this filter"),
+	OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace,
+		    "Show raw trace event output (do not use print fmt or plugins)"),
 	OPT_END()
 	};
 	struct perf_data_file file = {
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index feb9f5e1ef3d..2fc73c93fc62 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1210,6 +1210,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_CALLBACK('j', "branch-filter", &opts->branch_stack,
 		     "branch filter mask", "branch stack filter modes",
 		     parse_branch_stack),
+	OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace,
+		    "Show raw trace event output (do not use print fmt or plugins)"),
 	OPT_END()
 	};
 	const char * const top_usage[] = {
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index caa8d3c1f6f9..da65b07258bb 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -460,7 +460,11 @@ static char *get_trace_output(struct hist_entry *he)
 	evsel = hists_to_evsel(he->hists);
 
 	trace_seq_init(&seq);
-	pevent_event_info(&seq, evsel->tp_format, &rec);
+	if (symbol_conf.raw_trace)
+		print_event_fields(&seq, he->raw_data, he->raw_size,
+				   evsel->tp_format);
+	else
+		pevent_event_info(&seq, evsel->tp_format, &rec);
 	return seq.buffer;
 }
 
@@ -1597,6 +1601,7 @@ struct hpp_dynamic_entry {
 	struct perf_evsel *evsel;
 	struct format_field *field;
 	unsigned dynamic_len;
+	bool raw_trace;
 };
 
 static int hde_width(struct hpp_dynamic_entry *hde)
@@ -1634,7 +1639,7 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde,
 	};
 	size_t namelen;
 
-	if (he->dynlen_updated)
+	if (he->dynlen_updated || hde->raw_trace)
 		return;
 
 	/* parse pretty print result and update max length */
@@ -1717,6 +1722,10 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 
 	field = hde->field;
 	trace_seq_init(&seq);
+
+	if (hde->raw_trace)
+		goto raw_field;
+
 	pevent_event_info(&seq, field->event, &rec);
 
 	namelen = strlen(field->name);
@@ -1731,6 +1740,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 	}
 
 	if (str == NULL) {
+raw_field:
 		trace_seq_reset(&seq);
 		print_event_field(&seq, he->raw_data, hde->field);
 		str = seq.buffer;
@@ -1811,11 +1821,12 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)
 
 static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 {
-	char *str, *event_name, *field_name;
+	char *str, *event_name, *field_name, *raw_opt;
 	struct perf_evsel *evsel, *pos;
 	struct event_format *format;
 	struct format_field *field;
 	struct hpp_dynamic_entry *hde;
+	bool raw_trace = symbol_conf.raw_trace;
 	int ret = 0;
 
 	if (evlist == NULL)
@@ -1833,6 +1844,18 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 	}
 	*field_name++ = '\0';
 
+	raw_opt = strchr(field_name, '/');
+	if (raw_opt) {
+		*raw_opt++ = '\0';
+
+		if (strcmp(raw_opt, "raw")) {
+			pr_err("Unsupported field option %s\n", raw_opt);
+			ret = -EINVAL;
+			goto out;
+		}
+		raw_trace = true;
+	}
+
 	evsel = NULL;
 	evlist__for_each(evlist, pos) {
 		if (!strcmp(pos->name, event_name)) {
@@ -1875,6 +1898,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
 		ret = -ENOMEM;
 		goto out;
 	}
+	hde->raw_trace = raw_trace;
 
 	perf_hpp__register_sort_field(&hde->hpp);
 
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 857f707ac12b..ccd1caa40e11 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -109,7 +109,8 @@ struct symbol_conf {
 			branch_callstack,
 			has_filter,
 			show_ref_callgraph,
-			hide_unresolved;
+			hide_unresolved,
+			raw_trace;
 	const char	*vmlinux_name,
 			*kallsyms_name,
 			*source_prefix,
-- 
2.6.4


  parent reply	other threads:[~2015-12-15 15:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 15:35 [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v2) Namhyung Kim
2015-12-15 15:35 ` [PATCH 01/10] perf hist: Pass struct sample to __hists__add_entry() Namhyung Kim
2015-12-15 15:35 ` [PATCH 02/10] perf hist: Save raw_data/size for tracepoint events Namhyung Kim
2015-12-17  8:14   ` [PATCH v2.1] " Namhyung Kim
2015-12-17 12:22     ` Arnaldo Carvalho de Melo
2015-12-15 15:35 ` [PATCH 03/10] tools lib traceevent: Factor out and export print_event_field[s] Namhyung Kim
2015-12-15 15:35 ` [PATCH 04/10] perf tools: Pass evlist to setup_sorting() Namhyung Kim
2015-12-15 15:35 ` [PATCH 05/10] perf tools: Add dynamic sort key for tracepoint events Namhyung Kim
2015-12-20 13:51   ` Jiri Olsa
2015-12-20 14:02     ` Namhyung Kim
2015-12-15 15:35 ` [PATCH 06/10] perf tools: Try to show pretty printed output for dynamic sort keys Namhyung Kim
2015-12-20 14:12   ` Jiri Olsa
2015-12-21  8:36     ` Namhyung Kim
2015-12-15 15:35 ` [PATCH 07/10] perf tools: Add 'trace' sort key Namhyung Kim
2015-12-15 15:35 ` Namhyung Kim [this message]
2015-12-20 14:58   ` [PATCH 08/10] perf tools: Add --raw-trace option Jiri Olsa
2015-12-21  8:44     ` Namhyung Kim
2015-12-22  6:57       ` Jiri Olsa
2015-12-22 16:19         ` Namhyung Kim
2015-12-15 15:35 ` [PATCH 09/10] perf tools: Make 'trace' sort key default for tracepoint events Namhyung Kim
2015-12-15 15:35 ` [PATCH 10/10] perf tools: Support shortcuts for events in dynamic sort keys Namhyung Kim
2015-12-17  0:17 ` [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v2) Arnaldo Carvalho de Melo
2015-12-17  7:56   ` Namhyung Kim
2015-12-17 12:21     ` Arnaldo Carvalho de Melo
  -- strict thread matches above, loose matches on Subject: below --
2015-12-21 14:26 [PATCHSET 00/10] perf tools: Support dynamic sort keys for tracepoints (v3) Namhyung Kim
2015-12-21 14:26 ` [PATCH 08/10] perf tools: Add --raw-trace option 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=1450193743-4409-9-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --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