perf evsel: Adopt parse_sample method from perf_event
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 Aug 2012 15:23:46 +0000 (12:23 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 Aug 2012 15:23:46 +0000 (12:23 -0300)
Since we need evsel->{attr.{sample_{id_all,type}},sample_size},
reducing the number of parameters tools have to pass.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-wdtmgak0ihgsmw1brb54a8h4@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/event.h
tools/perf/util/evlist.c
tools/perf/util/evlist.h
tools/perf/util/evsel.c
tools/perf/util/evsel.h

index 1b197280c621fea866e3bfd90f71f3213971ee4a..d84870b0642627b11b81b5b5dc1c0abade1a09e4 100644 (file)
@@ -197,9 +197,6 @@ int perf_event__preprocess_sample(const union perf_event *self,
 
 const char *perf_event__name(unsigned int id);
 
-int perf_event__parse_sample(const union perf_event *event, u64 type,
-                            int sample_size, bool sample_id_all,
-                            struct perf_sample *sample, bool swapped);
 int perf_event__synthesize_sample(union perf_event *event, u64 type,
                                  const struct perf_sample *sample,
                                  bool swapped);
index 1a560e0904a5a4eb299a9d909e88dbaa969cbff2..9b38681add9e2d46e3a02b8ca0ffe48363a3e3c5 100644 (file)
@@ -882,11 +882,9 @@ int perf_evlist__start_workload(struct perf_evlist *evlist)
        return 0;
 }
 
-int perf_evlist__parse_sample(struct perf_evlist *evlist,
-                             const union perf_event *event,
+int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
                              struct perf_sample *sample, bool swapped)
 {
        struct perf_evsel *e = list_entry(evlist->entries.next, struct perf_evsel, node);
-       return perf_event__parse_sample(event, e->attr.sample_type, e->sample_size,
-                                       e->attr.sample_id_all, sample, swapped);
+       return perf_evsel__parse_sample(e, event, sample, swapped);
 }
index a5a49118a91a8e272f2c5ec7eabd73da63a2fa7b..528c1acd9298443ce37afee8a2f3be515f49adfe 100644 (file)
@@ -122,8 +122,7 @@ u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
 bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
 u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
 
-int perf_evlist__parse_sample(struct perf_evlist *evlist,
-                             const union perf_event *event,
+int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event,
                              struct perf_sample *sample, bool swapped);
 
 bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
index 8feec4011356693c4c4a37cd85e33475b56439ab..2eaae140def26b5ef952d814e47a1a3179d8abbb 100644 (file)
@@ -729,10 +729,10 @@ static bool sample_overlap(const union perf_event *event,
        return false;
 }
 
-int perf_event__parse_sample(const union perf_event *event, u64 type,
-                            int sample_size, bool sample_id_all,
+int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
                             struct perf_sample *data, bool swapped)
 {
+       u64 type = evsel->attr.sample_type;
        const u64 *array;
 
        /*
@@ -747,14 +747,14 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
        data->period = 1;
 
        if (event->header.type != PERF_RECORD_SAMPLE) {
-               if (!sample_id_all)
+               if (!evsel->attr.sample_id_all)
                        return 0;
                return perf_event__parse_id_sample(event, type, data, swapped);
        }
 
        array = event->sample.array;
 
-       if (sample_size + sizeof(event->header) > event->header.size)
+       if (evsel->sample_size + sizeof(event->header) > event->header.size)
                return -EFAULT;
 
        if (type & PERF_SAMPLE_IP) {
@@ -896,7 +896,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
                u.val32[1] = sample->tid;
                if (swapped) {
                        /*
-                        * Inverse of what is done in perf_event__parse_sample
+                        * Inverse of what is done in perf_evsel__parse_sample
                         */
                        u.val32[0] = bswap_32(u.val32[0]);
                        u.val32[1] = bswap_32(u.val32[1]);
@@ -931,7 +931,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
                u.val32[0] = sample->cpu;
                if (swapped) {
                        /*
-                        * Inverse of what is done in perf_event__parse_sample
+                        * Inverse of what is done in perf_evsel__parse_sample
                         */
                        u.val32[0] = bswap_32(u.val32[0]);
                        u.val64 = bswap_64(u.val64);
index 894bd77d90ccf466c13c40b56e6853e868529036..b559929983bbefd2e991fdf26e338fe588570a66 100644 (file)
@@ -180,4 +180,6 @@ static inline int perf_evsel__read_scaled(struct perf_evsel *evsel,
 
 void hists__init(struct hists *hists);
 
+int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
+                            struct perf_sample *sample, bool swapped);
 #endif /* __PERF_EVSEL_H */