perf evsel: Do not use globals in config()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Apr 2016 21:15:29 +0000 (18:15 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 12 Apr 2016 01:18:20 +0000 (22:18 -0300)
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>
15 files changed:
tools/perf/arch/x86/tests/perf-time-to-tsc.c
tools/perf/builtin-kvm.c
tools/perf/builtin-record.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/tests/bpf.c
tools/perf/tests/code-reading.c
tools/perf/tests/keep-tracking.c
tools/perf/tests/openat-syscall-tp-fields.c
tools/perf/tests/perf-record.c
tools/perf/tests/switch-tracking.c
tools/perf/util/evlist.h
tools/perf/util/evsel.c
tools/perf/util/evsel.h
tools/perf/util/record.c

index 9d29ee283ac5334bfd6a529c7a9d226f0db782cd..d4aa567a29c4685ece1fb142577322ba9e57c890 100644 (file)
@@ -71,7 +71,7 @@ int test__perf_time_to_tsc(int subtest __maybe_unused)
 
        CHECK__(parse_events(evlist, "cycles:u", NULL));
 
-       perf_evlist__config(evlist, &opts);
+       perf_evlist__config(evlist, &opts, NULL);
 
        evsel = perf_evlist__first(evlist);
 
index bff666458b28e24dccac682d0f28b6708a1a7c83..6487c06d270853fdf3c0e3a101f821d5692871a6 100644 (file)
@@ -982,7 +982,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
        struct perf_evlist *evlist = kvm->evlist;
        char sbuf[STRERR_BUFSIZE];
 
-       perf_evlist__config(evlist, &kvm->opts);
+       perf_evlist__config(evlist, &kvm->opts, NULL);
 
        /*
         * Note: exclude_{guest,host} do not apply here.
index e64bd1ee5acb2384fc318780c69432bbd65cd827..eb6a199a833c29fd3f8ef47bfbc233d36137a4a7 100644 (file)
@@ -284,7 +284,7 @@ static int record__open(struct record *rec)
        struct record_opts *opts = &rec->opts;
        int rc = 0;
 
-       perf_evlist__config(evlist, opts);
+       perf_evlist__config(evlist, opts, &callchain_param);
 
        evlist__for_each(evlist, pos) {
 try_again:
index 833214979c4f49c7e211ecef49d8e4833635ad41..8846df0ec0c3f23ac1e0d1ff291904aae5131bc2 100644 (file)
@@ -886,7 +886,7 @@ static int perf_top__start_counters(struct perf_top *top)
        struct perf_evlist *evlist = top->evlist;
        struct record_opts *opts = &top->record_opts;
 
-       perf_evlist__config(evlist, opts);
+       perf_evlist__config(evlist, opts, &callchain_param);
 
        evlist__for_each(evlist, counter) {
 try_again:
index cfa5ce8fdb7bf881151282ef58490b5591eadbf5..08fb100b91fa5c3ef289cd938735c946f8246a23 100644 (file)
@@ -2749,7 +2749,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
                goto out_delete_evlist;
        }
 
-       perf_evlist__config(evlist, &trace->opts);
+       perf_evlist__config(evlist, &trace->opts, &callchain_param);
 
        signal(SIGCHLD, sig_handler);
        signal(SIGINT, sig_handler);
index 199501c71e272491850065910aae5003603ab10e..f31eed31c1a9cff8e8307a1f06c3013329871ec6 100644 (file)
@@ -138,7 +138,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
        perf_evlist__splice_list_tail(evlist, &parse_evlist.list);
        evlist->nr_groups = parse_evlist.nr_groups;
 
-       perf_evlist__config(evlist, &opts);
+       perf_evlist__config(evlist, &opts, NULL);
 
        err = perf_evlist__open(evlist);
        if (err < 0) {
index abd3f0ec0c0b8e61c6371df1077e1fb2240e068e..68a69a195545e16bfd0913f1da56c88131734f5f 100644 (file)
@@ -532,7 +532,7 @@ static int do_test_code_reading(bool try_kcore)
                        goto out_put;
                }
 
-               perf_evlist__config(evlist, &opts);
+               perf_evlist__config(evlist, &opts, NULL);
 
                evsel = perf_evlist__first(evlist);
 
index ddb78fae064a50ca1d43476b29c7b5ff7ee2e7b3..614e45a3c6038099fd9fe6b838db0f1988d20855 100644 (file)
@@ -80,7 +80,7 @@ int test__keep_tracking(int subtest __maybe_unused)
        CHECK__(parse_events(evlist, "dummy:u", NULL));
        CHECK__(parse_events(evlist, "cycles:u", NULL));
 
-       perf_evlist__config(evlist, &opts);
+       perf_evlist__config(evlist, &opts, NULL);
 
        evsel = perf_evlist__first(evlist);
 
index eb99a105f31ce60b6d16123c92524e2f436eb71b..4344fe482c1d2f9a9dec676e236d3200e372e78f 100644 (file)
@@ -44,7 +44,7 @@ int test__syscall_openat_tp_fields(int subtest __maybe_unused)
                goto out_delete_evlist;
        }
 
-       perf_evsel__config(evsel, &opts);
+       perf_evsel__config(evsel, &opts, NULL);
 
        thread_map__set_pid(evlist->threads, 0, getpid());
 
index 1cc78cefe3990906d8195c43c4d6971e630ddc42..b836ee6a8d9bb6a676f65bcfa5243fef840c73e0 100644 (file)
@@ -99,7 +99,7 @@ int test__PERF_RECORD(int subtest __maybe_unused)
        perf_evsel__set_sample_bit(evsel, CPU);
        perf_evsel__set_sample_bit(evsel, TID);
        perf_evsel__set_sample_bit(evsel, TIME);
-       perf_evlist__config(evlist, &opts);
+       perf_evlist__config(evlist, &opts, NULL);
 
        err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask);
        if (err < 0) {
index ebd80168d51e853a29e0f34d93e4dad1812b417b..39a689bf7574e13010a59bf8dae7b748aa0b63c8 100644 (file)
@@ -417,7 +417,7 @@ int test__switch_tracking(int subtest __maybe_unused)
        perf_evsel__set_sample_bit(tracking_evsel, TIME);
 
        /* Config events */
-       perf_evlist__config(evlist, &opts);
+       perf_evlist__config(evlist, &opts, NULL);
 
        /* Check moved event is still at the front */
        if (cycles_evsel != perf_evlist__first(evlist)) {
index a0d15221db6e878412126f1ec5de08cb030f132f..8db9228663d6f8c47432ef2dcd60fc4ba6bbef70 100644 (file)
@@ -123,11 +123,14 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx);
 int perf_evlist__open(struct perf_evlist *evlist);
 void perf_evlist__close(struct perf_evlist *evlist);
 
+struct callchain_param;
+
 void perf_evlist__set_id_pos(struct perf_evlist *evlist);
 bool perf_can_sample_identifier(void);
 bool perf_can_record_switch_events(void);
 bool perf_can_record_cpu_wide(void);
-void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts);
+void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts,
+                        struct callchain_param *callchain);
 int record_opts__config(struct record_opts *opts);
 
 int perf_evlist__prepare_workload(struct perf_evlist *evlist,
index 3fd7c2c72f4adf5267995ad1ca850e6ae59205d3..84252729222d9844f0cbfac7756ee5fbb1c1e090 100644 (file)
@@ -737,7 +737,8 @@ static void apply_config_terms(struct perf_evsel *evsel,
  *     enable/disable events specifically, as there's no
  *     initial traced exec call.
  */
-void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
+void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
+                       struct callchain_param *callchain)
 {
        struct perf_evsel *leader = evsel->leader;
        struct perf_event_attr *attr = &evsel->attr;
@@ -812,8 +813,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
        if (perf_evsel__is_function_event(evsel))
                evsel->attr.exclude_callchain_user = 1;
 
-       if (callchain_param.enabled && !evsel->no_aux_samples)
-               perf_evsel__config_callgraph(evsel, opts, &callchain_param);
+       if (callchain && callchain->enabled && !evsel->no_aux_samples)
+               perf_evsel__config_callgraph(evsel, opts, callchain);
 
        if (opts->sample_intr_regs) {
                attr->sample_regs_intr = opts->sample_intr_regs;
index ab3632caba9f55bceb53614efea95ec6a35be76c..7e45d2130a0fd0e6397f5e2bfa11ee3107096ba7 100644 (file)
@@ -178,8 +178,11 @@ void perf_evsel__init(struct perf_evsel *evsel,
 void perf_evsel__exit(struct perf_evsel *evsel);
 void perf_evsel__delete(struct perf_evsel *evsel);
 
+struct callchain_param;
+
 void perf_evsel__config(struct perf_evsel *evsel,
-                       struct record_opts *opts);
+                       struct record_opts *opts,
+                       struct callchain_param *callchain);
 
 int __perf_evsel__sample_size(u64 sample_type);
 void perf_evsel__calc_id_pos(struct perf_evsel *evsel);
index 0467367dc31551122c47e0274e01ac48378c5a6e..481792c7484bd7109be072b6ea22f3fb8cf13089 100644 (file)
@@ -129,7 +129,8 @@ bool perf_can_record_cpu_wide(void)
        return true;
 }
 
-void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
+void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts,
+                        struct callchain_param *callchain)
 {
        struct perf_evsel *evsel;
        bool use_sample_identifier = false;
@@ -148,7 +149,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
        use_comm_exec = perf_can_comm_exec();
 
        evlist__for_each(evlist, evsel) {
-               perf_evsel__config(evsel, opts);
+               perf_evsel__config(evsel, opts, callchain);
                if (evsel->tracking && use_comm_exec)
                        evsel->attr.comm_exec = 1;
        }