aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-12-02 07:25:28 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-12-04 20:08:40 -0500
commit9c90a61c7e4286aa5a38b314a2d8f5a1e70b5135 (patch)
treed05c5d84db78b2c98c27c3cc83f5da651a6f5707 /tools/perf/util/session.c
parent640c03ce837fe8d4b56342aba376ea0da3960459 (diff)
perf tools: Ask for ID PERF_SAMPLE_ info on all PERF_RECORD_ events
So that we can use -T == --timestamp, asking for PERF_SAMPLE_TIME: $ perf record -aT $ perf report -D | grep PERF_RECORD_ <SNIP> 3 5951915425 0x47530 [0x58]: PERF_RECORD_SAMPLE(IP, 1): 16811/16811: 0xffffffff8138c1a2 period: 215979 cpu:3 3 5952026879 0x47588 [0x90]: PERF_RECORD_SAMPLE(IP, 1): 16811/16811: 0xffffffff810cb480 period: 215979 cpu:3 3 5952059959 0x47618 [0x38]: PERF_RECORD_FORK(6853:6853):(16811:16811) 3 5952138878 0x47650 [0x78]: PERF_RECORD_SAMPLE(IP, 1): 16811/16811: 0xffffffff811bac35 period: 431478 cpu:3 3 5952375068 0x476c8 [0x30]: PERF_RECORD_COMM: find:6853 3 5952395923 0x476f8 [0x50]: PERF_RECORD_MMAP 6853/6853: [0x400000(0x25000) @ 0]: /usr/bin/find 3 5952413756 0x47748 [0xa0]: PERF_RECORD_SAMPLE(IP, 1): 6853/6853: 0xffffffff810d080f period: 859332 cpu:3 3 5952419837 0x477e8 [0x58]: PERF_RECORD_MMAP 6853/6853: [0x3f44600000(0x21d000) @ 0]: /lib64/ld-2.5.so 3 5952437929 0x47840 [0x48]: PERF_RECORD_MMAP 6853/6853: [0x7fff7e1c9000(0x1000) @ 0x7fff7e1c9000]: [vdso] 3 5952570127 0x47888 [0x58]: PERF_RECORD_MMAP 6853/6853: [0x3f46200000(0x218000) @ 0]: /lib64/libselinux.so.1 3 5952623637 0x478e0 [0x58]: PERF_RECORD_MMAP 6853/6853: [0x3f44a00000(0x356000) @ 0]: /lib64/libc-2.5.so 3 5952675720 0x47938 [0x58]: PERF_RECORD_MMAP 6853/6853: [0x3f44e00000(0x204000) @ 0]: /lib64/libdl-2.5.so 3 5952710080 0x47990 [0x58]: PERF_RECORD_MMAP 6853/6853: [0x3f45a00000(0x246000) @ 0]: /lib64/libsepol.so.1 3 5952847802 0x479e8 [0x58]: PERF_RECORD_SAMPLE(IP, 1): 6853/6853: 0xffffffff813897f0 period: 1142536 cpu:3 <SNIP> First column is the cpu and the second the timestamp. That way we can investigate problems in the event stream. If the new perf binary is run on an older kernel, it will disable this feature automatically. Tested-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Ian Munsie <imunsie@au1.ibm.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Ian Munsie <imunsie@au1.ibm.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Stephane Eranian <eranian@google.com> LKML-Reference: <1291318772-30880-5-git-send-email-acme@infradead.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 08ec018966a8..5c756609104e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -65,9 +65,37 @@ out_close:
65 return -1; 65 return -1;
66} 66}
67 67
68void perf_session__update_sample_type(struct perf_session *self) 68static void perf_session__id_header_size(struct perf_session *session)
69{ 69{
70 self->sample_type = perf_header__sample_type(&self->header); 70 struct sample_data *data;
71 u64 sample_type = session->sample_type;
72 u16 size = 0;
73
74 if (!session->sample_id_all)
75 goto out;
76
77 if (sample_type & PERF_SAMPLE_TID)
78 size += sizeof(data->tid) * 2;
79
80 if (sample_type & PERF_SAMPLE_TIME)
81 size += sizeof(data->time);
82
83 if (sample_type & PERF_SAMPLE_ID)
84 size += sizeof(data->id);
85
86 if (sample_type & PERF_SAMPLE_STREAM_ID)
87 size += sizeof(data->stream_id);
88
89 if (sample_type & PERF_SAMPLE_CPU)
90 size += sizeof(data->cpu) * 2;
91out:
92 session->id_hdr_size = size;
93}
94
95void perf_session__set_sample_id_all(struct perf_session *session, bool value)
96{
97 session->sample_id_all = value;
98 perf_session__id_header_size(session);
71} 99}
72 100
73void perf_session__set_sample_type(struct perf_session *session, u64 type) 101void perf_session__set_sample_type(struct perf_session *session, u64 type)
@@ -75,6 +103,13 @@ void perf_session__set_sample_type(struct perf_session *session, u64 type)
75 session->sample_type = type; 103 session->sample_type = type;
76} 104}
77 105
106void perf_session__update_sample_type(struct perf_session *self)
107{
108 self->sample_type = perf_header__sample_type(&self->header);
109 self->sample_id_all = perf_header__sample_id_all(&self->header);
110 perf_session__id_header_size(self);
111}
112
78int perf_session__create_kernel_maps(struct perf_session *self) 113int perf_session__create_kernel_maps(struct perf_session *self)
79{ 114{
80 int ret = machine__create_kernel_maps(&self->host_machine); 115 int ret = machine__create_kernel_maps(&self->host_machine);
@@ -443,7 +478,7 @@ static void flush_sample_queue(struct perf_session *s,
443 if (iter->timestamp > limit) 478 if (iter->timestamp > limit)
444 break; 479 break;
445 480
446 event__parse_sample(iter->event, s->sample_type, &sample); 481 event__parse_sample(iter->event, s, &sample);
447 ops->sample(iter->event, &sample, s); 482 ops->sample(iter->event, &sample, s);
448 483
449 os->last_flush = iter->timestamp; 484 os->last_flush = iter->timestamp;
@@ -618,6 +653,23 @@ static void callchain__dump(struct sample_data *sample)
618 printf("..... %2d: %016Lx\n", i, sample->callchain->ips[i]); 653 printf("..... %2d: %016Lx\n", i, sample->callchain->ips[i]);
619} 654}
620 655
656static void perf_session__print_tstamp(struct perf_session *session,
657 event_t *event,
658 struct sample_data *sample)
659{
660 if (event->header.type != PERF_RECORD_SAMPLE &&
661 !session->sample_id_all) {
662 fputs("-1 -1 ", stdout);
663 return;
664 }
665
666 if ((session->sample_type & PERF_SAMPLE_CPU))
667 printf("%u ", sample->cpu);
668
669 if (session->sample_type & PERF_SAMPLE_TIME)
670 printf("%Lu ", sample->time);
671}
672
621static int perf_session__process_event(struct perf_session *self, 673static int perf_session__process_event(struct perf_session *self,
622 event_t *event, 674 event_t *event,
623 struct perf_event_ops *ops, 675 struct perf_event_ops *ops,
@@ -630,8 +682,12 @@ static int perf_session__process_event(struct perf_session *self,
630 if (self->header.needs_swap && event__swap_ops[event->header.type]) 682 if (self->header.needs_swap && event__swap_ops[event->header.type])
631 event__swap_ops[event->header.type](event); 683 event__swap_ops[event->header.type](event);
632 684
633 if (event->header.type == PERF_RECORD_SAMPLE) 685 if (event->header.type >= PERF_RECORD_MMAP &&
634 event__parse_sample(event, self->sample_type, &sample); 686 event->header.type <= PERF_RECORD_SAMPLE) {
687 event__parse_sample(event, self, &sample);
688 if (dump_trace)
689 perf_session__print_tstamp(self, event, &sample);
690 }
635 691
636 if (event->header.type < PERF_RECORD_HEADER_MAX) { 692 if (event->header.type < PERF_RECORD_HEADER_MAX) {
637 dump_printf("%#Lx [%#x]: PERF_RECORD_%s", 693 dump_printf("%#Lx [%#x]: PERF_RECORD_%s",