diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-11 19:28:50 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-28 07:37:29 -0500 |
commit | 81e36bffad95e015af9741b5b1ee16afe08aab05 (patch) | |
tree | 3468b3f8e1109e8e1d89d5d910d3a533bf6da70e /tools/perf | |
parent | d04b35f8085f0d4c5c874515b8f65e7664357148 (diff) |
perf evlist: Introduce id_hdr_size method out of perf_session
We will need this when not using perf_session in cases like 'perf top'
and strace where no perf.data file is created nor consumed.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
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-za923wjc41q5xot5vrhuhj3j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/evlist.c | 32 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 1 | ||||
-rw-r--r-- | tools/perf/util/session.c | 29 |
3 files changed, 34 insertions, 28 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 81237dcde1fd..d44e3df13a8f 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -625,6 +625,38 @@ u64 perf_evlist__sample_type(const struct perf_evlist *evlist) | |||
625 | return first->attr.sample_type; | 625 | return first->attr.sample_type; |
626 | } | 626 | } |
627 | 627 | ||
628 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist) | ||
629 | { | ||
630 | struct perf_evsel *first; | ||
631 | struct perf_sample *data; | ||
632 | u64 sample_type; | ||
633 | u16 size = 0; | ||
634 | |||
635 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
636 | |||
637 | if (!first->attr.sample_id_all) | ||
638 | goto out; | ||
639 | |||
640 | sample_type = first->attr.sample_type; | ||
641 | |||
642 | if (sample_type & PERF_SAMPLE_TID) | ||
643 | size += sizeof(data->tid) * 2; | ||
644 | |||
645 | if (sample_type & PERF_SAMPLE_TIME) | ||
646 | size += sizeof(data->time); | ||
647 | |||
648 | if (sample_type & PERF_SAMPLE_ID) | ||
649 | size += sizeof(data->id); | ||
650 | |||
651 | if (sample_type & PERF_SAMPLE_STREAM_ID) | ||
652 | size += sizeof(data->stream_id); | ||
653 | |||
654 | if (sample_type & PERF_SAMPLE_CPU) | ||
655 | size += sizeof(data->cpu) * 2; | ||
656 | out: | ||
657 | return size; | ||
658 | } | ||
659 | |||
628 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist) | 660 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist) |
629 | { | 661 | { |
630 | struct perf_evsel *pos, *first; | 662 | struct perf_evsel *pos, *first; |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 17e9c80243ce..2202e7b04103 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -104,6 +104,7 @@ int perf_evlist__set_filters(struct perf_evlist *evlist); | |||
104 | 104 | ||
105 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist); | 105 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist); |
106 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); | 106 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); |
107 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist); | ||
107 | 108 | ||
108 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); | 109 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); |
109 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); | 110 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index a76666f17767..675e080f66b6 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -78,39 +78,12 @@ out_close: | |||
78 | return -1; | 78 | return -1; |
79 | } | 79 | } |
80 | 80 | ||
81 | static void perf_session__id_header_size(struct perf_session *session) | ||
82 | { | ||
83 | struct perf_sample *data; | ||
84 | u64 sample_type = session->sample_type; | ||
85 | u16 size = 0; | ||
86 | |||
87 | if (!session->sample_id_all) | ||
88 | goto out; | ||
89 | |||
90 | if (sample_type & PERF_SAMPLE_TID) | ||
91 | size += sizeof(data->tid) * 2; | ||
92 | |||
93 | if (sample_type & PERF_SAMPLE_TIME) | ||
94 | size += sizeof(data->time); | ||
95 | |||
96 | if (sample_type & PERF_SAMPLE_ID) | ||
97 | size += sizeof(data->id); | ||
98 | |||
99 | if (sample_type & PERF_SAMPLE_STREAM_ID) | ||
100 | size += sizeof(data->stream_id); | ||
101 | |||
102 | if (sample_type & PERF_SAMPLE_CPU) | ||
103 | size += sizeof(data->cpu) * 2; | ||
104 | out: | ||
105 | session->id_hdr_size = size; | ||
106 | } | ||
107 | |||
108 | void perf_session__update_sample_type(struct perf_session *self) | 81 | void perf_session__update_sample_type(struct perf_session *self) |
109 | { | 82 | { |
110 | self->sample_type = perf_evlist__sample_type(self->evlist); | 83 | self->sample_type = perf_evlist__sample_type(self->evlist); |
111 | self->sample_size = __perf_evsel__sample_size(self->sample_type); | 84 | self->sample_size = __perf_evsel__sample_size(self->sample_type); |
112 | self->sample_id_all = perf_evlist__sample_id_all(self->evlist); | 85 | self->sample_id_all = perf_evlist__sample_id_all(self->evlist); |
113 | perf_session__id_header_size(self); | 86 | self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist); |
114 | } | 87 | } |
115 | 88 | ||
116 | int perf_session__create_kernel_maps(struct perf_session *self) | 89 | int perf_session__create_kernel_maps(struct perf_session *self) |