Commit 40184c46 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Pass evlist to setup_sorting()

This is a preparation to support dynamic sort keys for tracepoint
events.  Dynamic sort keys can be created for specific fields in trace
events so it needs the event information.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1450804030-29193-5-git-send-email-namhyung@kernel.org
[ Moving the evlist creation earlier in top was split to a previous patch ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 54f8f403
...@@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
if (ret < 0) if (ret < 0)
goto out_delete; goto out_delete;
if (setup_sorting() < 0) if (setup_sorting(NULL) < 0)
usage_with_options(annotate_usage, options); usage_with_options(annotate_usage, options);
if (annotate.use_stdio) if (annotate.use_stdio)
......
...@@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
sort__mode = SORT_MODE__DIFF; sort__mode = SORT_MODE__DIFF;
if (setup_sorting() < 0) if (setup_sorting(NULL) < 0)
usage_with_options(diff_usage, options); usage_with_options(diff_usage, options);
setup_pager(); setup_pager();
......
...@@ -897,7 +897,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -897,7 +897,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
symbol_conf.cumulate_callchain = false; symbol_conf.cumulate_callchain = false;
} }
if (setup_sorting() < 0) { if (setup_sorting(session->evlist) < 0) {
if (sort_order) if (sort_order)
parse_options_usage(report_usage, options, "s", 1); parse_options_usage(report_usage, options, "s", 1);
if (field_order) if (field_order)
......
...@@ -1241,7 +1241,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -1241,7 +1241,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
/* display thread wants entries to be collapsed in a different tree */ /* display thread wants entries to be collapsed in a different tree */
sort__need_collapse = 1; sort__need_collapse = 1;
if (setup_sorting() < 0) { if (setup_sorting(top.evlist) < 0) {
if (sort_order) if (sort_order)
parse_options_usage(top_usage, options, "s", 1); parse_options_usage(top_usage, options, "s", 1);
if (field_order) if (field_order)
......
...@@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) ...@@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
symbol_conf.cumulate_callchain = false; symbol_conf.cumulate_callchain = false;
perf_evsel__reset_sample_bit(evsel, CALLCHAIN); perf_evsel__reset_sample_bit(evsel, CALLCHAIN);
setup_sorting(); setup_sorting(NULL);
callchain_register_param(&callchain_param); callchain_register_param(&callchain_param);
err = add_hist_entries(hists, machine); err = add_hist_entries(hists, machine);
...@@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) ...@@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
symbol_conf.cumulate_callchain = false; symbol_conf.cumulate_callchain = false;
perf_evsel__set_sample_bit(evsel, CALLCHAIN); perf_evsel__set_sample_bit(evsel, CALLCHAIN);
setup_sorting(); setup_sorting(NULL);
callchain_register_param(&callchain_param); callchain_register_param(&callchain_param);
err = add_hist_entries(hists, machine); err = add_hist_entries(hists, machine);
...@@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) ...@@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
symbol_conf.cumulate_callchain = true; symbol_conf.cumulate_callchain = true;
perf_evsel__reset_sample_bit(evsel, CALLCHAIN); perf_evsel__reset_sample_bit(evsel, CALLCHAIN);
setup_sorting(); setup_sorting(NULL);
callchain_register_param(&callchain_param); callchain_register_param(&callchain_param);
err = add_hist_entries(hists, machine); err = add_hist_entries(hists, machine);
...@@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) ...@@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
symbol_conf.cumulate_callchain = true; symbol_conf.cumulate_callchain = true;
perf_evsel__set_sample_bit(evsel, CALLCHAIN); perf_evsel__set_sample_bit(evsel, CALLCHAIN);
setup_sorting(); setup_sorting(NULL);
callchain_register_param(&callchain_param); callchain_register_param(&callchain_param);
err = add_hist_entries(hists, machine); err = add_hist_entries(hists, machine);
......
...@@ -122,7 +122,7 @@ int test__hists_filter(int subtest __maybe_unused) ...@@ -122,7 +122,7 @@ int test__hists_filter(int subtest __maybe_unused)
goto out; goto out;
/* default sort order (comm,dso,sym) will be used */ /* default sort order (comm,dso,sym) will be used */
if (setup_sorting() < 0) if (setup_sorting(NULL) < 0)
goto out; goto out;
machines__init(&machines); machines__init(&machines);
......
...@@ -294,7 +294,7 @@ int test__hists_link(int subtest __maybe_unused) ...@@ -294,7 +294,7 @@ int test__hists_link(int subtest __maybe_unused)
goto out; goto out;
/* default sort order (comm,dso,sym) will be used */ /* default sort order (comm,dso,sym) will be used */
if (setup_sorting() < 0) if (setup_sorting(NULL) < 0)
goto out; goto out;
machines__init(&machines); machines__init(&machines);
......
...@@ -134,7 +134,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) ...@@ -134,7 +134,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
field_order = NULL; field_order = NULL;
sort_order = NULL; /* equivalent to sort_order = "comm,dso,sym" */ sort_order = NULL; /* equivalent to sort_order = "comm,dso,sym" */
setup_sorting(); setup_sorting(NULL);
/* /*
* expected output: * expected output:
...@@ -236,7 +236,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) ...@@ -236,7 +236,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
field_order = "overhead,cpu"; field_order = "overhead,cpu";
sort_order = "pid"; sort_order = "pid";
setup_sorting(); setup_sorting(NULL);
/* /*
* expected output: * expected output:
...@@ -292,7 +292,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) ...@@ -292,7 +292,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
field_order = "comm,overhead,dso"; field_order = "comm,overhead,dso";
sort_order = NULL; sort_order = NULL;
setup_sorting(); setup_sorting(NULL);
/* /*
* expected output: * expected output:
...@@ -366,7 +366,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) ...@@ -366,7 +366,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
field_order = "dso,sym,comm,overhead,dso"; field_order = "dso,sym,comm,overhead,dso";
sort_order = "sym"; sort_order = "sym";
setup_sorting(); setup_sorting(NULL);
/* /*
* expected output: * expected output:
...@@ -468,7 +468,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine) ...@@ -468,7 +468,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine)
field_order = "cpu,pid,comm,dso,sym"; field_order = "cpu,pid,comm,dso,sym";
sort_order = "dso,pid"; sort_order = "dso,pid";
setup_sorting(); setup_sorting(NULL);
/* /*
* expected output: * expected output:
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "comm.h" #include "comm.h"
#include "symbol.h" #include "symbol.h"
#include "evsel.h" #include "evsel.h"
#include "evlist.h"
#include <traceevent/event-parse.h>
regex_t parent_regex; regex_t parent_regex;
const char default_parent_pattern[] = "^sys_|^do_page_fault"; const char default_parent_pattern[] = "^sys_|^do_page_fault";
...@@ -1583,7 +1585,8 @@ int hpp_dimension__add_output(unsigned col) ...@@ -1583,7 +1585,8 @@ int hpp_dimension__add_output(unsigned col)
return __hpp_dimension__add_output(&hpp_sort_dimensions[col]); return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
} }
int sort_dimension__add(const char *tok) static int sort_dimension__add(const char *tok,
struct perf_evlist *evlist __maybe_unused)
{ {
unsigned int i; unsigned int i;
...@@ -1712,7 +1715,7 @@ static int setup_sort_order(void) ...@@ -1712,7 +1715,7 @@ static int setup_sort_order(void)
return 0; return 0;
} }
static int __setup_sorting(void) static int __setup_sorting(struct perf_evlist *evlist)
{ {
char *tmp, *tok, *str; char *tmp, *tok, *str;
const char *sort_keys; const char *sort_keys;
...@@ -1743,7 +1746,7 @@ static int __setup_sorting(void) ...@@ -1743,7 +1746,7 @@ static int __setup_sorting(void)
for (tok = strtok_r(str, ", ", &tmp); for (tok = strtok_r(str, ", ", &tmp);
tok; tok = strtok_r(NULL, ", ", &tmp)) { tok; tok = strtok_r(NULL, ", ", &tmp)) {
ret = sort_dimension__add(tok); ret = sort_dimension__add(tok, evlist);
if (ret == -EINVAL) { if (ret == -EINVAL) {
error("Invalid --sort key: `%s'", tok); error("Invalid --sort key: `%s'", tok);
break; break;
...@@ -1954,16 +1957,16 @@ static int __setup_output_field(void) ...@@ -1954,16 +1957,16 @@ static int __setup_output_field(void)
return ret; return ret;
} }
int setup_sorting(void) int setup_sorting(struct perf_evlist *evlist)
{ {
int err; int err;
err = __setup_sorting(); err = __setup_sorting(evlist);
if (err < 0) if (err < 0)
return err; return err;
if (parent_pattern != default_parent_pattern) { if (parent_pattern != default_parent_pattern) {
err = sort_dimension__add("parent"); err = sort_dimension__add("parent", evlist);
if (err < 0) if (err < 0)
return err; return err;
} }
......
...@@ -226,10 +226,11 @@ struct sort_entry { ...@@ -226,10 +226,11 @@ struct sort_entry {
extern struct sort_entry sort_thread; extern struct sort_entry sort_thread;
extern struct list_head hist_entry__sort_list; extern struct list_head hist_entry__sort_list;
int setup_sorting(void); struct perf_evlist;
struct pevent;
int setup_sorting(struct perf_evlist *evlist);
int setup_output_field(void); int setup_output_field(void);
void reset_output_field(void); void reset_output_field(void);
extern int sort_dimension__add(const char *);
void sort__setup_elide(FILE *fp); void sort__setup_elide(FILE *fp);
void perf_hpp__set_elide(int idx, bool elide); void perf_hpp__set_elide(int idx, bool elide);
......
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