diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-26 11:48:18 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-26 11:48:18 -0400 |
| commit | 0807d2d8a381f4fc600ad481c3e77e5cdb624eed (patch) | |
| tree | 3cd46552cea3e1a9c7c872250f790cb180f6cccf /tools | |
| parent | a14bb7a6fd4a3d563ca971daf462ba4dc294a7a6 (diff) | |
perf evsel: Know if byte swap is needed
Instead of passing it around for parsing as an explicit parameter, will
help with reading tracepoint fields when not using a perf session or
pevent structure, i.e. for non perf.data centered workflows.
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-qa67ikv2sm49cwa7dyjhhp6g@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/builtin-test.c | 4 | ||||
| -rw-r--r-- | tools/perf/builtin-top.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/evlist.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/evlist.h | 2 | ||||
| -rw-r--r-- | tools/perf/util/evsel.c | 13 | ||||
| -rw-r--r-- | tools/perf/util/evsel.h | 3 | ||||
| -rw-r--r-- | tools/perf/util/header.c | 6 | ||||
| -rw-r--r-- | tools/perf/util/python.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/session.c | 6 |
9 files changed, 24 insertions, 18 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 78b47a75a7c9..2fd2c031f627 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
| @@ -564,7 +564,7 @@ static int test__basic_mmap(void) | |||
| 564 | goto out_munmap; | 564 | goto out_munmap; |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | err = perf_evlist__parse_sample(evlist, event, &sample, false); | 567 | err = perf_evlist__parse_sample(evlist, event, &sample); |
| 568 | if (err) { | 568 | if (err) { |
| 569 | pr_err("Can't parse sample, err = %d\n", err); | 569 | pr_err("Can't parse sample, err = %d\n", err); |
| 570 | goto out_munmap; | 570 | goto out_munmap; |
| @@ -781,7 +781,7 @@ static int test__PERF_RECORD(void) | |||
| 781 | if (type < PERF_RECORD_MAX) | 781 | if (type < PERF_RECORD_MAX) |
| 782 | nr_events[type]++; | 782 | nr_events[type]++; |
| 783 | 783 | ||
| 784 | err = perf_evlist__parse_sample(evlist, event, &sample, false); | 784 | err = perf_evlist__parse_sample(evlist, event, &sample); |
| 785 | if (err < 0) { | 785 | if (err < 0) { |
| 786 | if (verbose) | 786 | if (verbose) |
| 787 | perf_event__fprintf(event, stderr); | 787 | perf_event__fprintf(event, stderr); |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 5550754c05f2..e434a16bb5ac 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -823,7 +823,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
| 823 | int ret; | 823 | int ret; |
| 824 | 824 | ||
| 825 | while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { | 825 | while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { |
| 826 | ret = perf_evlist__parse_sample(top->evlist, event, &sample, false); | 826 | ret = perf_evlist__parse_sample(top->evlist, event, &sample); |
| 827 | if (ret) { | 827 | if (ret) { |
| 828 | pr_err("Can't parse sample, err = %d\n", ret); | 828 | pr_err("Can't parse sample, err = %d\n", ret); |
| 829 | continue; | 829 | continue; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 27f6de3aab16..704bd91ce05d 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
| @@ -884,10 +884,10 @@ int perf_evlist__start_workload(struct perf_evlist *evlist) | |||
| 884 | } | 884 | } |
| 885 | 885 | ||
| 886 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, | 886 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
| 887 | struct perf_sample *sample, bool swapped) | 887 | struct perf_sample *sample) |
| 888 | { | 888 | { |
| 889 | struct perf_evsel *evsel = perf_evlist__first(evlist); | 889 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 890 | return perf_evsel__parse_sample(evsel, event, sample, swapped); | 890 | return perf_evsel__parse_sample(evsel, event, sample); |
| 891 | } | 891 | } |
| 892 | 892 | ||
| 893 | size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp) | 893 | size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp) |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 3f2e1e4ccdd5..008a95702bf7 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
| @@ -125,7 +125,7 @@ bool perf_evlist__sample_id_all(struct perf_evlist *evlist); | |||
| 125 | u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist); | 125 | u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist); |
| 126 | 126 | ||
| 127 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, | 127 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
| 128 | struct perf_sample *sample, bool swapped); | 128 | struct perf_sample *sample); |
| 129 | 129 | ||
| 130 | bool perf_evlist__valid_sample_type(struct perf_evlist *evlist); | 130 | bool perf_evlist__valid_sample_type(struct perf_evlist *evlist); |
| 131 | bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist); | 131 | bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist); |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2467eaf2968f..fe9581b0323c 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -767,11 +767,13 @@ int perf_evsel__open_per_thread(struct perf_evsel *evsel, | |||
| 767 | return __perf_evsel__open(evsel, &empty_cpu_map.map, threads); | 767 | return __perf_evsel__open(evsel, &empty_cpu_map.map, threads); |
| 768 | } | 768 | } |
| 769 | 769 | ||
| 770 | static int perf_event__parse_id_sample(const union perf_event *event, u64 type, | 770 | static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel, |
| 771 | struct perf_sample *sample, | 771 | const union perf_event *event, |
| 772 | bool swapped) | 772 | struct perf_sample *sample) |
| 773 | { | 773 | { |
| 774 | u64 type = evsel->attr.sample_type; | ||
| 774 | const u64 *array = event->sample.array; | 775 | const u64 *array = event->sample.array; |
| 776 | bool swapped = evsel->needs_swap; | ||
| 775 | union u64_swap u; | 777 | union u64_swap u; |
| 776 | 778 | ||
| 777 | array += ((event->header.size - | 779 | array += ((event->header.size - |
| @@ -832,10 +834,11 @@ static bool sample_overlap(const union perf_event *event, | |||
| 832 | } | 834 | } |
| 833 | 835 | ||
| 834 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, | 836 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, |
| 835 | struct perf_sample *data, bool swapped) | 837 | struct perf_sample *data) |
| 836 | { | 838 | { |
| 837 | u64 type = evsel->attr.sample_type; | 839 | u64 type = evsel->attr.sample_type; |
| 838 | u64 regs_user = evsel->attr.sample_regs_user; | 840 | u64 regs_user = evsel->attr.sample_regs_user; |
| 841 | bool swapped = evsel->needs_swap; | ||
| 839 | const u64 *array; | 842 | const u64 *array; |
| 840 | 843 | ||
| 841 | /* | 844 | /* |
| @@ -852,7 +855,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, | |||
| 852 | if (event->header.type != PERF_RECORD_SAMPLE) { | 855 | if (event->header.type != PERF_RECORD_SAMPLE) { |
| 853 | if (!evsel->attr.sample_id_all) | 856 | if (!evsel->attr.sample_id_all) |
| 854 | return 0; | 857 | return 0; |
| 855 | return perf_event__parse_id_sample(event, type, data, swapped); | 858 | return perf_evsel__parse_id_sample(evsel, event, data); |
| 856 | } | 859 | } |
| 857 | 860 | ||
| 858 | array = event->sample.array; | 861 | array = event->sample.array; |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index bb445d1cbc7b..60d28853748e 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
| @@ -69,6 +69,7 @@ struct perf_evsel { | |||
| 69 | struct cpu_map *cpus; | 69 | struct cpu_map *cpus; |
| 70 | unsigned int sample_size; | 70 | unsigned int sample_size; |
| 71 | bool supported; | 71 | bool supported; |
| 72 | bool needs_swap; | ||
| 72 | /* parse modifier helper */ | 73 | /* parse modifier helper */ |
| 73 | int exclude_GH; | 74 | int exclude_GH; |
| 74 | struct perf_evsel *leader; | 75 | struct perf_evsel *leader; |
| @@ -205,7 +206,7 @@ static inline int perf_evsel__read_scaled(struct perf_evsel *evsel, | |||
| 205 | void hists__init(struct hists *hists); | 206 | void hists__init(struct hists *hists); |
| 206 | 207 | ||
| 207 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, | 208 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, |
| 208 | struct perf_sample *sample, bool swapped); | 209 | struct perf_sample *sample); |
| 209 | 210 | ||
| 210 | static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) | 211 | static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) |
| 211 | { | 212 | { |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 6aae3290358e..7daad237dea5 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
| @@ -1256,8 +1256,10 @@ read_event_desc(struct perf_header *ph, int fd) | |||
| 1256 | if (ret != (ssize_t)sizeof(nr)) | 1256 | if (ret != (ssize_t)sizeof(nr)) |
| 1257 | goto error; | 1257 | goto error; |
| 1258 | 1258 | ||
| 1259 | if (ph->needs_swap) | 1259 | if (ph->needs_swap) { |
| 1260 | nr = bswap_32(nr); | 1260 | nr = bswap_32(nr); |
| 1261 | evsel->needs_swap = true; | ||
| 1262 | } | ||
| 1261 | 1263 | ||
| 1262 | evsel->name = do_read_string(fd, ph); | 1264 | evsel->name = do_read_string(fd, ph); |
| 1263 | 1265 | ||
| @@ -2626,6 +2628,8 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
| 2626 | 2628 | ||
| 2627 | if (evsel == NULL) | 2629 | if (evsel == NULL) |
| 2628 | goto out_delete_evlist; | 2630 | goto out_delete_evlist; |
| 2631 | |||
| 2632 | evsel->needs_swap = header->needs_swap; | ||
| 2629 | /* | 2633 | /* |
| 2630 | * Do it before so that if perf_evsel__alloc_id fails, this | 2634 | * Do it before so that if perf_evsel__alloc_id fails, this |
| 2631 | * entry gets purged too at perf_evlist__delete(). | 2635 | * entry gets purged too at perf_evlist__delete(). |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c i | |||
