diff options
| author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-23 19:18:48 -0400 |
|---|---|---|
| committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-23 21:50:46 -0400 |
| commit | 9df9bbba9f7e2e4ffdc51bbbfa524b67691321d2 (patch) | |
| tree | 7bdecf74c8895e69cfb550071801a548ac6567c9 | |
| parent | e0a808c65c23f88e48a5fff48775b90e7919c64f (diff) | |
perf: Use generic sample reordering in perf timechart
Use the new generic sample events reordering from perf timechart,
this drops the ad hoc sample reordering it was using before.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
| -rw-r--r-- | tools/perf/builtin-timechart.c | 112 |
1 files changed, 5 insertions, 107 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 96f4a092df37..c35aa44f82ba 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
| @@ -143,9 +143,6 @@ struct wake_event { | |||
| 143 | static struct power_event *power_events; | 143 | static struct power_event *power_events; |
| 144 | static struct wake_event *wake_events; | 144 | static struct wake_event *wake_events; |
| 145 | 145 | ||
| 146 | struct sample_wrapper *all_samples; | ||
| 147 | |||
| 148 | |||
| 149 | struct process_filter; | 146 | struct process_filter; |
| 150 | struct process_filter { | 147 | struct process_filter { |
| 151 | char *name; | 148 | char *name; |
| @@ -566,88 +563,6 @@ static void end_sample_processing(void) | |||
| 566 | } | 563 | } |
| 567 | } | 564 | } |
| 568 | 565 | ||
| 569 | static u64 sample_time(event_t *event, const struct perf_session *session) | ||
| 570 | { | ||
| 571 | int cursor; | ||
| 572 | |||
| 573 | cursor = 0; | ||
| 574 | if (session->sample_type & PERF_SAMPLE_IP) | ||
| 575 | cursor++; | ||
| 576 | if (session->sample_type & PERF_SAMPLE_TID) | ||
| 577 | cursor++; | ||
| 578 | if (session->sample_type & PERF_SAMPLE_TIME) | ||
| 579 | return event->sample.array[cursor]; | ||
| 580 | return 0; | ||
| 581 | } | ||
| 582 | |||
| 583 | |||
| 584 | /* | ||
| 585 | * We first queue all events, sorted backwards by insertion. | ||
| 586 | * The order will get flipped later. | ||
| 587 | */ | ||
| 588 | static int queue_sample_event(event_t *event, struct perf_session *session) | ||
| 589 | { | ||
| 590 | struct sample_wrapper *copy, *prev; | ||
| 591 | int size; | ||
| 592 | |||
| 593 | size = event->sample.header.size + sizeof(struct sample_wrapper) + 8; | ||
| 594 | |||
| 595 | copy = malloc(size); | ||
| 596 | if (!copy) | ||
| 597 | return 1; | ||
| 598 | |||
| 599 | memset(copy, 0, size); | ||
| 600 | |||
| 601 | copy->next = NULL; | ||
| 602 | copy->timestamp = sample_time(event, session); | ||
| 603 | |||
| 604 | memcpy(©->data, event, event->sample.header.size); | ||
| 605 | |||
| 606 | /* insert in the right place in the list */ | ||
| 607 | |||
| 608 | if (!all_samples) { | ||
| 609 | /* first sample ever */ | ||
| 610 | all_samples = copy; | ||
| 611 | return 0; | ||
| 612 | } | ||
| 613 | |||
| 614 | if (all_samples->timestamp < copy->timestamp) { | ||
| 615 | /* insert at the head of the list */ | ||
| 616 | copy->next = all_samples; | ||
| 617 | all_samples = copy; | ||
| 618 | return 0; | ||
| 619 | } | ||
| 620 | |||
| 621 | prev = all_samples; | ||
| 622 | while (prev->next) { | ||
| 623 | if (prev->next->timestamp < copy->timestamp) { | ||
| 624 | copy->next = prev->next; | ||
| 625 | prev->next = copy; | ||
| 626 | return 0; | ||
| 627 | } | ||
| 628 | prev = prev->next; | ||
| 629 | } | ||
| 630 | /* insert at the end of the list */ | ||
| 631 | prev->next = copy; | ||
| 632 | |||
| 633 | return 0; | ||
| 634 | } | ||
| 635 | |||
| 636 | static void sort_queued_samples(void) | ||
| 637 | { | ||
| 638 | struct sample_wrapper *cursor, *next; | ||
| 639 | |||
| 640 | cursor = all_samples; | ||
| 641 | all_samples = NULL; | ||
| 642 | |||
| 643 | while (cursor) { | ||
| 644 | next = cursor->next; | ||
| 645 | cursor->next = all_samples; | ||
| 646 | all_samples = cursor; | ||
| 647 | cursor = next; | ||
| 648 | } | ||
| 649 | } | ||
| 650 | |||
| 651 | /* | 566 | /* |
| 652 | * Sort the pid datastructure | 567 | * Sort the pid datastructure |
| 653 | */ | 568 | */ |
| @@ -1011,26 +926,12 @@ static void write_svg_file(const char *filename) | |||
| 1011 | svg_close(); | 926 | svg_close(); |
| 1012 | } | 927 | } |
| 1013 | 928 | ||
| 1014 | static void process_samples(struct perf_session *session) | ||
| 1015 | { | ||
| 1016 | struct sample_wrapper *cursor; | ||
| 1017 | event_t *event; | ||
| 1018 | |||
| 1019 | sort_queued_samples(); | ||
| 1020 | |||
| 1021 | cursor = all_samples; | ||
| 1022 | while (cursor) { | ||
| 1023 | event = (void *)&cursor->data; | ||
| 1024 | cursor = cursor->next; | ||
| 1025 | process_sample_event(event, session); | ||
| 1026 | } | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | static struct perf_event_ops event_ops = { | 929 | static struct perf_event_ops event_ops = { |
| 1030 | .comm = process_comm_event, | 930 | .comm = process_comm_event, |
| 1031 | .fork = process_fork_event, | 931 | .fork = process_fork_event, |
| 1032 | .exit = process_exit_event, | 932 | .exit = process_exit_event, |
| 1033 | .sample = queue_sample_event, | 933 | .sample = process_sample_event, |
| 934 | .ordered_samples = true, | ||
| 1034 | }; | 935 | }; |
| 1035 | 936 | ||
| 1036 | static int __cmd_timechart(void) | 937 | static int __cmd_timechart(void) |
| @@ -1048,8 +949,6 @@ static int __cmd_timechart(void) | |||
| 1048 | if (ret) | 949 | if (ret) |
| 1049 | goto out_delete; | 950 | goto out_delete; |
| 1050 | 951 | ||
| 1051 | process_samples(session); | ||
| 1052 | |||
| 1053 | end_sample_processing(); | 952 | end_sample_processing(); |
| 1054 | 953 | ||
| 1055 | sort_pids(); | 954 | sort_pids(); |
| @@ -1072,7 +971,6 @@ static const char *record_args[] = { | |||
| 1072 | "record", | 971 | "record", |
| 1073 | "-a", | 972 | "-a", |
| 1074 | "-R", | 973 | "-R", |
| 1075 | "-M", | ||
| 1076 | "-f", | 974 | "-f", |
| 1077 | "-c", "1", | 975 | "-c", "1", |
| 1078 | "-e", "power:power_start", | 976 | "-e", "power:power_start", |
