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/util/evlist.c | |
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/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 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; |