diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-09-22 21:01:41 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-09-26 11:40:33 -0400 |
commit | 72a128aa083a7f4cc4f800718aaae05d9c698e26 (patch) | |
tree | 9ae890a7d8bc073bca3d23159aa96562c7422e46 | |
parent | 72f72ed21e56c386dd92118e5da3ce06752b1614 (diff) |
perf tools: Move callchain config from record_opts to callchain_param
So that all callchain config parameters can be read/written to a single
place. It's a preparation to consolidate handling of all callchain
options.
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Milian Wolff <mail@milianw.de>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1411434104-5307-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 45 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 4 | ||||
-rw-r--r-- | tools/perf/perf.h | 3 | ||||
-rw-r--r-- | tools/perf/util/callchain.h | 5 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 11 |
5 files changed, 30 insertions, 38 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 320b198b54dd..fde0df72beaa 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -652,7 +652,7 @@ static int get_stack_size(char *str, unsigned long *_size) | |||
652 | } | 652 | } |
653 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ | 653 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ |
654 | 654 | ||
655 | int record_parse_callchain(const char *arg, struct record_opts *opts) | 655 | int record_parse_callchain(const char *arg) |
656 | { | 656 | { |
657 | char *tok, *name, *saveptr = NULL; | 657 | char *tok, *name, *saveptr = NULL; |
658 | char *buf; | 658 | char *buf; |
@@ -672,7 +672,7 @@ int record_parse_callchain(const char *arg, struct record_opts *opts) | |||
672 | /* Framepointer style */ | 672 | /* Framepointer style */ |
673 | if (!strncmp(name, "fp", sizeof("fp"))) { | 673 | if (!strncmp(name, "fp", sizeof("fp"))) { |
674 | if (!strtok_r(NULL, ",", &saveptr)) { | 674 | if (!strtok_r(NULL, ",", &saveptr)) { |
675 | opts->call_graph = CALLCHAIN_FP; | 675 | callchain_param.record_mode = CALLCHAIN_FP; |
676 | ret = 0; | 676 | ret = 0; |
677 | } else | 677 | } else |
678 | pr_err("callchain: No more arguments " | 678 | pr_err("callchain: No more arguments " |
@@ -685,15 +685,15 @@ int record_parse_callchain(const char *arg, struct record_opts *opts) | |||
685 | const unsigned long default_stack_dump_size = 8192; | 685 | const unsigned long default_stack_dump_size = 8192; |
686 | 686 | ||
687 | ret = 0; | 687 | ret = 0; |
688 | opts->call_graph = CALLCHAIN_DWARF; | 688 | callchain_param.record_mode = CALLCHAIN_DWARF; |
689 | opts->stack_dump_size = default_stack_dump_size; | 689 | callchain_param.dump_size = default_stack_dump_size; |
690 | 690 | ||
691 | tok = strtok_r(NULL, ",", &saveptr); | 691 | tok = strtok_r(NULL, ",", &saveptr); |
692 | if (tok) { | 692 | if (tok) { |
693 | unsigned long size = 0; | 693 | unsigned long size = 0; |
694 | 694 | ||
695 | ret = get_stack_size(tok, &size); | 695 | ret = get_stack_size(tok, &size); |
696 | opts->stack_dump_size = size; | 696 | callchain_param.dump_size = size; |
697 | } | 697 | } |
698 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ | 698 | #endif /* HAVE_DWARF_UNWIND_SUPPORT */ |
699 | } else { | 699 | } else { |
@@ -708,61 +708,56 @@ int record_parse_callchain(const char *arg, struct record_opts *opts) | |||
708 | return ret; | 708 | return ret; |
709 | } | 709 | } |
710 | 710 | ||
711 | static void callchain_debug(struct record_opts *opts) | 711 | static void callchain_debug(void) |
712 | { | 712 | { |
713 | static const char *str[CALLCHAIN_MAX] = { "NONE", "FP", "DWARF" }; | 713 | static const char *str[CALLCHAIN_MAX] = { "NONE", "FP", "DWARF" }; |
714 | 714 | ||
715 | pr_debug("callchain: type %s\n", str[opts->call_graph]); | 715 | pr_debug("callchain: type %s\n", str[callchain_param.record_mode]); |
716 | 716 | ||
717 | if (opts->call_graph == CALLCHAIN_DWARF) | 717 | if (callchain_param.record_mode == CALLCHAIN_DWARF) |
718 | pr_debug("callchain: stack dump size %d\n", | 718 | pr_debug("callchain: stack dump size %d\n", |
719 | opts->stack_dump_size); | 719 | callchain_param.dump_size); |
720 | } | 720 | } |
721 | 721 | ||
722 | int record_parse_callchain_opt(const struct option *opt, | 722 | int record_parse_callchain_opt(const struct option *opt __maybe_unused, |
723 | const char *arg, | 723 | const char *arg, |
724 | int unset) | 724 | int unset) |
725 | { | 725 | { |
726 | struct record_opts *opts = opt->value; | ||
727 | int ret; | 726 | int ret; |
728 | 727 | ||
729 | opts->call_graph_enabled = !unset; | 728 | callchain_param.enabled = !unset; |
730 | 729 | ||
731 | /* --no-call-graph */ | 730 | /* --no-call-graph */ |
732 | if (unset) { | 731 | if (unset) { |
733 | opts->call_graph = CALLCHAIN_NONE; | 732 | callchain_param.record_mode = CALLCHAIN_NONE; |
734 | pr_debug("callchain: disabled\n"); | 733 | pr_debug("callchain: disabled\n"); |
735 | return 0; | 734 | return 0; |
736 | } | 735 | } |
737 | 736 | ||
738 | ret = record_parse_callchain(arg, opts); | 737 | ret = record_parse_callchain(arg); |
739 | if (!ret) | 738 | if (!ret) |
740 | callchain_debug(opts); | 739 | callchain_debug(); |
741 | 740 | ||
742 | return ret; | 741 | return ret; |
743 | } | 742 | } |
744 | 743 | ||
745 | int record_callchain_opt(const struct option *opt, | 744 | int record_callchain_opt(const struct option *opt __maybe_unused, |
746 | const char *arg __maybe_unused, | 745 | const char *arg __maybe_unused, |
747 | int unset __maybe_unused) | 746 | int unset __maybe_unused) |
748 | { | 747 | { |
749 | struct record_opts *opts = opt->value; | 748 | callchain_param.enabled = true; |
750 | 749 | ||
751 | opts->call_graph_enabled = !unset; | 750 | if (callchain_param.record_mode == CALLCHAIN_NONE) |
751 | callchain_param.record_mode = CALLCHAIN_FP; | ||
752 | 752 | ||
753 | if (opts->call_graph == CALLCHAIN_NONE) | 753 | callchain_debug(); |
754 | opts->call_graph = CALLCHAIN_FP; | ||
755 | |||
756 | callchain_debug(opts); | ||
757 | return 0; | 754 | return 0; |
758 | } | 755 | } |
759 | 756 | ||
760 | static int perf_record_config(const char *var, const char *value, void *cb) | 757 | static int perf_record_config(const char *var, const char *value, void *cb) |
761 | { | 758 | { |
762 | struct record *rec = cb; | ||
763 | |||
764 | if (!strcmp(var, "record.call-graph")) | 759 | if (!strcmp(var, "record.call-graph")) |
765 | return record_parse_callchain(value, &rec->opts); | 760 | return record_parse_callchain(value); |
766 | 761 | ||
767 | return perf_default_config(var, value, cb); | 762 | return perf_default_config(var, value, cb); |
768 | } | 763 | } |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 5c16ba2dcf08..f7003fc0c5f0 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -1020,10 +1020,8 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset) | |||
1020 | 1020 | ||
1021 | static int perf_top_config(const char *var, const char *value, void *cb) | 1021 | static int perf_top_config(const char *var, const char *value, void *cb) |
1022 | { | 1022 | { |
1023 | struct perf_top *top = cb; | ||
1024 | |||
1025 | if (!strcmp(var, "top.call-graph")) | 1023 | if (!strcmp(var, "top.call-graph")) |
1026 | return record_parse_callchain(value, &top->record_opts); | 1024 | return record_parse_callchain(value); |
1027 | if (!strcmp(var, "top.children")) { | 1025 | if (!strcmp(var, "top.children")) { |
1028 | symbol_conf.cumulate_callchain = perf_config_bool(var, value); | 1026 | symbol_conf.cumulate_callchain = perf_config_bool(var, value); |
1029 | return 0; | 1027 | return 0; |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 510c65f72858..220d44e44c1b 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -41,8 +41,6 @@ void pthread__unblock_sigwinch(void); | |||
41 | 41 | ||
42 | struct record_opts { | 42 | struct record_opts { |
43 | struct target target; | 43 | struct target target; |
44 | int call_graph; | ||
45 | bool call_graph_enabled; | ||
46 | bool group; | 44 | bool group; |
47 | bool inherit_stat; | 45 | bool inherit_stat; |
48 | bool no_buffering; | 46 | bool no_buffering; |
@@ -60,7 +58,6 @@ struct record_opts { | |||
60 | u64 branch_stack; | 58 | u64 branch_stack; |
61 | u64 default_interval; | 59 | u64 default_interval; |
62 | u64 user_interval; | 60 | u64 user_interval; |
63 | u16 stack_dump_size; | ||
64 | bool sample_transaction; | 61 | bool sample_transaction; |
65 | unsigned initial_delay; | 62 | unsigned initial_delay; |
66 | }; | 63 | }; |
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index da43619d6173..819ae4f61e08 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -54,6 +54,9 @@ enum chain_key { | |||
54 | }; | 54 | }; |
55 | 55 | ||
56 | struct callchain_param { | 56 | struct callchain_param { |
57 | bool enabled; | ||
58 | enum perf_call_graph_mode record_mode; | ||
59 | u32 dump_size; | ||
57 | enum chain_mode mode; | 60 | enum chain_mode mode; |
58 | u32 print_limit; | 61 | u32 print_limit; |
59 | double min_percent; | 62 | double min_percent; |
@@ -154,7 +157,7 @@ static inline void callchain_cursor_advance(struct callchain_cursor *cursor) | |||
154 | struct option; | 157 | struct option; |
155 | struct hist_entry; | 158 | struct hist_entry; |
156 | 159 | ||
157 | int record_parse_callchain(const char *arg, struct record_opts *opts); | 160 | int record_parse_callchain(const char *arg); |
158 | int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset); | 161 | int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset); |
159 | int record_callchain_opt(const struct option *opt, const char *arg, int unset); | 162 | int record_callchain_opt(const struct option *opt, const char *arg, int unset); |
160 | 163 | ||
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b38de5819323..e0868a901c4a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -503,20 +503,19 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size) | |||
503 | } | 503 | } |
504 | 504 | ||
505 | static void | 505 | static void |
506 | perf_evsel__config_callgraph(struct perf_evsel *evsel, | 506 | perf_evsel__config_callgraph(struct perf_evsel *evsel) |
507 | struct record_opts *opts) | ||
508 | { | 507 | { |
509 | bool function = perf_evsel__is_function_event(evsel); | 508 | bool function = perf_evsel__is_function_event(evsel); |
510 | struct perf_event_attr *attr = &evsel->attr; | 509 | struct perf_event_attr *attr = &evsel->attr; |
511 | 510 | ||
512 | perf_evsel__set_sample_bit(evsel, CALLCHAIN); | 511 | perf_evsel__set_sample_bit(evsel, CALLCHAIN); |
513 | 512 | ||
514 | if (opts->call_graph == CALLCHAIN_DWARF) { | 513 | if (callchain_param.record_mode == CALLCHAIN_DWARF) { |
515 | if (!function) { | 514 | if (!function) { |
516 | perf_evsel__set_sample_bit(evsel, REGS_USER); | 515 | perf_evsel__set_sample_bit(evsel, REGS_USER); |
517 | perf_evsel__set_sample_bit(evsel, STACK_USER); | 516 | perf_evsel__set_sample_bit(evsel, STACK_USER); |
518 | attr->sample_regs_user = PERF_REGS_MASK; | 517 | attr->sample_regs_user = PERF_REGS_MASK; |
519 | attr->sample_stack_user = opts->stack_dump_size; | 518 | attr->sample_stack_user = callchain_param.dump_size; |
520 | attr->exclude_callchain_user = 1; | 519 | attr->exclude_callchain_user = 1; |
521 | } else { | 520 | } else { |
522 | pr_info("Cannot use DWARF unwind for function trace event," | 521 | pr_info("Cannot use DWARF unwind for function trace event," |
@@ -625,8 +624,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) | |||
625 | attr->mmap_data = track; | 624 | attr->mmap_data = track; |
626 | } | 625 | } |
627 | 626 | ||
628 | if (opts->call_graph_enabled && !evsel->no_aux_samples) | 627 | if (callchain_param.enabled && !evsel->no_aux_samples) |
629 | perf_evsel__config_callgraph(evsel, opts); | 628 | perf_evsel__config_callgraph(evsel); |
630 | 629 | ||
631 | if (target__has_cpu(&opts->target)) | 630 | if (target__has_cpu(&opts->target)) |
632 | perf_evsel__set_sample_bit(evsel, CPU); | 631 | perf_evsel__set_sample_bit(evsel, CPU); |