perf machine: Rename perf_event__preprocess_sample to machine__resolve
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 22 Mar 2016 21:39:09 +0000 (18:39 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 23 Mar 2016 15:03:08 +0000 (12:03 -0300)
Since we only deal with fields in the passed struct perf_sample move
this method to struct machine, that is where the perf_sample fields
will be resolved to a struct addr_location, i.e. thread, map, symbol,
etc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-a1ww2lbm2vbuqsv4p7ilubu9@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
13 files changed:
tools/perf/builtin-annotate.c
tools/perf/builtin-diff.c
tools/perf/builtin-mem.c
tools/perf/builtin-report.c
tools/perf/builtin-script.c
tools/perf/builtin-timechart.c
tools/perf/builtin-top.c
tools/perf/tests/hists_cumulate.c
tools/perf/tests/hists_filter.c
tools/perf/tests/hists_link.c
tools/perf/tests/hists_output.c
tools/perf/util/event.c
tools/perf/util/event.h

index cfe366375c4b89bb3642f5531d04b418a8d76e56..814158393656ca5348e6272ebc30f9449e0edfce 100644 (file)
@@ -94,7 +94,7 @@ static int process_sample_event(struct perf_tool *tool,
        struct addr_location al;
        int ret = 0;
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
+       if (machine__resolve(machine, &al, sample) < 0) {
                pr_warning("problem processing %d event, skipping it.\n",
                           event->header.type);
                return -1;
index 4d72359fd15ad00ca7397bb033e84b4f899546c2..8053a8ceefdad28d3008de359190f3f043929267 100644 (file)
@@ -330,7 +330,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
        struct hists *hists = evsel__hists(evsel);
        int ret = -1;
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
+       if (machine__resolve(machine, &al, sample) < 0) {
                pr_warning("problem processing %d event, skipping it.\n",
                           event->header.type);
                return -1;
index 88aeac9aa1da12c664ec64ee419d6ce48c5ad8ec..85db3be4b3cb6365059adb3fea17dcf3e6700f77 100644 (file)
@@ -131,7 +131,7 @@ dump_raw_samples(struct perf_tool *tool,
        struct addr_location al;
        const char *fmt;
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
+       if (machine__resolve(machine, &al, sample) < 0) {
                fprintf(stderr, "problem processing %d event, skipping it.\n",
                                event->header.type);
                return -1;
index 7eea49f9ed46b520bdce56972379b76c14302c4b..ab47273a53732aa85c5f05a42f0587b3054a87c9 100644 (file)
@@ -154,7 +154,7 @@ static int process_sample_event(struct perf_tool *tool,
        };
        int ret = 0;
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
+       if (machine__resolve(machine, &al, sample) < 0) {
                pr_debug("problem processing %d event, skipping it.\n",
                         event->header.type);
                return -1;
index 928a4411e0235cf6fbe9647e65ef2c9c145211df..02a65d15c594785aeb9007e56b12edc4331f1ee7 100644 (file)
@@ -904,7 +904,7 @@ static int process_sample_event(struct perf_tool *tool,
                return 0;
        }
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
+       if (machine__resolve(machine, &al, sample) < 0) {
                pr_err("problem processing %d event, skipping it.\n",
                       event->header.type);
                return -1;
index bd7a7757176ff0461426903411e20339edc57416..40cc9bb3506c6d1b1625f2e37da795be36809ce3 100644 (file)
@@ -489,7 +489,7 @@ static const char *cat_backtrace(union perf_event *event,
        if (!chain)
                goto exit;
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
+       if (machine__resolve(machine, &al, sample) < 0) {
                fprintf(stderr, "problem processing %d event, skipping it.\n",
                        event->header.type);
                goto exit;
index a287800bc4950ab3ca052b041889c7d4448e0d67..9b0f2df2faa046508cd620d811e7bb7e770b8da1 100644 (file)
@@ -728,7 +728,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
        if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
                top->exact_samples++;
 
-       if (perf_event__preprocess_sample(event, machine, &al, sample) < 0)
+       if (machine__resolve(machine, &al, sample) < 0)
                return;
 
        if (!top->kptr_restrict_warned &&
index cf7eef73fbe64bf12c51358d087126aa79ccd444..ed5aa9eaeb6cf51d113e75620737641737a85fb6 100644 (file)
@@ -81,11 +81,6 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
        size_t i;
 
        for (i = 0; i < ARRAY_SIZE(fake_samples); i++) {
-               const union perf_event event = {
-                       .header = {
-                               .misc = PERF_RECORD_MISC_USER,
-                       },
-               };
                struct hist_entry_iter iter = {
                        .evsel = evsel,
                        .sample = &sample,
@@ -103,8 +98,7 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
                sample.ip = fake_samples[i].ip;
                sample.callchain = (struct ip_callchain *)fake_callchains[i];
 
-               if (perf_event__preprocess_sample(&event, machine, &al,
-                                                 &sample) < 0)
+               if (machine__resolve(machine, &al, &sample) < 0)
                        goto out;
 
                if (hist_entry_iter__add(&iter, &al, PERF_MAX_STACK_DEPTH,
index 1c9e19352cb6029966cc18d2fce187583f7e26e6..b825d24f81866b8756903ce8975beb74e932e326 100644 (file)
@@ -58,11 +58,6 @@ static int add_hist_entries(struct perf_evlist *evlist,
         */
        evlist__for_each(evlist, evsel) {
                for (i = 0; i < ARRAY_SIZE(fake_samples); i++) {
-                       const union perf_event event = {
-                               .header = {
-                                       .misc = PERF_RECORD_MISC_USER,
-                               },
-                       };
                        struct hist_entry_iter iter = {
                                .evsel = evsel,
                                .sample = &sample,
@@ -81,8 +76,7 @@ static int add_hist_entries(struct perf_evlist *evlist,
                        sample.tid = fake_samples[i].pid;
                        sample.ip = fake_samples[i].ip;
 
-                       if (perf_event__preprocess_sample(&event, machine, &al,
-                                                         &sample) < 0)
+                       if (machine__resolve(machine, &al, &sample) < 0)
                                goto out;
 
                        al.socket = fake_samples[i].socket;
index 7885b1d324e49750cbd7c632b4e11dc7240bdede..358324e47805e7f9a5210a70a6bfb99371dacd04 100644 (file)
@@ -76,18 +76,12 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
                struct hists *hists = evsel__hists(evsel);
 
                for (k = 0; k < ARRAY_SIZE(fake_common_samples); k++) {
-                       const union perf_event event = {
-                               .header = {
-                                       .misc = PERF_RECORD_MISC_USER,
-                               },
-                       };
-
                        sample.cpumode = PERF_RECORD_MISC_USER;
                        sample.pid = fake_common_samples[k].pid;
                        sample.tid = fake_common_samples[k].pid;
                        sample.ip = fake_common_samples[k].ip;
-                       if (perf_event__preprocess_sample(&event, machine, &al,
-                                                         &sample) < 0)
+
+                       if (machine__resolve(machine, &al, &sample) < 0)
                                goto out;
 
                        he = __hists__add_entry(hists, &al, NULL,
@@ -103,17 +97,10 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
                }
 
                for (k = 0; k < ARRAY_SIZE(fake_samples[i]); k++) {
-                       const union perf_event event = {
-                               .header = {
-                                       .misc = PERF_RECORD_MISC_USER,
-                               },
-                       };
-
                        sample.pid = fake_samples[i][k].pid;
                        sample.tid = fake_samples[i][k].pid;
                        sample.ip = fake_samples[i][k].ip;
-                       if (perf_event__preprocess_sample(&event, machine, &al,
-                                                         &sample) < 0)
+                       if (machine__resolve(machine, &al, &sample) < 0)
                                goto out;
 
                        he = __hists__add_entry(hists, &al, NULL,
index 03e4e9c47a553d1f6b212591bd11bb5c61aa21d5..d3556fbe8c5caeaa0dee938615417c64346e8551 100644 (file)
@@ -51,11 +51,6 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
        size_t i;
 
        for (i = 0; i < ARRAY_SIZE(fake_samples); i++) {
-               const union perf_event event = {
-                       .header = {
-                               .misc = PERF_RECORD_MISC_USER,
-                       },
-               };
                struct hist_entry_iter iter = {
                        .evsel = evsel,
                        .sample = &sample,
@@ -69,8 +64,7 @@ static int add_hist_entries(struct hists *hists, struct machine *machine)
                sample.tid = fake_samples[i].pid;
                sample.ip = fake_samples[i].ip;
 
-               if (perf_event__preprocess_sample(&event, machine, &al,
-                                                 &sample) < 0)
+               if (machine__resolve(machine, &al, &sample) < 0)
                        goto out;
 
                if (hist_entry_iter__add(&iter, &al, PERF_MAX_STACK_DEPTH,
index f679caac12d0ff1994cdd6235d2c3a407f4517d2..a89c29e2e0a97dc2b9c955e8f7ca5aa2ac70df9b 100644 (file)
@@ -1295,10 +1295,8 @@ void thread__find_addr_location(struct thread *thread,
  * Callers need to drop the reference to al->thread, obtained in
  * machine__findnew_thread()
  */
-int perf_event__preprocess_sample(const union perf_event *event __maybe_unused,
-                                 struct machine *machine,
-                                 struct addr_location *al,
-                                 struct perf_sample *sample)
+int machine__resolve(struct machine *machine, struct addr_location *al,
+                    struct perf_sample *sample)
 {
        struct thread *thread = machine__findnew_thread(machine, sample->pid,
                                                        sample->tid);
index f5a2e67c86aae385576f1ae224fe207d76fe46c5..22921fd0f5b8c44e2021f66dab513a6bf19b7d5e 100644 (file)
@@ -598,10 +598,8 @@ int perf_event__process(struct perf_tool *tool,
 
 struct addr_location;
 
-int perf_event__preprocess_sample(const union perf_event *event,
-                                 struct machine *machine,
-                                 struct addr_location *al,
-                                 struct perf_sample *sample);
+int machine__resolve(struct machine *machine, struct addr_location *al,
+                    struct perf_sample *sample);
 
 void addr_location__put(struct addr_location *al);