diff options
| -rw-r--r-- | tools/perf/builtin-kmem.c | 10 | ||||
| -rw-r--r-- | tools/perf/builtin-report.c | 12 | ||||
| -rw-r--r-- | tools/perf/builtin-sched.c | 12 | ||||
| -rw-r--r-- | tools/perf/builtin-timechart.c | 36 | ||||
| -rw-r--r-- | tools/perf/builtin-trace.c | 12 | ||||
| -rw-r--r-- | tools/perf/util/data_map.c | 6 | ||||
| -rw-r--r-- | tools/perf/util/session.h | 4 |
7 files changed, 34 insertions, 58 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 3b329c66b505..dda60869faad 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
| @@ -20,8 +20,6 @@ typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); | |||
| 20 | 20 | ||
| 21 | static char const *input_name = "perf.data"; | 21 | static char const *input_name = "perf.data"; |
| 22 | 22 | ||
| 23 | static u64 sample_type; | ||
| 24 | |||
| 25 | static int alloc_flag; | 23 | static int alloc_flag; |
| 26 | static int caller_flag; | 24 | static int caller_flag; |
| 27 | 25 | ||
| @@ -321,7 +319,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 321 | data.cpu = -1; | 319 | data.cpu = -1; |
| 322 | data.period = 1; | 320 | data.period = 1; |
| 323 | 321 | ||
| 324 | event__parse_sample(event, sample_type, &data); | 322 | event__parse_sample(event, session->sample_type, &data); |
| 325 | 323 | ||
| 326 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", | 324 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
| 327 | event->header.misc, | 325 | event->header.misc, |
| @@ -344,11 +342,9 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 344 | return 0; | 342 | return 0; |
| 345 | } | 343 | } |
| 346 | 344 | ||
| 347 | static int sample_type_check(u64 type, struct perf_session *session __used) | 345 | static int sample_type_check(struct perf_session *session) |
| 348 | { | 346 | { |
| 349 | sample_type = type; | 347 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { |
| 350 | |||
| 351 | if (!(sample_type & PERF_SAMPLE_RAW)) { | ||
| 352 | fprintf(stderr, | 348 | fprintf(stderr, |
| 353 | "No trace sample to read. Did you call perf record " | 349 | "No trace sample to read. Did you call perf record " |
| 354 | "without -R?"); | 350 | "without -R?"); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 5141cdccbb65..142c475f9918 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -52,8 +52,6 @@ static int exclude_other = 1; | |||
| 52 | 52 | ||
| 53 | static char callchain_default_opt[] = "fractal,0.5"; | 53 | static char callchain_default_opt[] = "fractal,0.5"; |
| 54 | 54 | ||
| 55 | static u64 sample_type; | ||
| 56 | |||
| 57 | struct symbol_conf symbol_conf; | 55 | struct symbol_conf symbol_conf; |
| 58 | 56 | ||
| 59 | 57 | ||
| @@ -557,7 +555,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 557 | memset(&data, 0, sizeof(data)); | 555 | memset(&data, 0, sizeof(data)); |
| 558 | data.period = 1; | 556 | data.period = 1; |
| 559 | 557 | ||
| 560 | event__parse_sample(event, sample_type, &data); | 558 | event__parse_sample(event, session->sample_type, &data); |
| 561 | 559 | ||
| 562 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", | 560 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
| 563 | event->header.misc, | 561 | event->header.misc, |
| @@ -565,7 +563,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 565 | (void *)(long)data.ip, | 563 | (void *)(long)data.ip, |
| 566 | (long long)data.period); | 564 | (long long)data.period); |
| 567 | 565 | ||
| 568 | if (sample_type & PERF_SAMPLE_CALLCHAIN) { | 566 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) { |
| 569 | unsigned int i; | 567 | unsigned int i; |
| 570 | 568 | ||
| 571 | dump_printf("... chain: nr:%Lu\n", data.callchain->nr); | 569 | dump_printf("... chain: nr:%Lu\n", data.callchain->nr); |
| @@ -664,11 +662,9 @@ static int process_read_event(event_t *event, struct perf_session *session __use | |||
| 664 | return 0; | 662 | return 0; |
| 665 | } | 663 | } |
| 666 | 664 | ||
| 667 | static int sample_type_check(u64 type, struct perf_session *session) | 665 | static int sample_type_check(struct perf_session *session) |
| 668 | { | 666 | { |
| 669 | sample_type = type; | 667 | if (!(session->sample_type & PERF_SAMPLE_CALLCHAIN)) { |
| 670 | |||
| 671 | if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) { | ||
| 672 | if (sort__has_parent) { | 668 | if (sort__has_parent) { |
| 673 | fprintf(stderr, "selected --sort parent, but no" | 669 | fprintf(stderr, "selected --sort parent, but no" |
| 674 | " callchain data. Did you call" | 670 | " callchain data. Did you call" |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 412ae924640a..d67f274adba0 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
| @@ -21,8 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | static char const *input_name = "perf.data"; | 22 | static char const *input_name = "perf.data"; |
| 23 | 23 | ||
| 24 | static u64 sample_type; | ||
| 25 | |||
| 26 | static char default_sort_order[] = "avg, max, switch, runtime"; | 24 | static char default_sort_order[] = "avg, max, switch, runtime"; |
| 27 | static char *sort_order = default_sort_order; | 25 | static char *sort_order = default_sort_order; |
| 28 | 26 | ||
| @@ -1613,7 +1611,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 1613 | struct sample_data data; | 1611 | struct sample_data data; |
| 1614 | struct thread *thread; | 1612 | struct thread *thread; |
| 1615 | 1613 | ||
| 1616 | if (!(sample_type & PERF_SAMPLE_RAW)) | 1614 | if (!(session->sample_type & PERF_SAMPLE_RAW)) |
| 1617 | return 0; | 1615 | return 0; |
| 1618 | 1616 | ||
| 1619 | memset(&data, 0, sizeof(data)); | 1617 | memset(&data, 0, sizeof(data)); |
| @@ -1621,7 +1619,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 1621 | data.cpu = -1; | 1619 | data.cpu = -1; |
| 1622 | data.period = -1; | 1620 | data.period = -1; |
| 1623 | 1621 | ||
| 1624 | event__parse_sample(event, sample_type, &data); | 1622 | event__parse_sample(event, session->sample_type, &data); |
| 1625 | 1623 | ||
| 1626 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", | 1624 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
| 1627 | event->header.misc, | 1625 | event->header.misc, |
| @@ -1655,11 +1653,9 @@ static int process_lost_event(event_t *event __used, | |||
| 1655 | return 0; | 1653 | return 0; |
| 1656 | } | 1654 | } |
| 1657 | 1655 | ||
| 1658 | static int sample_type_check(u64 type, struct perf_session *session __used) | 1656 | static int sample_type_check(struct perf_session *session __used) |
| 1659 | { | 1657 | { |
| 1660 | sample_type = type; | 1658 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { |
| 1661 | |||
| 1662 | if (!(sample_type & PERF_SAMPLE_RAW)) { | ||
| 1663 | fprintf(stderr, | 1659 | fprintf(stderr, |
| 1664 | "No trace sample to read. Did you call perf record " | 1660 | "No trace sample to read. Did you call perf record " |
| 1665 | "without -R?"); | 1661 | "without -R?"); |
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 | ||
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index adce442dd603..9ee976dc395b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -61,8 +61,6 @@ static int cleanup_scripting(void) | |||
| 61 | 61 | ||
| 62 | static char const *input_name = "perf.data"; | 62 | static char const *input_name = "perf.data"; |
| 63 | 63 | ||
| 64 | static u64 sample_type; | ||
| 65 | |||
| 66 | static int process_sample_event(event_t *event, struct perf_session *session) | 64 | static int process_sample_event(event_t *event, struct perf_session *session) |
| 67 | { | 65 | { |
| 68 | struct sample_data data; | 66 | struct sample_data data; |
| @@ -73,7 +71,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 73 | data.cpu = -1; | 71 | data.cpu = -1; |
| 74 | data.period = 1; | 72 | data.period = 1; |
| 75 | 73 | ||
| 76 | event__parse_sample(event, sample_type, &data); | 74 | event__parse_sample(event, session->sample_type, &data); |
| 77 | 75 | ||
| 78 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", | 76 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
| 79 | event->header.misc, | 77 | event->header.misc, |
| @@ -88,7 +86,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 88 | return -1; | 86 | return -1; |
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | if (sample_type & PERF_SAMPLE_RAW) { | 89 | if (session->sample_type & PERF_SAMPLE_RAW) { |
| 92 | /* | 90 | /* |
| 93 | * FIXME: better resolve from pid from the struct trace_entry | 91 | * FIXME: better resolve from pid from the struct trace_entry |
| 94 | * field, although it should be the same than this perf | 92 | * field, although it should be the same than this perf |
| @@ -103,11 +101,9 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 103 | return 0; | 101 | return 0; |
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | static int sample_type_check(u64 type, struct perf_session *session __used) | 104 | static int sample_type_check(struct perf_session *session) |
| 107 | { | 105 | { |
| 108 | sample_type = type; | 106 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { |
| 109 | |||
| 110 | if (!(sample_type & PERF_SAMPLE_RAW)) { | ||
| 111 | fprintf(stderr, | 107 | fprintf(stderr, |
| 112 | "No trace sample to read. Did you call perf record " | 108 | "No trace sample to read. Did you call perf record " |
| 113 | "without -R?"); | 109 | "without -R?"); |
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c index 08c4cf5e66ba..b557b836de3d 100644 --- a/tools/perf/util/data_map.c +++ b/tools/perf/util/data_map.c | |||
| @@ -144,7 +144,6 @@ int perf_session__process_events(struct perf_session *self, | |||
| 144 | unsigned long head, shift; | 144 | unsigned long head, shift; |
| 145 | unsigned long offset = 0; | 145 | unsigned long offset = 0; |
| 146 | size_t page_size; | 146 | size_t page_size; |
| 147 | u64 sample_type; | ||
| 148 | event_t *event; | 147 | event_t *event; |
| 149 | uint32_t size; | 148 | uint32_t size; |
| 150 | char *buf; | 149 | char *buf; |
| @@ -157,11 +156,10 @@ int perf_session__process_events(struct perf_session *self, | |||
| 157 | page_size = getpagesize(); | 156 | page_size = getpagesize(); |
| 158 | 157 | ||
| 159 | head = self->header.data_offset; | 158 | head = self->header.data_offset; |
| 160 | sample_type = perf_header__sample_type(&self->header); | 159 | self->sample_type = perf_header__sample_type(&self->header); |
| 161 | 160 | ||
| 162 | err = -EINVAL; | 161 | err = -EINVAL; |
| 163 | if (ops->sample_type_check && | 162 | if (ops->sample_type_check && ops->sample_type_check(self) < 0) |
| 164 | ops->sample_type_check(sample_type, self) < 0) | ||
| 165 | goto out_err; | 163 | goto out_err; |
| 166 | 164 | ||
| 167 | if (!ops->full_paths) { | 165 | if (!ops->full_paths) { |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index a8f3a49ca43a..4e8a21c5304c 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
| @@ -19,6 +19,7 @@ struct perf_session { | |||
| 19 | struct rb_root threads; | 19 | struct rb_root threads; |
| 20 | struct thread *last_match; | 20 | struct thread *last_match; |
| 21 | struct rb_root hists; | 21 | struct rb_root hists; |
| 22 | u64 sample_type; | ||
| 22 | int fd; | 23 | int fd; |
| 23 | int cwdlen; | 24 | int cwdlen; |
| 24 | char *cwd; | 25 | char *cwd; |
| @@ -39,8 +40,7 @@ struct perf_event_ops { | |||
| 39 | event_op process_read_event; | 40 | event_op process_read_event; |
| 40 | event_op process_throttle_event; | 41 | event_op process_throttle_event; |
| 41 | event_op process_unthrottle_event; | 42 | event_op process_unthrottle_event; |
| 42 | int (*sample_type_check)(u64 sample_type, | 43 | int (*sample_type_check)(struct perf_session *session); |
| 43 | struct perf_session *session); | ||
| 44 | unsigned long total_unknown; | 44 | unsigned long total_unknown; |
| 45 | bool full_paths; | 45 | bool full_paths; |
| 46 | }; | 46 | }; |
