diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-08-22 09:58:38 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-24 07:11:19 -0400 |
commit | 2f3f9bcf000b2043a480e7cc0cae582559fb0f13 (patch) | |
tree | bccd5beceef431d76bfa32dc0cb00ee48a69916c /tools | |
parent | 3969cc094a9dbb40e624b259caa73c7a2056b249 (diff) |
perf tools: Add +field argument support for --field option
Adding support to add field(s) to default field order via using the '+'
prefix, like for report:
$ perf report
Samples: 10 of event 'cycles', Event count (approx.): 4463799
Overhead Command Shared Object Symbol
32.40% ls [kernel.kallsyms] [k] filemap_fault
28.19% ls [kernel.kallsyms] [k] get_page_from_freelist
23.38% ls [kernel.kallsyms] [k] enqueue_entity
15.04% ls [kernel.kallsyms] [k] mmap_region
$ perf report -F +period,sample
Samples: 10 of event 'cycles', Event count (approx.): 4463799
Overhead Period Samples Command Shared Object Symbol
32.40% 1446493 1 ls [kernel.kallsyms] [k] filemap_fault
28.19% 1258486 1 ls [kernel.kallsyms] [k] get_page_from_freelist
23.38% 1043754 1 ls [kernel.kallsyms] [k] enqueue_entity
15.04% 671160 1 ls [kernel.kallsyms] [k] mmap_region
Works in general for commands using --field option.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1408715919-25990-2-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 | 4 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 24 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 1 |
3 files changed, 22 insertions, 7 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 75eb6ac821f8..2af18376b077 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -452,7 +452,7 @@ void perf_hpp__init(void) | |||
452 | /* | 452 | /* |
453 | * If user specified field order, no need to setup default fields. | 453 | * If user specified field order, no need to setup default fields. |
454 | */ | 454 | */ |
455 | if (field_order) | 455 | if (is_strict_order(field_order)) |
456 | return; | 456 | return; |
457 | 457 | ||
458 | if (symbol_conf.cumulate_callchain) { | 458 | if (symbol_conf.cumulate_callchain) { |
@@ -519,7 +519,7 @@ void perf_hpp__column_disable(unsigned col) | |||
519 | 519 | ||
520 | void perf_hpp__cancel_cumulate(void) | 520 | void perf_hpp__cancel_cumulate(void) |
521 | { | 521 | { |
522 | if (field_order) | 522 | if (is_strict_order(field_order)) |
523 | return; | 523 | return; |
524 | 524 | ||
525 | perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC); | 525 | perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC); |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b4a805e5e440..1958637cf136 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -1453,7 +1453,7 @@ static int __setup_sorting(void) | |||
1453 | int ret = 0; | 1453 | int ret = 0; |
1454 | 1454 | ||
1455 | if (sort_keys == NULL) { | 1455 | if (sort_keys == NULL) { |
1456 | if (field_order) { | 1456 | if (is_strict_order(field_order)) { |
1457 | /* | 1457 | /* |
1458 | * If user specified field order but no sort order, | 1458 | * If user specified field order but no sort order, |
1459 | * we'll honor it and not add default sort orders. | 1459 | * we'll honor it and not add default sort orders. |
@@ -1639,23 +1639,36 @@ static void reset_dimensions(void) | |||
1639 | memory_sort_dimensions[i].taken = 0; | 1639 | memory_sort_dimensions[i].taken = 0; |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | bool is_strict_order(const char *order) | ||
1643 | { | ||
1644 | return order && (*order != '+'); | ||
1645 | } | ||
1646 | |||
1642 | static int __setup_output_field(void) | 1647 | static int __setup_output_field(void) |
1643 | { | 1648 | { |
1644 | char *tmp, *tok, *str; | 1649 | char *tmp, *tok, *str, *strp; |
1645 | int ret = 0; | 1650 | int ret = -EINVAL; |
1646 | 1651 | ||
1647 | if (field_order == NULL) | 1652 | if (field_order == NULL) |
1648 | return 0; | 1653 | return 0; |
1649 | 1654 | ||
1650 | reset_dimensions(); | 1655 | reset_dimensions(); |
1651 | 1656 | ||
1652 | str = strdup(field_order); | 1657 | strp = str = strdup(field_order); |
1653 | if (str == NULL) { | 1658 | if (str == NULL) { |
1654 | error("Not enough memory to setup output fields"); | 1659 | error("Not enough memory to setup output fields"); |
1655 | return -ENOMEM; | 1660 | return -ENOMEM; |
1656 | } | 1661 | } |
1657 | 1662 | ||
1658 | for (tok = strtok_r(str, ", ", &tmp); | 1663 | if (!is_strict_order(field_order)) |
1664 | strp++; | ||
1665 | |||
1666 | if (!strlen(strp)) { | ||
1667 | error("Invalid --fields key: `+'"); | ||
1668 | goto out; | ||
1669 | } | ||
1670 | |||
1671 | for (tok = strtok_r(strp, ", ", &tmp); | ||
1659 | tok; tok = strtok_r(NULL, ", ", &tmp)) { | 1672 | tok; tok = strtok_r(NULL, ", ", &tmp)) { |
1660 | ret = output_field_add(tok); | 1673 | ret = output_field_add(tok); |
1661 | if (ret == -EINVAL) { | 1674 | if (ret == -EINVAL) { |
@@ -1667,6 +1680,7 @@ static int __setup_output_field(void) | |||
1667 | } | 1680 | } |
1668 | } | 1681 | } |
1669 | 1682 | ||
1683 | out: | ||
1670 | free(str); | 1684 | free(str); |
1671 | return ret; | 1685 | return ret; |
1672 | } | 1686 | } |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 041f0c9cea2b..c03e4ff8beff 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -218,4 +218,5 @@ void perf_hpp__set_elide(int idx, bool elide); | |||
218 | 218 | ||
219 | int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset); | 219 | int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset); |
220 | 220 | ||
221 | bool is_strict_order(const char *order); | ||
221 | #endif /* __PERF_SORT_H */ | 222 | #endif /* __PERF_SORT_H */ |