diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-11 22:28:50 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-28 10:37:29 -0200 |
commit | 81e36bffad95e015af9741b5b1ee16afe08aab05 (patch) | |
tree | 3468b3f8e1109e8e1d89d5d910d3a533bf6da70e /tools/perf/util/evlist.c | |
parent | d04b35f8085f0d4c5c874515b8f65e7664357148 (diff) | |
download | op-kernel-dev-81e36bffad95e015af9741b5b1ee16afe08aab05.zip op-kernel-dev-81e36bffad95e015af9741b5b1ee16afe08aab05.tar.gz |
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/util/evlist.c')
-rw-r--r-- | tools/perf/util/evlist.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 81237dc..d44e3df 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) return first->attr.sample_type; } +u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist) +{ + struct perf_evsel *first; + struct perf_sample *data; + u64 sample_type; + u16 size = 0; + + first = list_entry(evlist->entries.next, struct perf_evsel, node); + + if (!first->attr.sample_id_all) + goto out; + + sample_type = first->attr.sample_type; + + if (sample_type & PERF_SAMPLE_TID) + size += sizeof(data->tid) * 2; + + if (sample_type & PERF_SAMPLE_TIME) + size += sizeof(data->time); + + if (sample_type & PERF_SAMPLE_ID) + size += sizeof(data->id); + + if (sample_type & PERF_SAMPLE_STREAM_ID) + size += sizeof(data->stream_id); + + if (sample_type & PERF_SAMPLE_CPU) + size += sizeof(data->cpu) * 2; +out: + return size; +} + bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist) { struct perf_evsel *pos, *first; |