diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-02 10:42:57 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-02 10:42:57 -0400 |
commit | cb0b29e0861659c9eef9664772cd7e845ba1104a (patch) | |
tree | a53dd1ebccef16cb9e7873aa76566ab339fb73ff /tools/perf | |
parent | 7b56cce27123ccbf2cb82febbbc88443d719f1f8 (diff) |
perf evlist: Introduce perf_evlist__parse_sample
That is a more compact form of perf_session__parse_sample and to support
multiple evlists per perf_session is the way to go anyway.
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-vkxx3j5qktoj11bvcwmfjj13@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-test.c | 8 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 2 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 9 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 4 | ||||
-rw-r--r-- | tools/perf/util/python.c | 6 | ||||
-rw-r--r-- | tools/perf/util/session.c | 19 | ||||
-rw-r--r-- | tools/perf/util/session.h | 4 |
7 files changed, 21 insertions, 31 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index e5032ed2f259..1d592f5cbea9 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -562,9 +562,7 @@ static int test__basic_mmap(void) | |||
562 | goto out_munmap; | 562 | goto out_munmap; |
563 | } | 563 | } |
564 | 564 | ||
565 | err = perf_event__parse_sample(event, attr.sample_type, | 565 | err = perf_evlist__parse_sample(evlist, event, &sample, false); |
566 | evsels[0]->sample_size, | ||
567 | false, &sample, false); | ||
568 | if (err) { | 566 | if (err) { |
569 | pr_err("Can't parse sample, err = %d\n", err); | 567 | pr_err("Can't parse sample, err = %d\n", err); |
570 | goto out_munmap; | 568 | goto out_munmap; |
@@ -781,9 +779,7 @@ static int test__PERF_RECORD(void) | |||
781 | if (type < PERF_RECORD_MAX) | 779 | if (type < PERF_RECORD_MAX) |
782 | nr_events[type]++; | 780 | nr_events[type]++; |
783 | 781 | ||
784 | err = perf_event__parse_sample(event, evsel->attr.sample_type, | 782 | err = perf_evlist__parse_sample(evlist, event, &sample, false); |
785 | evsel->sample_size, true, | ||
786 | &sample, false); | ||
787 | if (err < 0) { | 783 | if (err < 0) { |
788 | if (verbose) | 784 | if (verbose) |
789 | perf_event__fprintf(event, stderr); | 785 | perf_event__fprintf(event, stderr); |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 520e4256fc66..40264eaa9f0f 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -811,7 +811,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
811 | int ret; | 811 | int ret; |
812 | 812 | ||
813 | while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { | 813 | while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { |
814 | ret = perf_session__parse_sample(session, event, &sample); | 814 | ret = perf_evlist__parse_sample(top->evlist, event, &sample, false); |
815 | if (ret) { | 815 | if (ret) { |
816 | pr_err("Can't parse sample, err = %d\n", ret); | 816 | pr_err("Can't parse sample, err = %d\n", ret); |
817 | continue; | 817 | continue; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 3edfd3483816..1a560e0904a5 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -881,3 +881,12 @@ int perf_evlist__start_workload(struct perf_evlist *evlist) | |||
881 | 881 | ||
882 | return 0; | 882 | return 0; |
883 | } | 883 | } |
884 | |||
885 | int perf_evlist__parse_sample(struct perf_evlist *evlist, | ||
886 | const union perf_event *event, | ||
887 | struct perf_sample *sample, bool swapped) | ||
888 | { | ||
889 | 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, | ||
891 | e->attr.sample_id_all, sample, swapped); | ||
892 | } | ||
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 40d4d3cdced0..a5a49118a91a 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -122,6 +122,10 @@ 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, | ||
126 | const union perf_event *event, | ||
127 | struct perf_sample *sample, bool swapped); | ||
128 | |||
125 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); | 129 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); |
126 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); | 130 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); |
127 | 131 | ||
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index b0d6f85e30f1..0688bfb6d280 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -797,17 +797,13 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
797 | 797 | ||
798 | event = perf_evlist__mmap_read(evlist, cpu); | 798 | event = perf_evlist__mmap_read(evlist, cpu); |
799 | if (event != NULL) { | 799 | if (event != NULL) { |
800 | struct perf_evsel *first; | ||
801 | PyObject *pyevent = pyrf_event__new(event); | 800 | PyObject *pyevent = pyrf_event__new(event); |
802 | struct pyrf_event *pevent = (struct pyrf_event *)pyevent; | 801 | struct pyrf_event *pevent = (struct pyrf_event *)pyevent; |
803 | 802 | ||
804 | if (pyevent == NULL) | 803 | if (pyevent == NULL) |
805 | return PyErr_NoMemory(); | 804 | return PyErr_NoMemory(); |
806 | 805 | ||
807 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | 806 | err = perf_evlist__parse_sample(evlist, event, &pevent->sample, false); |
808 | err = perf_event__parse_sample(event, first->attr.sample_type, | ||
809 | first->sample_size, | ||
810 | sample_id_all, &pevent->sample, false); | ||
811 | if (err) | 807 | if (err) |
812 | return PyErr_Format(PyExc_OSError, | 808 | return PyErr_Format(PyExc_OSError, |
813 | "perf: can't parse sample, err=%d", err); | 809 | "perf: can't parse sample, err=%d", err); |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5b8601df2392..7d07324db41c 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -16,19 +16,6 @@ | |||
16 | #include "cpumap.h" | 16 | #include "cpumap.h" |
17 | #include "event-parse.h" | 17 | #include "event-parse.h" |
18 | 18 | ||
19 | int perf_session__parse_sample(struct perf_session *session, | ||
20 | const union perf_event *event, | ||
21 | struct perf_sample *sample) | ||
22 | { | ||
23 | struct perf_evsel *first; | ||
24 | first = list_entry(session->evlist->entries.next, struct perf_evsel, node); | ||
25 | |||
26 | return perf_event__parse_sample(event, first->attr.sample_type, | ||
27 | first->sample_size, | ||
28 | first->attr.sample_id_all, sample, | ||
29 | session->header.needs_swap); | ||
30 | } | ||
31 | |||
32 | int perf_session__synthesize_sample(struct perf_session *session, | 19 | int perf_session__synthesize_sample(struct perf_session *session, |
33 | union perf_event *event, | 20 | union perf_event *event, |
34 | const struct perf_sample *sample) | 21 | const struct perf_sample *sample) |
@@ -692,7 +679,8 @@ static void flush_sample_queue(struct perf_session *s, | |||
692 | if (iter->timestamp > limit) | 679 | if (iter->timestamp > limit) |
693 | break; | 680 | break; |
694 | 681 | ||
695 | ret = perf_session__parse_sample(s, iter->event, &sample); | 682 | ret = perf_evlist__parse_sample(s->evlist, iter->event, &sample, |
683 | s->header.needs_swap); | ||
696 | if (ret) | 684 | if (ret) |
697 | pr_err("Can't parse sample, err = %d\n", ret); | 685 | pr_err("Can't parse sample, err = %d\n", ret); |
698 | else | 686 | else |
@@ -1103,7 +1091,8 @@ static int perf_session__process_event(struct perf_session *session, | |||
1103 | /* | 1091 | /* |
1104 | * For all kernel events we get the sample data | 1092 | * For all kernel events we get the sample data |
1105 | */ | 1093 | */ |
1106 | ret = perf_session__parse_sample(session, event, &sample); | 1094 | ret = perf_evlist__parse_sample(session->evlist, event, &sample, |
1095 | session->header.needs_swap); | ||
1107 | if (ret) | 1096 | if (ret) |
1108 | return ret; | 1097 | return ret; |
1109 | 1098 | ||
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index e2a1a4b7b236..7389fb1f010a 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -126,10 +126,6 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, | |||
126 | 126 | ||
127 | size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); | 127 | size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); |
128 | 128 | ||
129 | int perf_session__parse_sample(struct perf_session *session, | ||
130 | const union perf_event *event, | ||
131 | struct perf_sample *sample); | ||
132 | |||
133 | int perf_session__synthesize_sample(struct perf_session *session, | 129 | int perf_session__synthesize_sample(struct perf_session *session, |
134 | union perf_event *event, | 130 | union perf_event *event, |
135 | const struct perf_sample *sample); | 131 | const struct perf_sample *sample); |