diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-14 11:23:00 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-14 11:34:56 -0500 |
commit | c019879bcc5692ec9267c1cedad91f1794d0b693 (patch) | |
tree | ec499400b1ee0b1d93e961cc67b9dead9cd8c9a9 /tools/perf/builtin-timechart.c | |
parent | a328626b61aeda1a7d00a80c475c76ca1b815e0d (diff) |
perf session: Adopt the sample_type variable
All tools had copies, and perf diff would have to specify a
sample_type_check method just for copying it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260807780-19377-2-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r-- | tools/perf/builtin-timechart.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 3a0a89e41523..ffd81e87ce69 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -36,9 +36,6 @@ | |||
36 | static char const *input_name = "perf.data"; | 36 | static char const *input_name = "perf.data"; |
37 | static char const *output_name = "output.svg"; | 37 | static char const *output_name = "output.svg"; |
38 | 38 | ||
39 | |||
40 | static u64 sample_type; | ||
41 | |||
42 | static unsigned int numcpus; | 39 | static unsigned int numcpus; |
43 | static u64 min_freq; /* Lowest CPU frequency seen */ | 40 | static u64 min_freq; /* Lowest CPU frequency seen */ |
44 | static u64 max_freq; /* Highest CPU frequency seen */ | 41 | static u64 max_freq; /* Highest CPU frequency seen */ |
@@ -478,17 +475,16 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te) | |||
478 | } | 475 | } |
479 | 476 | ||
480 | 477 | ||
481 | static int | 478 | static int process_sample_event(event_t *event, struct perf_session *session) |
482 | process_sample_event(event_t *event) | ||
483 | { | 479 | { |
484 | struct sample_data data; | 480 | struct sample_data data; |
485 | struct trace_entry *te; | 481 | struct trace_entry *te; |
486 | 482 | ||
487 | memset(&data, 0, sizeof(data)); | 483 | memset(&data, 0, sizeof(data)); |
488 | 484 | ||
489 | event__parse_sample(event, sample_type, &data); | 485 | event__parse_sample(event, session->sample_type, &data); |
490 | 486 | ||
491 | if (sample_type & PERF_SAMPLE_TIME) { | 487 | if (session->sample_type & PERF_SAMPLE_TIME) { |
492 | if (!first_time || first_time > data.time) | 488 | if (!first_time || first_time > data.time) |
493 | first_time = data.time; | 489 | first_time = data.time; |
494 | if (last_time < data.time) | 490 | if (last_time < data.time) |
@@ -496,7 +492,7 @@ process_sample_event(event_t *event) | |||
496 | } | 492 | } |
497 | 493 | ||
498 | te = (void *)data.raw_data; | 494 | te = (void *)data.raw_data; |
499 | if (sample_type & PERF_SAMPLE_RAW && data.raw_size > 0) { | 495 | if (session->sample_type & PERF_SAMPLE_RAW && data.raw_size > 0) { |
500 | char *event_str; | 496 | char *event_str; |
501 | struct power_entry *pe; | 497 | struct power_entry *pe; |
502 | 498 | ||
@@ -573,16 +569,16 @@ static void end_sample_processing(void) | |||
573 | } | 569 | } |
574 | } | 570 | } |
575 | 571 | ||
576 | static u64 sample_time(event_t *event) | 572 | static u64 sample_time(event_t *event, const struct perf_session *session) |
577 | { | 573 | { |
578 | int cursor; | 574 | int cursor; |
579 | 575 | ||
580 | cursor = 0; | 576 | cursor = 0; |
581 | if (sample_type & PERF_SAMPLE_IP) | 577 | if (session->sample_type & PERF_SAMPLE_IP) |
582 | cursor++; | 578 | cursor++; |
583 | if (sample_type & PERF_SAMPLE_TID) | 579 | if (session->sample_type & PERF_SAMPLE_TID) |
584 | cursor++; | 580 | cursor++; |
585 | if (sample_type & PERF_SAMPLE_TIME) | 581 | if (session->sample_type & PERF_SAMPLE_TIME) |
586 | return event->sample.array[cursor]; | 582 | return event->sample.array[cursor]; |
587 | return 0; | 583 | return 0; |
588 | } | 584 | } |
@@ -592,7 +588,7 @@ static u64 sample_time(event_t *event) | |||
592 | * We first queue all events, sorted backwards by insertion. | 588 | * We first queue all events, sorted backwards by insertion. |
593 | * The order will get flipped later. | 589 | * The order will get flipped later. |
594 | */ | 590 | */ |
595 | static int queue_sample_event(event_t *event, struct perf_session *session __used) | 591 | static int queue_sample_event(event_t *event, struct perf_session *session) |
596 | { | 592 | { |
597 | struct sample_wrapper *copy, *prev; | 593 | struct sample_wrapper *copy, *prev; |
598 | int size; | 594 | int size; |
@@ -606,7 +602,7 @@ static int queue_sample_event(event_t *event, struct perf_session *session __use | |||
606 | memset(copy, 0, size); | 602 | memset(copy, 0, size); |
607 | 603 | ||
608 | copy->next = NULL; | 604 | copy->next = NULL; |
609 | copy->timestamp = sample_time(event); | 605 | copy->timestamp = sample_time(event, session); |
610 | 606 | ||
611 | memcpy(©->data, event, event->sample.header.size); | 607 | memcpy(©->data, event, event->sample.header.size); |
612 | 608 | ||
@@ -1018,7 +1014,7 @@ static void write_svg_file(const char *filename) | |||
1018 | svg_close(); | 1014 | svg_close(); |
1019 | } | 1015 | } |
1020 | 1016 | ||
1021 | static void process_samples(void) | 1017 | static void process_samples(struct perf_session *session) |
1022 | { | 1018 | { |
1023 | struct sample_wrapper *cursor; | 1019 | struct sample_wrapper *cursor; |
1024 | event_t *event; | 1020 | event_t *event; |
@@ -1029,15 +1025,13 @@ static void process_samples(void) | |||
1029 | while (cursor) { | 1025 | while (cursor) { |
1030 | event = (void *)&cursor->data; | 1026 | event = (void *)&cursor->data; |
1031 | cursor = cursor->next; | 1027 | cursor = cursor->next; |
1032 | process_sample_event(event); | 1028 | process_sample_event(event, session); |
1033 | } | 1029 | } |
1034 | } | 1030 | } |
1035 | 1031 | ||
1036 | static int sample_type_check(u64 type, struct perf_session *session __used) | 1032 | static int sample_type_check(struct perf_session *session) |
1037 | { | 1033 | { |
1038 | sample_type = type; | 1034 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { |
1039 | |||
1040 | if (!(sample_type & PERF_SAMPLE_RAW)) { | ||
1041 | fprintf(stderr, "No trace samples found in the file.\n" | 1035 | fprintf(stderr, "No trace samples found in the file.\n" |
1042 | "Have you used 'perf timechart record' to record it?\n"); | 1036 | "Have you used 'perf timechart record' to record it?\n"); |
1043 | return -1; | 1037 | return -1; |
@@ -1067,7 +1061,7 @@ static int __cmd_timechart(void) | |||
1067 | if (ret) | 1061 | if (ret) |
1068 | goto out_delete; | 1062 | goto out_delete; |
1069 | 1063 | ||
1070 | process_samples(); | 1064 | process_samples(session); |
1071 | 1065 | ||
1072 | end_sample_processing(); | 1066 | end_sample_processing(); |
1073 | 1067 | ||