aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-timechart.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r--tools/perf/builtin-timechart.c36
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 @@
36static char const *input_name = "perf.data"; 36static char const *input_name = "perf.data";
37static char const *output_name = "output.svg"; 37static char const *output_name = "output.svg";
38 38
39
40static u64 sample_type;
41
42static unsigned int numcpus; 39static unsigned int numcpus;
43static u64 min_freq; /* Lowest CPU frequency seen */ 40static u64 min_freq; /* Lowest CPU frequency seen */
44static u64 max_freq; /* Highest CPU frequency seen */ 41static 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
481static int 478static int process_sample_event(event_t *event, struct perf_session *session)
482process_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
576static u64 sample_time(event_t *event) 572static 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 */
595static int queue_sample_event(event_t *event, struct perf_session *session __used) 591static 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(&copy->data, event, event->sample.header.size); 607 memcpy(&copy->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
1021static void process_samples(void) 1017static 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
1036static int sample_type_check(u64 type, struct perf_session *session __used) 1032static 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