diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-01-07 04:14:08 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-08 10:58:58 -0500 |
commit | b97511c5bc94ef12613f485ab82f989df04088da (patch) | |
tree | a53c185595b774c9ec2ba6416a16a861738cdd3c /tools | |
parent | bb4ced29f5d5ff1d4d51b602dad34a0d15495a67 (diff) |
perf tools: Add overhead/overhead_children keys defaults via string
We currently set 'overhead' and 'overhead_children' as default sort keys
within perf_hpp__init function by directly adding into the sort list.
This patch adds 'overhead' and 'overhead_children' in text form into
sort_keys and let them be added by standard sort dimension interface.
We need to eliminate dirrect sort_list additions to be able to add
support for hists specific sort keys.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Noel Grandin <noelgrandin@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1452158050-28061-12-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/ui/hist.c | 12 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 39 |
2 files changed, 39 insertions, 12 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 8263c0eb9fb5..bf2a66e254ea 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -443,7 +443,6 @@ LIST_HEAD(perf_hpp__sort_list); | |||
443 | 443 | ||
444 | void perf_hpp__init(void) | 444 | void perf_hpp__init(void) |
445 | { | 445 | { |
446 | struct list_head *list; | ||
447 | int i; | 446 | int i; |
448 | 447 | ||
449 | for (i = 0; i < PERF_HPP__MAX_INDEX; i++) { | 448 | for (i = 0; i < PERF_HPP__MAX_INDEX; i++) { |
@@ -484,17 +483,6 @@ void perf_hpp__init(void) | |||
484 | 483 | ||
485 | if (symbol_conf.show_total_period) | 484 | if (symbol_conf.show_total_period) |
486 | hpp_dimension__add_output(PERF_HPP__PERIOD); | 485 | hpp_dimension__add_output(PERF_HPP__PERIOD); |
487 | |||
488 | /* prepend overhead field for backward compatiblity. */ | ||
489 | list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list; | ||
490 | if (list_empty(list)) | ||
491 | list_add(list, &perf_hpp__sort_list); | ||
492 | |||
493 | if (symbol_conf.cumulate_callchain) { | ||
494 | list = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC].sort_list; | ||
495 | if (list_empty(list)) | ||
496 | list_add(list, &perf_hpp__sort_list); | ||
497 | } | ||
498 | } | 486 | } |
499 | 487 | ||
500 | void perf_hpp__column_register(struct perf_hpp_fmt *format) | 488 | void perf_hpp__column_register(struct perf_hpp_fmt *format) |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 04e2a5cb19e3..ec722346e6ff 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -2252,6 +2252,34 @@ static int setup_sort_order(struct perf_evlist *evlist) | |||
2252 | return 0; | 2252 | return 0; |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | /* | ||
2256 | * Adds 'pre,' prefix into 'str' is 'pre' is | ||
2257 | * not already part of 'str'. | ||
2258 | */ | ||
2259 | static char *prefix_if_not_in(const char *pre, char *str) | ||
2260 | { | ||
2261 | char *n; | ||
2262 | |||
2263 | if (!str || strstr(str, pre)) | ||
2264 | return str; | ||
2265 | |||
2266 | if (asprintf(&n, "%s,%s", pre, str) < 0) | ||
2267 | return NULL; | ||
2268 | |||
2269 | free(str); | ||
2270 | return n; | ||
2271 | } | ||
2272 | |||
2273 | static char *setup_overhead(char *keys) | ||
2274 | { | ||
2275 | keys = prefix_if_not_in("overhead", keys); | ||
2276 | |||
2277 | if (symbol_conf.cumulate_callchain) | ||
2278 | keys = prefix_if_not_in("overhead_children", keys); | ||
2279 | |||
2280 | return keys; | ||
2281 | } | ||
2282 | |||
2255 | static int __setup_sorting(struct perf_evlist *evlist) | 2283 | static int __setup_sorting(struct perf_evlist *evlist) |
2256 | { | 2284 | { |
2257 | char *tmp, *tok, *str; | 2285 | char *tmp, *tok, *str; |
@@ -2281,6 +2309,17 @@ static int __setup_sorting(struct perf_evlist *evlist) | |||
2281 | return -ENOMEM; | 2309 | return -ENOMEM; |
2282 | } | 2310 | } |
2283 | 2311 | ||
2312 | /* | ||
2313 | * Prepend overhead fields for backward compatibility. | ||
2314 | */ | ||
2315 | if (!is_strict_order(field_order)) { | ||
2316 | str = setup_overhead(str); | ||
2317 | if (str == NULL) { | ||
2318 | error("Not enough memory to setup overhead keys"); | ||
2319 | return -ENOMEM; | ||
2320 | } | ||
2321 | } | ||
2322 | |||
2284 | for (tok = strtok_r(str, ", ", &tmp); | 2323 | for (tok = strtok_r(str, ", ", &tmp); |
2285 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | 2324 | tok; tok = strtok_r(NULL, ", ", &tmp)) { |
2286 | ret = sort_dimension__add(tok, evlist); | 2325 | ret = sort_dimension__add(tok, evlist); |