[PATCH 04/10] 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: Namhyung Kim --- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 14 +++--- tools/perf/tests/hists_cumulate.c | 8 tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 2 +- tools/perf/tests/hists_output.c | 10 +- tools/perf/util/sort.c| 15 +-- tools/perf/util/sort.h| 5 +++-- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b5b8db0b0338..cc5c1267c738 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) if (ret < 0) goto out_delete; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(annotate_usage, options); if (annotate.use_stdio) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 69f5b1feff39..87063835d741 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) sort__mode = SORT_MODE__DIFF; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(diff_usage, options); setup_pager(); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2a7330b99b82..ea53c816640a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -897,7 +897,7 @@ repeat: symbol_conf.cumulate_callchain = false; } - if (setup_sorting() < 0) { + if (setup_sorting(session->evlist) < 0) { if (sort_order) parse_options_usage(report_usage, options, "s", 1); if (field_order) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 9ebd67a42ede..005825942441 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1231,11 +1231,17 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (argc) usage_with_options(top_usage, options); + if (!top.evlist->nr_entries && + perf_evlist__add_default(top.evlist) < 0) { + pr_err("Not enough memory for event selector list\n"); + goto out_delete_evlist; + } + sort__mode = SORT_MODE__TOP; /* display thread wants entries to be collapsed in a different tree */ sort__need_collapse = 1; - if (setup_sorting() < 0) { + if (setup_sorting(top.evlist) < 0) { if (sort_order) parse_options_usage(top_usage, options, "s", 1); if (field_order) @@ -1277,12 +1283,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) goto out_delete_evlist; } - if (!top.evlist->nr_entries && - perf_evlist__add_default(top.evlist) < 0) { - ui__error("Not enough memory for event selector list\n"); - goto out_delete_evlist; - } - symbol_conf.nr_events = top.evlist->nr_entries; if (top.delay_secs < 1) diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 8292948bc5f9..e36089212061 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__set_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true;
[PATCH 04/10] 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: Namhyung Kim--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 14 +++--- tools/perf/tests/hists_cumulate.c | 8 tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 2 +- tools/perf/tests/hists_output.c | 10 +- tools/perf/util/sort.c| 15 +-- tools/perf/util/sort.h| 5 +++-- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b5b8db0b0338..cc5c1267c738 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) if (ret < 0) goto out_delete; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(annotate_usage, options); if (annotate.use_stdio) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 69f5b1feff39..87063835d741 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) sort__mode = SORT_MODE__DIFF; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(diff_usage, options); setup_pager(); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2a7330b99b82..ea53c816640a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -897,7 +897,7 @@ repeat: symbol_conf.cumulate_callchain = false; } - if (setup_sorting() < 0) { + if (setup_sorting(session->evlist) < 0) { if (sort_order) parse_options_usage(report_usage, options, "s", 1); if (field_order) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 9ebd67a42ede..005825942441 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1231,11 +1231,17 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (argc) usage_with_options(top_usage, options); + if (!top.evlist->nr_entries && + perf_evlist__add_default(top.evlist) < 0) { + pr_err("Not enough memory for event selector list\n"); + goto out_delete_evlist; + } + sort__mode = SORT_MODE__TOP; /* display thread wants entries to be collapsed in a different tree */ sort__need_collapse = 1; - if (setup_sorting() < 0) { + if (setup_sorting(top.evlist) < 0) { if (sort_order) parse_options_usage(top_usage, options, "s", 1); if (field_order) @@ -1277,12 +1283,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) goto out_delete_evlist; } - if (!top.evlist->nr_entries && - perf_evlist__add_default(top.evlist) < 0) { - ui__error("Not enough memory for event selector list\n"); - goto out_delete_evlist; - } - symbol_conf.nr_events = top.evlist->nr_entries; if (top.delay_secs < 1) diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 8292948bc5f9..e36089212061 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__set_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true;
[PATCH 04/10] 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: Namhyung Kim --- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 14 +++--- tools/perf/tests/hists_cumulate.c | 8 tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 2 +- tools/perf/tests/hists_output.c | 10 +- tools/perf/util/sort.c| 15 +-- tools/perf/util/sort.h| 5 +++-- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index e193340853ba..8ed582a44b39 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) if (ret < 0) goto out_delete; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(annotate_usage, options); if (annotate.use_stdio) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 69f5b1feff39..87063835d741 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) sort__mode = SORT_MODE__DIFF; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(diff_usage, options); setup_pager(); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 5a454669d075..3b8eb77d586d 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -897,7 +897,7 @@ repeat: symbol_conf.cumulate_callchain = false; } - if (setup_sorting() < 0) { + if (setup_sorting(session->evlist) < 0) { if (sort_order) parse_options_usage(report_usage, options, "s", 1); if (field_order) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 92fe963e43c4..feb9f5e1ef3d 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1231,11 +1231,17 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (argc) usage_with_options(top_usage, options); + if (!top.evlist->nr_entries && + perf_evlist__add_default(top.evlist) < 0) { + pr_err("Not enough memory for event selector list\n"); + goto out_delete_evlist; + } + sort__mode = SORT_MODE__TOP; /* display thread wants entries to be collapsed in a different tree */ sort__need_collapse = 1; - if (setup_sorting() < 0) { + if (setup_sorting(top.evlist) < 0) { if (sort_order) parse_options_usage(top_usage, options, "s", 1); if (field_order) @@ -1277,12 +1283,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) goto out_delete_evlist; } - if (!top.evlist->nr_entries && - perf_evlist__add_default(top.evlist) < 0) { - ui__error("Not enough memory for event selector list\n"); - goto out_delete_evlist; - } - symbol_conf.nr_events = top.evlist->nr_entries; if (top.delay_secs < 1) diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 8292948bc5f9..e36089212061 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__set_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true;
[PATCH 04/10] 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: Namhyung Kim--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 14 +++--- tools/perf/tests/hists_cumulate.c | 8 tools/perf/tests/hists_filter.c | 2 +- tools/perf/tests/hists_link.c | 2 +- tools/perf/tests/hists_output.c | 10 +- tools/perf/util/sort.c| 15 +-- tools/perf/util/sort.h| 5 +++-- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index e193340853ba..8ed582a44b39 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -370,7 +370,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) if (ret < 0) goto out_delete; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(annotate_usage, options); if (annotate.use_stdio) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 69f5b1feff39..87063835d741 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -1279,7 +1279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) sort__mode = SORT_MODE__DIFF; - if (setup_sorting() < 0) + if (setup_sorting(NULL) < 0) usage_with_options(diff_usage, options); setup_pager(); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 5a454669d075..3b8eb77d586d 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -897,7 +897,7 @@ repeat: symbol_conf.cumulate_callchain = false; } - if (setup_sorting() < 0) { + if (setup_sorting(session->evlist) < 0) { if (sort_order) parse_options_usage(report_usage, options, "s", 1); if (field_order) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 92fe963e43c4..feb9f5e1ef3d 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1231,11 +1231,17 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (argc) usage_with_options(top_usage, options); + if (!top.evlist->nr_entries && + perf_evlist__add_default(top.evlist) < 0) { + pr_err("Not enough memory for event selector list\n"); + goto out_delete_evlist; + } + sort__mode = SORT_MODE__TOP; /* display thread wants entries to be collapsed in a different tree */ sort__need_collapse = 1; - if (setup_sorting() < 0) { + if (setup_sorting(top.evlist) < 0) { if (sort_order) parse_options_usage(top_usage, options, "s", 1); if (field_order) @@ -1277,12 +1283,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) goto out_delete_evlist; } - if (!top.evlist->nr_entries && - perf_evlist__add_default(top.evlist) < 0) { - ui__error("Not enough memory for event selector list\n"); - goto out_delete_evlist; - } - symbol_conf.nr_events = top.evlist->nr_entries; if (top.delay_secs < 1) diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 8292948bc5f9..e36089212061 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -281,7 +281,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -428,7 +428,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = false; perf_evsel__set_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -486,7 +486,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true; perf_evsel__reset_sample_bit(evsel, CALLCHAIN); - setup_sorting(); + setup_sorting(NULL); callchain_register_param(_param); err = add_hist_entries(hists, machine); @@ -670,7 +670,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) symbol_conf.cumulate_callchain = true;