Commit 3b099bf5 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Support '<event>.*' dynamic sort key

Support '*' character for field name to add all (non-common) fields as
sort keys easily.

  $ perf report -s 'switch.*' --stdio
  ...
  # Overhead    prev_comm  prev_pid   prev_prio  prev_state     next_comm  next_pid  next_prio
  # ........  ...........  .........  .........  ..........  ............  ........  .........
  #
       3.82%    swapper/0         0         120           0   netctl-auto     18711        120
       3.75%  netctl-auto     18711         120           1     swapper/0         0        120
       2.24%    swapper/1         0         120           0   netctl-auto     18709        120
       2.24%  netctl-auto     18709         120           1     swapper/1         0        120
       1.80%    swapper/2         0         120           0   rcu_preempt         7        120
       1.80%    swapper/2         0         120           0   netctl-auto     18711        120
       1.80%  rcu_preempt         7         120           1     swapper/2         0        120
       1.80%  netctl-auto     18711         120           1     swapper/2         0        120
  ...
Suggested-and-acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Tested-by: default avatarArnaldo 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-11-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5d0cff93
...@@ -1908,12 +1908,27 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam ...@@ -1908,12 +1908,27 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam
return evsel; return evsel;
} }
static int __dynamic_dimension__add(struct perf_evsel *evsel,
struct format_field *field,
bool raw_trace)
{
struct hpp_dynamic_entry *hde;
hde = __alloc_dynamic_entry(evsel, field);
if (hde == NULL)
return -ENOMEM;
hde->raw_trace = raw_trace;
perf_hpp__register_sort_field(&hde->hpp);
return 0;
}
static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
{ {
char *str, *event_name, *field_name, *opt_name; char *str, *event_name, *field_name, *opt_name;
struct perf_evsel *evsel; struct perf_evsel *evsel;
struct format_field *field; struct format_field *field;
struct hpp_dynamic_entry *hde;
bool raw_trace = symbol_conf.raw_trace; bool raw_trace = symbol_conf.raw_trace;
int ret = 0; int ret = 0;
...@@ -1951,22 +1966,26 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok) ...@@ -1951,22 +1966,26 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok)
goto out; goto out;
} }
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;
}
} else {
field = pevent_find_any_field(evsel->tp_format, field_name); field = pevent_find_any_field(evsel->tp_format, field_name);
if (field == NULL) { if (field == NULL) {
pr_debug("Cannot find event field for %s.%s\n", pr_debug("Cannot find event field for %s.%s\n",
event_name, field_name); event_name, field_name);
ret = -ENOENT; return -ENOENT;
goto out;
} }
hde = __alloc_dynamic_entry(evsel, field); ret = __dynamic_dimension__add(evsel, field, raw_trace);
if (hde == NULL) {
ret = -ENOMEM;
goto out;
} }
hde->raw_trace = raw_trace;
perf_hpp__register_sort_field(&hde->hpp);
out: out:
free(str); free(str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment