diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-02 11:23:46 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-02 11:23:46 -0400 |
commit | a3f698fe3082ff80a7f3b27c9b64b4b748c81f9d (patch) | |
tree | 16fa9bf9b974893cff85ae38cb41ae9dec91f0c6 | |
parent | cb0b29e0861659c9eef9664772cd7e845ba1104a (diff) |
perf evsel: Adopt parse_sample method from perf_event
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>
-rw-r--r-- | tools/perf/util/event.h | 3 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 3 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 12 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 2 |
5 files changed, 11 insertions, 15 deletions
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 1b197280c621..d84870b06426 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -197,9 +197,6 @@ int perf_event__preprocess_sample(const union perf_event *self, | |||
197 | 197 | ||
198 | const char *perf_event__name(unsigned int id); | 198 | const char *perf_event__name(unsigned int id); |
199 | 199 | ||
200 | int perf_event__parse_sample(const union perf_event *event, u64 type, | ||
201 | int sample_size, bool sample_id_all, | ||
202 | struct perf_sample *sample, bool swapped); | ||
203 | int perf_event__synthesize_sample(union perf_event *event, u64 type, | 200 | int perf_event__synthesize_sample(union perf_event *event, u64 type, |
204 | const struct perf_sample *sample, | 201 | const struct perf_sample *sample, |
205 | bool swapped); | 202 | bool swapped); |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1a560e0904a5..9b38681add9e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -882,11 +882,9 @@ int perf_evlist__start_workload(struct perf_evlist *evlist) | |||
882 | return 0; | 882 | return 0; |
883 | } | 883 | } |
884 | 884 | ||
885 | int perf_evlist__parse_sample(struct perf_evlist *evlist, | 885 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
886 | const union perf_event *event, | ||
887 | struct perf_sample *sample, bool swapped) | 886 | struct perf_sample *sample, bool swapped) |
888 | { | 887 | { |
889 | struct perf_evsel *e = list_entry(evlist->entries.next, struct perf_evsel, node); | 888 | struct perf_evsel *e = list_entry(evlist->entries.next, struct perf_evsel, node); |
890 | return perf_event__parse_sample(event, e->attr.sample_type, e->sample_size, | 889 | return perf_evsel__parse_sample(e, event, sample, swapped); |
891 | e->attr.sample_id_all, sample, swapped); | ||
892 | } | 890 | } |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index a5a49118a91a..528c1acd9298 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -122,8 +122,7 @@ u64 perf_evlist__sample_type(const struct perf_evlist *evlist); | |||
122 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); | 122 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); |
123 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist); | 123 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist); |
124 | 124 | ||
125 | int perf_evlist__parse_sample(struct perf_evlist *evlist, | 125 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
126 | const union perf_event *event, | ||
127 | struct perf_sample *sample, bool swapped); | 126 | struct perf_sample *sample, bool swapped); |
128 | 127 | ||
129 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); | 128 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8feec4011356..2eaae140def2 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -729,10 +729,10 @@ static bool sample_overlap(const union perf_event *event, | |||
729 | return false; | 729 | return false; |
730 | } | 730 | } |
731 | 731 | ||
732 | int perf_event__parse_sample(const union perf_event *event, u64 type, | 732 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, |
733 | int sample_size, bool sample_id_all, | ||
734 | struct perf_sample *data, bool swapped) | 733 | struct perf_sample *data, bool swapped) |
735 | { | 734 | { |
735 | u64 type = evsel->attr.sample_type; | ||
736 | const u64 *array; | 736 | const u64 *array; |
737 | 737 | ||
738 | /* | 738 | /* |
@@ -747,14 +747,14 @@ int perf_event__parse_sample(const union perf_event *event, u64 type, | |||
747 | data->period = 1; | 747 | data->period = 1; |
748 | 748 | ||
749 | if (event->header.type != PERF_RECORD_SAMPLE) { | 749 | if (event->header.type != PERF_RECORD_SAMPLE) { |
750 | if (!sample_id_all) | 750 | if (!evsel->attr.sample_id_all) |
751 | return 0; | 751 | return 0; |
752 | return perf_event__parse_id_sample(event, type, data, swapped); | 752 | return perf_event__parse_id_sample(event, type, data, swapped); |
753 | } | 753 | } |
754 | 754 | ||
755 | array = event->sample.array; | 755 | array = event->sample.array; |
756 | 756 | ||
757 | if (sample_size + sizeof(event->header) > event->header.size) | 757 | if (evsel->sample_size + sizeof(event->header) > event->header.size) |
758 | return -EFAULT; | 758 | return -EFAULT; |
759 | 759 | ||
760 | if (type & PERF_SAMPLE_IP) { | 760 | if (type & PERF_SAMPLE_IP) { |
@@ -896,7 +896,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, | |||
896 | u.val32[1] = sample->tid; | 896 | u.val32[1] = sample->tid; |
897 | if (swapped) { | 897 | if (swapped) { |
898 | /* | 898 | /* |
899 | * Inverse of what is done in perf_event__parse_sample | 899 | * Inverse of what is done in perf_evsel__parse_sample |
900 | */ | 900 | */ |
901 | u.val32[0] = bswap_32(u.val32[0]); | 901 | u.val32[0] = bswap_32(u.val32[0]); |
902 | u.val32[1] = bswap_32(u.val32[1]); | 902 | u.val32[1] = bswap_32(u.val32[1]); |
@@ -931,7 +931,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, | |||
931 | u.val32[0] = sample->cpu; | 931 | u.val32[0] = sample->cpu; |
932 | if (swapped) { | 932 | if (swapped) { |
933 | /* | 933 | /* |
934 | * Inverse of what is done in perf_event__parse_sample | 934 | * Inverse of what is done in perf_evsel__parse_sample |
935 | */ | 935 | */ |
936 | u.val32[0] = bswap_32(u.val32[0]); | 936 | u.val32[0] = bswap_32(u.val32[0]); |
937 | u.val64 = bswap_64(u.val64); | 937 | u.val64 = bswap_64(u.val64); |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 894bd77d90cc..b559929983bb 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -180,4 +180,6 @@ static inline int perf_evsel__read_scaled(struct perf_evsel *evsel, | |||
180 | 180 | ||
181 | void hists__init(struct hists *hists); | 181 | void hists__init(struct hists *hists); |
182 | 182 | ||
183 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, | ||
184 | struct perf_sample *sample, bool swapped); | ||
183 | #endif /* __PERF_EVSEL_H */ | 185 | #endif /* __PERF_EVSEL_H */ |