aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-29 11:01:45 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-29 13:25:37 -0500
commit8115d60c323dd9931b95221c0a392aeddc1d6ef3 (patch)
tree13e75d71c5163c78efc9d8ab33988cc6c7be74a1 /tools/perf/util/session.c
parent8d50e5b4171a69cf48ca94a1e7c14033d0b4771d (diff)
perf tools: Kill event_t typedef, use 'union perf_event' instead
And move the event_t methods to the perf_event__ too. No code changes, just namespace consistency. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> 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.c169
1 files changed, 85 insertions, 84 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ee0b61102571..a3a871f7bda3 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -165,7 +165,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
165 } else if (mode == O_WRONLY) { 165 } else if (mode == O_WRONLY) {
166 /* 166 /*
167 * In O_RDONLY mode this will be performed when reading the 167 * In O_RDONLY mode this will be performed when reading the
168 * kernel MMAP event, in event__process_mmap(). 168 * kernel MMAP event, in perf_event__process_mmap().
169 */ 169 */
170 if (perf_session__create_kernel_maps(self) < 0) 170 if (perf_session__create_kernel_maps(self) < 0)
171 goto out_delete; 171 goto out_delete;
@@ -291,14 +291,14 @@ int perf_session__resolve_callchain(struct perf_session *self,
291 return 0; 291 return 0;
292} 292}
293 293
294static int process_event_synth_stub(event_t *event __used, 294static int process_event_synth_stub(union perf_event *event __used,
295 struct perf_session *session __used) 295 struct perf_session *session __used)
296{ 296{
297 dump_printf(": unhandled!\n"); 297 dump_printf(": unhandled!\n");
298 return 0; 298 return 0;
299} 299}
300 300
301static int process_event_stub(event_t *event __used, 301static int process_event_stub(union perf_event *event __used,
302 struct perf_sample *sample __used, 302 struct perf_sample *sample __used,
303 struct perf_session *session __used) 303 struct perf_session *session __used)
304{ 304{
@@ -306,7 +306,7 @@ static int process_event_stub(event_t *event __used,
306 return 0; 306 return 0;
307} 307}
308 308
309static int process_finished_round_stub(event_t *event __used, 309static int process_finished_round_stub(union perf_event *event __used,
310 struct perf_session *session __used, 310 struct perf_session *session __used,
311 struct perf_event_ops *ops __used) 311 struct perf_event_ops *ops __used)
312{ 312{
@@ -314,7 +314,7 @@ static int process_finished_round_stub(event_t *event __used,
314 return 0; 314 return 0;
315} 315}
316 316
317static int process_finished_round(event_t *event, 317static int process_finished_round(union perf_event *event,
318 struct perf_session *session, 318 struct perf_session *session,
319 struct perf_event_ops *ops); 319 struct perf_event_ops *ops);
320 320
@@ -331,7 +331,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
331 if (handler->exit == NULL) 331 if (handler->exit == NULL)
332 handler->exit = process_event_stub; 332 handler->exit = process_event_stub;
333 if (handler->lost == NULL) 333 if (handler->lost == NULL)
334 handler->lost = event__process_lost; 334 handler->lost = perf_event__process_lost;
335 if (handler->read == NULL) 335 if (handler->read == NULL)
336 handler->read = process_event_stub; 336 handler->read = process_event_stub;
337 if (handler->throttle == NULL) 337 if (handler->throttle == NULL)
@@ -365,98 +365,98 @@ void mem_bswap_64(void *src, int byte_size)
365 } 365 }
366} 366}
367 367
368static void event__all64_swap(event_t *self) 368static void perf_event__all64_swap(union perf_event *event)
369{ 369{
370 struct perf_event_header *hdr = &self->header; 370 struct perf_event_header *hdr = &event->header;
371 mem_bswap_64(hdr + 1, self->header.size - sizeof(*hdr)); 371 mem_bswap_64(hdr + 1, event->header.size - sizeof(*hdr));
372} 372}
373 373
374static void event__comm_swap(event_t *self) 374static void perf_event__comm_swap(union perf_event *event)
375{ 375{
376 self->comm.pid = bswap_32(self->comm.pid); 376 event->comm.pid = bswap_32(event->comm.pid);
377 self->comm.tid = bswap_32(self->comm.tid); 377 event->comm.tid = bswap_32(event->comm.tid);
378} 378}
379 379
380static void event__mmap_swap(event_t *self) 380static void perf_event__mmap_swap(union perf_event *event)
381{ 381{
382 self->mmap.pid = bswap_32(self->mmap.pid); 382 event->mmap.pid = bswap_32(event->mmap.pid);
383 self->mmap.tid = bswap_32(self->mmap.tid); 383 event->mmap.tid = bswap_32(event->mmap.tid);
384 self->mmap.start = bswap_64(self->mmap.start); 384 event->mmap.start = bswap_64(event->mmap.start);
385 self->mmap.len = bswap_64(self->mmap.len); 385 event->mmap.len = bswap_64(event->mmap.len);
386 self->mmap.pgoff = bswap_64(self->mmap.pgoff); 386 event->mmap.pgoff = bswap_64(event->mmap.pgoff);
387} 387}
388 388
389static void event__task_swap(event_t *self) 389static void perf_event__task_swap(union perf_event *event)
390{ 390{
391 self->fork.pid = bswap_32(self->fork.pid); 391 event->fork.pid = bswap_32(event->fork.pid);
392 self->fork.tid = bswap_32(self->fork.tid); 392 event->fork.tid = bswap_32(event->fork.tid);
393 self->fork.ppid = bswap_32(self->fork.ppid); 393 event->fork.ppid = bswap_32(event->fork.ppid);
394 self->fork.ptid = bswap_32(self->fork.ptid); 394 event->fork.ptid = bswap_32(event->fork.ptid);
395 self->fork.time = bswap_64(self->fork.time); 395 event->fork.time = bswap_64(event->fork.time);
396} 396}
397 397
398static void event__read_swap(event_t *self) 398static void perf_event__read_swap(union perf_event *event)
399{ 399{
400 self->read.pid = bswap_32(self->read.pid); 400 event->read.pid = bswap_32(event->read.pid);
401 self->read.tid = bswap_32(self->read.tid); 401 event->read.tid = bswap_32(event->read.tid);
402 self->read.value = bswap_64(self->read.value); 402 event->read.value = bswap_64(event->read.value);
403 self->read.time_enabled = bswap_64(self->read.time_enabled); 403 event->read.time_enabled = bswap_64(event->read.time_enabled);
404 self->read.time_running = bswap_64(self->read.time_running); 404 event->read.time_running = bswap_64(event->read.time_running);
405 self->read.id = bswap_64(self->read.id); 405 event->read.id = bswap_64(event->read.id);
406} 406}
407 407
408static void event__attr_swap(event_t *self) 408static void perf_event__attr_swap(union perf_event *event)
409{ 409{
410 size_t size; 410 size_t size;
411 411
412 self->attr.attr.type = bswap_32(self->attr.attr.type); 412 event->attr.attr.type = bswap_32(event->attr.attr.type);
413 self->attr.attr.size = bswap_32(self->attr.attr.size); 413 event->attr.attr.size = bswap_32(event->attr.attr.size);
414 self->attr.attr.config = bswap_64(self->attr.attr.config); 414 event->attr.attr.config = bswap_64(event->attr.attr.config);
415 self->attr.attr.sample_period = bswap_64(self->attr.attr.sample_period); 415 event->attr.attr.sample_period = bswap_64(event->attr.attr.sample_period);
416 self->attr.attr.sample_type = bswap_64(self->attr.attr.sample_type); 416 event->attr.attr.sample_type = bswap_64(event->attr.attr.sample_type);
417 self->attr.attr.read_format = bswap_64(self->attr.attr.read_format); 417 event->attr.attr.read_format = bswap_64(event->attr.attr.read_format);
418 self->attr.attr.wakeup_events = bswap_32(self->attr.attr.wakeup_events); 418 event->attr.attr.wakeup_events = bswap_32(event->attr.attr.wakeup_events);
419 self->attr.attr.bp_type = bswap_32(self->attr.attr.bp_type); 419 event->attr.attr.bp_type = bswap_32(event->attr.attr.bp_type);
420 self->attr.attr.bp_addr = bswap_64(self->attr.attr.bp_addr); 420 event->attr.attr.bp_addr = bswap_64(event->attr.attr.bp_addr);
421 self->attr.attr.bp_len = bswap_64(self->attr.attr.bp_len); 421 event->attr.attr.bp_len = bswap_64(event->attr.attr.bp_len);
422 422
423 size = self->header.size; 423 size = event->header.size;
424 size -= (void *)&self->attr.id - (void *)self; 424 size -= (void *)&event->attr.id - (void *)event;
425 mem_bswap_64(self->attr.id, size); 425 mem_bswap_64(event->attr.id, size);
426} 426}
427 427
428static void event__event_type_swap(event_t *self) 428static void perf_event__event_type_swap(union perf_event *event)
429{ 429{
430 self->event_type.event_type.event_id = 430 event->event_type.event_type.event_id =
431 bswap_64(self->event_type.event_type.event_id); 431 bswap_64(event->event_type.event_type.event_id);
432} 432}
433 433
434static void event__tracing_data_swap(event_t *self) 434static void perf_event__tracing_data_swap(union perf_event *event)
435{ 435{
436 self->tracing_data.size = bswap_32(self->tracing_data.size); 436 event->tracing_data.size = bswap_32(event->tracing_data.size);
437} 437}
438 438
439typedef void (*event__swap_op)(event_t *self); 439typedef void (*perf_event__swap_op)(union perf_event *event);
440 440
441static event__swap_op event__swap_ops[] = { 441static perf_event__swap_op perf_event__swap_ops[] = {
442 [PERF_RECORD_MMAP] = event__mmap_swap, 442 [PERF_RECORD_MMAP] = perf_event__mmap_swap,
443 [PERF_RECORD_COMM] = event__comm_swap, 443 [PERF_RECORD_COMM] = perf_event__comm_swap,
444 [PERF_RECORD_FORK] = event__task_swap, 444 [PERF_RECORD_FORK] = perf_event__task_swap,
445 [PERF_RECORD_EXIT] = event__task_swap, 445 [PERF_RECORD_EXIT] = perf_event__task_swap,
446 [PERF_RECORD_LOST] = event__all64_swap, 446 [PERF_RECORD_LOST] = perf_event__all64_swap,
447 [PERF_RECORD_READ] = event__read_swap, 447 [PERF_RECORD_READ] = perf_event__read_swap,
448 [PERF_RECORD_SAMPLE] = event__all64_swap, 448 [PERF_RECORD_SAMPLE] = perf_event__all64_swap,
449 [PERF_RECORD_HEADER_ATTR] = event__attr_swap, 449 [PERF_RECORD_HEADER_ATTR] = perf_event__attr_swap,
450 [PERF_RECORD_HEADER_EVENT_TYPE] = event__event_type_swap, 450 [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap,
451 [PERF_RECORD_HEADER_TRACING_DATA] = event__tracing_data_swap, 451 [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
452 [PERF_RECORD_HEADER_BUILD_ID] = NULL, 452 [PERF_RECORD_HEADER_BUILD_ID] = NULL,
453 [PERF_RECORD_HEADER_MAX] = NULL, 453 [PERF_RECORD_HEADER_MAX] = NULL,
454}; 454};
455 455
456struct sample_queue { 456struct sample_queue {
457 u64 timestamp; 457 u64 timestamp;
458 u64 file_offset; 458 u64 file_offset;
459 event_t *event; 459 union perf_event *event;
460 struct list_head list; 460 struct list_head list;
461}; 461};
462 462
@@ -474,7 +474,7 @@ static void perf_session_free_sample_buffers(struct perf_session *session)
474} 474}
475 475
476static int perf_session_deliver_event(struct perf_session *session, 476static int perf_session_deliver_event(struct perf_session *session,
477 event_t *event, 477 union perf_event *event,
478 struct perf_sample *sample, 478 struct perf_sample *sample,
479 struct perf_event_ops *ops, 479 struct perf_event_ops *ops,
480 u64 file_offset); 480 u64 file_offset);
@@ -552,7 +552,7 @@ static void flush_sample_queue(struct perf_session *s,
552 * Flush every events below timestamp 7 552 * Flush every events below timestamp 7
553 * etc... 553 * etc...
554 */ 554 */
555static int process_finished_round(event_t *event __used, 555static int process_finished_round(union perf_event *event __used,
556 struct perf_session *session, 556 struct perf_session *session,
557 struct perf_event_ops *ops) 557 struct perf_event_ops *ops)
558{ 558{
@@ -609,7 +609,7 @@ static void __queue_event(struct sample_queue *new, struct perf_session *s)
609 609
610#define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue)) 610#define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue))
611 611
612static int perf_session_queue_event(struct perf_session *s, event_t *event, 612static int perf_session_queue_event(struct perf_session *s, union perf_event *event,
613 struct perf_sample *sample, u64 file_offset) 613 struct perf_sample *sample, u64 file_offset)
614{ 614{
615 struct ordered_samples *os = &s->ordered_samples; 615 struct ordered_samples *os = &s->ordered_samples;
@@ -662,7 +662,7 @@ static void callchain__printf(struct perf_sample *sample)
662} 662}
663 663
664static void perf_session__print_tstamp(struct perf_session *session, 664static void perf_session__print_tstamp(struct perf_session *session,
665 event_t *event, 665 union perf_event *event,
666 struct perf_sample *sample) 666 struct perf_sample *sample)
667{ 667{
668 if (event->header.type != PERF_RECORD_SAMPLE && 668 if (event->header.type != PERF_RECORD_SAMPLE &&
@@ -678,7 +678,7 @@ static void perf_session__print_tstamp(struct perf_session *session,
678 printf("%" PRIu64 " ", sample->time); 678 printf("%" PRIu64 " ", sample->time);
679} 679}
680 680
681static void dump_event(struct perf_session *session, event_t *event, 681static void dump_event(struct perf_session *session, union perf_event *event,
682 u64 file_offset, struct perf_sample *sample) 682 u64 file_offset, struct perf_sample *sample)
683{ 683{
684 if (!dump_trace) 684 if (!dump_trace)
@@ -693,10 +693,10 @@ static void dump_event(struct perf_session *session, event_t *event,
693 perf_session__print_tstamp(session, event, sample); 693 perf_session__print_tstamp(session, event, sample);
694 694
695 printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset, 695 printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset,
696 event->header.size, event__get_event_name(event->header.type)); 696 event->header.size, perf_event__name(event->header.type));
697} 697}
698 698
699static void dump_sample(struct perf_session *session, event_t *event, 699static void dump_sample(struct perf_session *session, union perf_event *event,
700 struct perf_sample *sample) 700 struct perf_sample *sample)
701{ 701{
702 if (!dump_trace) 702 if (!dump_trace)
@@ -711,7 +711,7 @@ static void dump_sample(struct perf_session *session, event_t *event,
711} 711}
712 712
713static int perf_session_deliver_event(struct perf_session *session, 713static int perf_session_deliver_event(struct perf_session *session,
714 event_t *event, 714 union perf_event *event,
715 struct perf_sample *sample, 715 struct perf_sample *sample,
716 struct perf_event_ops *ops, 716 struct perf_event_ops *ops,
717 u64 file_offset) 717 u64 file_offset)
@@ -745,7 +745,7 @@ static int perf_session_deliver_event(struct perf_session *session,
745} 745}
746 746
747static int perf_session__preprocess_sample(struct perf_session *session, 747static int perf_session__preprocess_sample(struct perf_session *session,
748 event_t *event, struct perf_sample *sample) 748 union perf_event *event, struct perf_sample *sample)
749{ 749{
750 if (event->header.type != PERF_RECORD_SAMPLE || 750 if (event->header.type != PERF_RECORD_SAMPLE ||
751 !(session->sample_type & PERF_SAMPLE_CALLCHAIN)) 751 !(session->sample_type & PERF_SAMPLE_CALLCHAIN))
@@ -760,7 +760,7 @@ static int perf_session__preprocess_sample(struct perf_session *session,
760 return 0; 760 return 0;
761} 761}
762 762
763static int perf_session__process_user_event(struct perf_session *session, event_t *event, 763static int perf_session__process_user_event(struct perf_session *session, union perf_event *event,
764 struct perf_event_ops *ops, u64 file_offset) 764 struct perf_event_ops *ops, u64 file_offset)
765{ 765{
766 dump_event(session, event, file_offset, NULL); 766 dump_event(session, event, file_offset, NULL);
@@ -785,15 +785,16 @@ static int perf_session__process_user_event(struct perf_session *session, event_
785} 785}
786 786
787static int perf_session__process_event(struct perf_session *session, 787static int perf_session__process_event(struct perf_session *session,
788 event_t *event, 788 union perf_event *event,
789 struct perf_event_ops *ops, 789 struct perf_event_ops *ops,
790 u64 file_offset) 790 u64 file_offset)
791{ 791{
792 struct perf_sample sample; 792 struct perf_sample sample;
793 int ret; 793 int ret;
794 794
795 if (session->header.needs_swap && event__swap_ops[event->header.type]) 795 if (session->header.needs_swap &&
796 event__swap_ops[event->header.type](event); 796 perf_event__swap_ops[event->header.type])
797 perf_event__swap_ops[event->header.type](event);
797 798
798 if (event->header.type >= PERF_RECORD_HEADER_MAX) 799 if (event->header.type >= PERF_RECORD_HEADER_MAX)
799 return -EINVAL; 800 return -EINVAL;
@@ -845,7 +846,7 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
845static void perf_session__warn_about_errors(const struct perf_session *session, 846static void perf_session__warn_about_errors(const struct perf_session *session,
846 const struct perf_event_ops *ops) 847 const struct perf_event_ops *ops)
847{ 848{
848 if (ops->lost == event__process_lost && 849 if (ops->lost == perf_event__process_lost &&
849 session->hists.stats.total_lost != 0) { 850 session->hists.stats.total_lost != 0) {
850 ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64 851 ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64
851 "!\n\nCheck IO/CPU overload!\n\n", 852 "!\n\nCheck IO/CPU overload!\n\n",
@@ -877,7 +878,7 @@ volatile int session_done;
877static int __perf_session__process_pipe_events(struct perf_session *self, 878static int __perf_session__process_pipe_events(struct perf_session *self,
878 struct perf_event_ops *ops) 879 struct perf_event_ops *ops)
879{ 880{
880 event_t event; 881 union perf_event event;
881 uint32_t size; 882 uint32_t size;
882 int skip = 0; 883 int skip = 0;
883 u64 head; 884 u64 head;
@@ -958,7 +959,7 @@ int __perf_session__process_events(struct perf_session *session,
958 struct ui_progress *progress; 959 struct ui_progress *progress;
959 size_t page_size, mmap_size; 960 size_t page_size, mmap_size;
960 char *buf, *mmaps[8]; 961 char *buf, *mmaps[8];
961 event_t *event; 962 union perf_event *event;
962 uint32_t size; 963 uint32_t size;
963 964
964 perf_event_ops__fill_defaults(ops); 965 perf_event_ops__fill_defaults(ops);
@@ -1003,7 +1004,7 @@ remap:
1003 file_pos = file_offset + head; 1004 file_pos = file_offset + head;
1004 1005
1005more: 1006more:
1006 event = (event_t *)(buf + head); 1007 event = (union perf_event *)(buf + head);
1007 1008
1008 if (session->header.needs_swap) 1009 if (session->header.needs_swap)
1009 perf_event_header__bswap(&event->header); 1010 perf_event_header__bswap(&event->header);