perf report/top: Add --raw-trace option
authorNamhyung Kim <namhyung@kernel.org>
Tue, 22 Dec 2015 17:07:05 +0000 (02:07 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 6 Jan 2016 23:11:12 +0000 (20:11 -0300)
The --raw-trace option allows disabling pretty printing by the event's
print_fmt or plugin.  Besides that, each dynamic sort key now can
receive a 'raw' suffix separated by '/' to ask for the raw trace of 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-and-Acked-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@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: Jiri Olsa <jolsa@redhat.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-9-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-report.txt
tools/perf/Documentation/perf-top.txt
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/util/sort.c
tools/perf/util/symbol.h

index dab99ed2b339c1af54bf15124057069e9c0e130e..ae7cd91727f6329774c89d75284b694ec5eb3355 100644 (file)
@@ -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
index 556cec09bf50cc4d5d9a50104d8efabd7879e2c7..b0e60e17db389d89efafa7025cd47fd44fe625c3 100644 (file)
@@ -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
 --------------------------
 
index ea53c816640a4b7c4316bd076ee265e222fcf8af..f10c663af99683f5081ee5319be9a554fedf1997 100644 (file)
@@ -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 = {
index 0058259424416f1b0d1f7ad3e78dad5749b1322b..bf01cbb0ef2369f2fc904809b86b70a823bdb604 100644 (file)
@@ -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[] = {
index db8476a9b1032915d35d0c2cc3002339e4ea9491..34776854626ebac46ce71a01ea366e2f53d03d43 100644 (file)
@@ -459,7 +459,12 @@ 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) {
+               pevent_print_fields(&seq, he->raw_data, he->raw_size,
+                                   evsel->tp_format);
+       } else {
+               pevent_event_info(&seq, evsel->tp_format, &rec);
+       }
        return seq.buffer;
 }
 
@@ -1596,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)
@@ -1628,6 +1634,9 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde,
        size_t namelen;
        bool last = false;
 
+       if (hde->raw_trace)
+               return;
+
        /* parse pretty print result and update max length */
        if (!he->trace_output)
                he->trace_output = get_trace_output(he);
@@ -1708,8 +1717,10 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
        if (hists_to_evsel(he->hists) != hde->evsel)
                return scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, "N/A");
 
-       field = hde->field;
+       if (hde->raw_trace)
+               goto raw_field;
 
+       field = hde->field;
        namelen = strlen(field->name);
        str = he->trace_output;
 
@@ -1738,6 +1749,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 
        if (str == NULL) {
                struct trace_seq seq;
+raw_field:
                trace_seq_init(&seq);
                pevent_print_field(&seq, he->raw_data, hde->field);
                str = seq.buffer;
@@ -1818,10 +1830,11 @@ __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 format_field *field;
        struct hpp_dynamic_entry *hde;
+       bool raw_trace = symbol_conf.raw_trace;
        int ret = 0;
 
        if (evlist == NULL)
@@ -1839,6 +1852,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)) {
@@ -1872,6 +1897,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);
 
index 857f707ac12bb0b6c27f056567d790ab0e76bb21..ccd1caa40e116645be37025665388886d7c97546 100644 (file)
@@ -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,