diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-11 17:15:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-11 21:18:20 -0400 |
commit | e68ae9cf7d734e669bc0a981b4154f70d29b5059 (patch) | |
tree | ac9880166ffa3ca0745811c6c60b1089d0f94ebd | |
parent | 44621819ddc9d5d0bfd0b0616c6cf33c94189b67 (diff) |
perf evsel: Do not use globals in config()
Instead receive a callchain_param pointer to configure callchain
aspects, not doing so if NULL is passed.
This will allow fine grained control over which evsels in an evlist
gets callchains enabled.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-2mupip6khc92mh5x4nw9to82@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-kvm.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/bpf.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/code-reading.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/keep-tracking.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/openat-syscall-tp-fields.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/perf-record.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/switch-tracking.c | 2 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 5 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 7 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 5 | ||||
-rw-r--r-- | tools/perf/util/record.c | 5 |
15 files changed, 26 insertions, 18 deletions
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 9d29ee283ac5..d4aa567a29c4 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c | |||
@@ -71,7 +71,7 @@ int test__perf_time_to_tsc(int subtest __maybe_unused) | |||
71 | 71 | ||
72 | CHECK__(parse_events(evlist, "cycles:u", NULL)); | 72 | CHECK__(parse_events(evlist, "cycles:u", NULL)); |
73 | 73 | ||
74 | perf_evlist__config(evlist, &opts); | 74 | perf_evlist__config(evlist, &opts, NULL); |
75 | 75 | ||
76 | evsel = perf_evlist__first(evlist); | 76 | evsel = perf_evlist__first(evlist); |
77 | 77 | ||
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index bff666458b28..6487c06d2708 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -982,7 +982,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) | |||
982 | struct perf_evlist *evlist = kvm->evlist; | 982 | struct perf_evlist *evlist = kvm->evlist; |
983 | char sbuf[STRERR_BUFSIZE]; | 983 | char sbuf[STRERR_BUFSIZE]; |
984 | 984 | ||
985 | perf_evlist__config(evlist, &kvm->opts); | 985 | perf_evlist__config(evlist, &kvm->opts, NULL); |
986 | 986 | ||
987 | /* | 987 | /* |
988 | * Note: exclude_{guest,host} do not apply here. | 988 | * Note: exclude_{guest,host} do not apply here. |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e64bd1ee5acb..eb6a199a833c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -284,7 +284,7 @@ static int record__open(struct record *rec) | |||
284 | struct record_opts *opts = &rec->opts; | 284 | struct record_opts *opts = &rec->opts; |
285 | int rc = 0; | 285 | int rc = 0; |
286 | 286 | ||
287 | perf_evlist__config(evlist, opts); | 287 | perf_evlist__config(evlist, opts, &callchain_param); |
288 | 288 | ||
289 | evlist__for_each(evlist, pos) { | 289 | evlist__for_each(evlist, pos) { |
290 | try_again: | 290 | try_again: |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 833214979c4f..8846df0ec0c3 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -886,7 +886,7 @@ static int perf_top__start_counters(struct perf_top *top) | |||
886 | struct perf_evlist *evlist = top->evlist; | 886 | struct perf_evlist *evlist = top->evlist; |
887 | struct record_opts *opts = &top->record_opts; | 887 | struct record_opts *opts = &top->record_opts; |
888 | 888 | ||
889 | perf_evlist__config(evlist, opts); | 889 | perf_evlist__config(evlist, opts, &callchain_param); |
890 | 890 | ||
891 | evlist__for_each(evlist, counter) { | 891 | evlist__for_each(evlist, counter) { |
892 | try_again: | 892 | try_again: |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index cfa5ce8fdb7b..08fb100b91fa 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -2749,7 +2749,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
2749 | goto out_delete_evlist; | 2749 | goto out_delete_evlist; |
2750 | } | 2750 | } |
2751 | 2751 | ||
2752 | perf_evlist__config(evlist, &trace->opts); | 2752 | perf_evlist__config(evlist, &trace->opts, &callchain_param); |
2753 | 2753 | ||
2754 | signal(SIGCHLD, sig_handler); | 2754 | signal(SIGCHLD, sig_handler); |
2755 | signal(SIGINT, sig_handler); | 2755 | signal(SIGINT, sig_handler); |
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 199501c71e27..f31eed31c1a9 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c | |||
@@ -138,7 +138,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void), | |||
138 | perf_evlist__splice_list_tail(evlist, &parse_evlist.list); | 138 | perf_evlist__splice_list_tail(evlist, &parse_evlist.list); |
139 | evlist->nr_groups = parse_evlist.nr_groups; | 139 | evlist->nr_groups = parse_evlist.nr_groups; |
140 | 140 | ||
141 | perf_evlist__config(evlist, &opts); | 141 | perf_evlist__config(evlist, &opts, NULL); |
142 | 142 | ||
143 | err = perf_evlist__open(evlist); | 143 | err = perf_evlist__open(evlist); |
144 | if (err < 0) { | 144 | if (err < 0) { |
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index abd3f0ec0c0b..68a69a195545 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -532,7 +532,7 @@ static int do_test_code_reading(bool try_kcore) | |||
532 | goto out_put; | 532 | goto out_put; |
533 | } | 533 | } |
534 | 534 | ||
535 | perf_evlist__config(evlist, &opts); | 535 | perf_evlist__config(evlist, &opts, NULL); |
536 | 536 | ||
537 | evsel = perf_evlist__first(evlist); | 537 | evsel = perf_evlist__first(evlist); |
538 | 538 | ||
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index ddb78fae064a..614e45a3c603 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c | |||
@@ -80,7 +80,7 @@ int test__keep_tracking(int subtest __maybe_unused) | |||
80 | CHECK__(parse_events(evlist, "dummy:u", NULL)); | 80 | CHECK__(parse_events(evlist, "dummy:u", NULL)); |
81 | CHECK__(parse_events(evlist, "cycles:u", NULL)); | 81 | CHECK__(parse_events(evlist, "cycles:u", NULL)); |
82 | 82 | ||
83 | perf_evlist__config(evlist, &opts); | 83 | perf_evlist__config(evlist, &opts, NULL); |
84 | 84 | ||
85 | evsel = perf_evlist__first(evlist); | 85 | evsel = perf_evlist__first(evlist); |
86 | 86 | ||
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c index eb99a105f31c..4344fe482c1d 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c | |||
@@ -44,7 +44,7 @@ int test__syscall_openat_tp_fields(int subtest __maybe_unused) | |||
44 | goto out_delete_evlist; | 44 | goto out_delete_evlist; |
45 | } | 45 | } |
46 | 46 | ||
47 | perf_evsel__config(evsel, &opts); | 47 | perf_evsel__config(evsel, &opts, NULL); |
48 | 48 | ||
49 | thread_map__set_pid(evlist->threads, 0, getpid()); | 49 | thread_map__set_pid(evlist->threads, 0, getpid()); |
50 | 50 | ||
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 1cc78cefe399..b836ee6a8d9b 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c | |||
@@ -99,7 +99,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) | |||
99 | perf_evsel__set_sample_bit(evsel, CPU); | 99 | perf_evsel__set_sample_bit(evsel, CPU); |
100 | perf_evsel__set_sample_bit(evsel, TID); | 100 | perf_evsel__set_sample_bit(evsel, TID); |
101 | perf_evsel__set_sample_bit(evsel, TIME); | 101 | perf_evsel__set_sample_bit(evsel, TIME); |
102 | perf_evlist__config(evlist, &opts); | 102 | perf_evlist__config(evlist, &opts, NULL); |
103 | 103 | ||
104 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); | 104 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); |
105 | if (err < 0) { | 105 | if (err < 0) { |
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index ebd80168d51e..39a689bf7574 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c | |||
@@ -417,7 +417,7 @@ int test__switch_tracking(int subtest __maybe_unused) | |||
417 | perf_evsel__set_sample_bit(tracking_evsel, TIME); | 417 | perf_evsel__set_sample_bit(tracking_evsel, TIME); |
418 | 418 | ||
419 | /* Config events */ | 419 | /* Config events */ |
420 | perf_evlist__config(evlist, &opts); | 420 | perf_evlist__config(evlist, &opts, NULL); |
421 | 421 | ||
422 | /* Check moved event is still at the front */ | 422 | /* Check moved event is still at the front */ |
423 | if (cycles_evsel != perf_evlist__first(evlist)) { | 423 | if (cycles_evsel != perf_evlist__first(evlist)) { |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index a0d15221db6e..8db9228663d6 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -123,11 +123,14 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); | |||
123 | int perf_evlist__open(struct perf_evlist *evlist); | 123 | int perf_evlist__open(struct perf_evlist *evlist); |
124 | void perf_evlist__close(struct perf_evlist *evlist); | 124 | void perf_evlist__close(struct perf_evlist *evlist); |
125 | 125 | ||
126 | struct callchain_param; | ||
127 | |||
126 | void perf_evlist__set_id_pos(struct perf_evlist *evlist); | 128 | void perf_evlist__set_id_pos(struct perf_evlist *evlist); |
127 | bool perf_can_sample_identifier(void); | 129 | bool perf_can_sample_identifier(void); |
128 | bool perf_can_record_switch_events(void); | 130 | bool perf_can_record_switch_events(void); |
129 | bool perf_can_record_cpu_wide(void); | 131 | bool perf_can_record_cpu_wide(void); |
130 | void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts); | 132 | void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, |
133 | struct callchain_param *callchain); | ||
131 | int record_opts__config(struct record_opts *opts); | 134 | int record_opts__config(struct record_opts *opts); |
132 | 135 | ||
133 | int perf_evlist__prepare_workload(struct perf_evlist *evlist, | 136 | int perf_evlist__prepare_workload(struct perf_evlist *evlist, |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3fd7c2c72f4a..84252729222d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -737,7 +737,8 @@ static void apply_config_terms(struct perf_evsel *evsel, | |||
737 | * enable/disable events specifically, as there's no | 737 | * enable/disable events specifically, as there's no |
738 | * initial traced exec call. | 738 | * initial traced exec call. |
739 | */ | 739 | */ |
740 | void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) | 740 | void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, |
741 | struct callchain_param *callchain) | ||
741 | { | 742 | { |
742 | struct perf_evsel *leader = evsel->leader; | 743 | struct perf_evsel *leader = evsel->leader; |
743 | struct perf_event_attr *attr = &evsel->attr; | 744 | struct perf_event_attr *attr = &evsel->attr; |
@@ -812,8 +813,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) | |||
812 | if (perf_evsel__is_function_event(evsel)) | 813 | if (perf_evsel__is_function_event(evsel)) |
813 | evsel->attr.exclude_callchain_user = 1; | 814 | evsel->attr.exclude_callchain_user = 1; |
814 | 815 | ||
815 | if (callchain_param.enabled && !evsel->no_aux_samples) | 816 | if (callchain && callchain->enabled && !evsel->no_aux_samples) |
816 | perf_evsel__config_callgraph(evsel, opts, &callchain_param); | 817 | perf_evsel__config_callgraph(evsel, opts, callchain); |
817 | 818 | ||
818 | if (opts->sample_intr_regs) { | 819 | if (opts->sample_intr_regs) { |
819 | attr->sample_regs_intr = opts->sample_intr_regs; | 820 | attr->sample_regs_intr = opts->sample_intr_regs; |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index ab3632caba9f..7e45d2130a0f 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -178,8 +178,11 @@ void perf_evsel__init(struct perf_evsel *evsel, | |||
178 | void perf_evsel__exit(struct perf_evsel *evsel); | 178 | void perf_evsel__exit(struct perf_evsel *evsel); |
179 | void perf_evsel__delete(struct perf_evsel *evsel); | 179 | void perf_evsel__delete(struct perf_evsel *evsel); |
180 | 180 | ||
181 | struct callchain_param; | ||
182 | |||
181 | void perf_evsel__config(struct perf_evsel *evsel, | 183 | void perf_evsel__config(struct perf_evsel *evsel, |
182 | struct record_opts *opts); | 184 | struct record_opts *opts, |
185 | struct callchain_param *callchain); | ||
183 | 186 | ||
184 | int __perf_evsel__sample_size(u64 sample_type); | 187 | int __perf_evsel__sample_size(u64 sample_type); |
185 | void perf_evsel__calc_id_pos(struct perf_evsel *evsel); | 188 | void perf_evsel__calc_id_pos(struct perf_evsel *evsel); |
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 0467367dc315..481792c7484b 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -129,7 +129,8 @@ bool perf_can_record_cpu_wide(void) | |||
129 | return true; | 129 | return true; |
130 | } | 130 | } |
131 | 131 | ||
132 | void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts) | 132 | void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, |
133 | struct callchain_param *callchain) | ||
133 | { | 134 | { |
134 | struct perf_evsel *evsel; | 135 | struct perf_evsel *evsel; |
135 | bool use_sample_identifier = false; | 136 | bool use_sample_identifier = false; |
@@ -148,7 +149,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts) | |||
148 | use_comm_exec = perf_can_comm_exec(); | 149 | use_comm_exec = perf_can_comm_exec(); |
149 | 150 | ||
150 | evlist__for_each(evlist, evsel) { | 151 | evlist__for_each(evlist, evsel) { |
151 | perf_evsel__config(evsel, opts); | 152 | perf_evsel__config(evsel, opts, callchain); |
152 | if (evsel->tracking && use_comm_exec) | 153 | if (evsel->tracking && use_comm_exec) |
153 | evsel->attr.comm_exec = 1; | 154 | evsel->attr.comm_exec = 1; |
154 | } | 155 | } |