diff options
-rw-r--r-- | tools/perf/builtin-sched.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 4 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 9 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 1 | ||||
-rw-r--r-- | tools/perf/util/session.c | 41 | ||||
-rw-r--r-- | tools/perf/util/session.h | 6 |
6 files changed, 34 insertions, 33 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index cc28b85dabd5..138229439a93 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1475,9 +1475,9 @@ static int perf_sched__read_events(struct perf_sched *sched, bool destroy, | |||
1475 | goto out_delete; | 1475 | goto out_delete; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | sched->nr_events = session->hists.stats.nr_events[0]; | 1478 | sched->nr_events = session->stats.nr_events[0]; |
1479 | sched->nr_lost_events = session->hists.stats.total_lost; | 1479 | sched->nr_lost_events = session->stats.total_lost; |
1480 | sched->nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST]; | 1480 | sched->nr_lost_chunks = session->stats.nr_events[PERF_RECORD_LOST]; |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | if (destroy) | 1483 | if (destroy) |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index f5fd260f7b20..996b10c702ba 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -728,7 +728,7 @@ static void perf_event__process_sample(struct perf_tool *tool, | |||
728 | 728 | ||
729 | if (!machine) { | 729 | if (!machine) { |
730 | pr_err("%u unprocessable samples recorded.\n", | 730 | pr_err("%u unprocessable samples recorded.\n", |
731 | top->session->hists.stats.nr_unprocessable_samples++); | 731 | top->session->stats.nr_unprocessable_samples++); |
732 | return; | 732 | return; |
733 | } | 733 | } |
734 | 734 | ||
@@ -878,7 +878,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
878 | hists__inc_nr_events(&evsel->hists, event->header.type); | 878 | hists__inc_nr_events(&evsel->hists, event->header.type); |
879 | machine__process_event(machine, event); | 879 | machine__process_event(machine, event); |
880 | } else | 880 | } else |
881 | ++session->hists.stats.nr_unknown_events; | 881 | ++session->stats.nr_unknown_events; |
882 | } | 882 | } |
883 | } | 883 | } |
884 | 884 | ||
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 37179af74409..965ebf948f2f 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -717,10 +717,15 @@ int hist_entry__annotate(struct hist_entry *he, size_t privsize) | |||
717 | return symbol__annotate(he->ms.sym, he->ms.map, privsize); | 717 | return symbol__annotate(he->ms.sym, he->ms.map, privsize); |
718 | } | 718 | } |
719 | 719 | ||
720 | void events_stats__inc(struct events_stats *stats, u32 type) | ||
721 | { | ||
722 | ++stats->nr_events[0]; | ||
723 | ++stats->nr_events[type]; | ||
724 | } | ||
725 | |||
720 | void hists__inc_nr_events(struct hists *hists, u32 type) | 726 | void hists__inc_nr_events(struct hists *hists, u32 type) |
721 | { | 727 | { |
722 | ++hists->stats.nr_events[0]; | 728 | events_stats__inc(&hists->stats, type); |
723 | ++hists->stats.nr_events[type]; | ||
724 | } | 729 | } |
725 | 730 | ||
726 | static struct hist_entry *hists__add_dummy_entry(struct hists *hists, | 731 | static struct hist_entry *hists__add_dummy_entry(struct hists *hists, |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index cb6533b2977a..38624686ee9a 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -98,6 +98,7 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows); | |||
98 | 98 | ||
99 | void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); | 99 | void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); |
100 | void hists__inc_nr_events(struct hists *self, u32 type); | 100 | void hists__inc_nr_events(struct hists *self, u32 type); |
101 | void events_stats__inc(struct events_stats *stats, u32 type); | ||
101 | size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); | 102 | size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); |
102 | 103 | ||
103 | size_t hists__fprintf(struct hists *self, bool show_header, int max_rows, | 104 | size_t hists__fprintf(struct hists *self, bool show_header, int max_rows, |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 6e8dd2abcf0b..b0bcc328d1fb 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -133,7 +133,6 @@ struct perf_session *perf_session__new(const char *filename, int mode, | |||
133 | INIT_LIST_HEAD(&self->ordered_samples.sample_cache); | 133 | INIT_LIST_HEAD(&self->ordered_samples.sample_cache); |
134 | INIT_LIST_HEAD(&self->ordered_samples.to_free); | 134 | INIT_LIST_HEAD(&self->ordered_samples.to_free); |
135 | machine__init(&self->host_machine, "", HOST_KERNEL_ID); | 135 | machine__init(&self->host_machine, "", HOST_KERNEL_ID); |
136 | hists__init(&self->hists); | ||
137 | 136 | ||
138 | if (mode == O_RDONLY) { | 137 | if (mode == O_RDONLY) { |
139 | if (perf_session__open(self, force) < 0) | 138 | if (perf_session__open(self, force) < 0) |
@@ -863,11 +862,11 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
863 | case PERF_RECORD_SAMPLE: | 862 | case PERF_RECORD_SAMPLE: |
864 | dump_sample(evsel, event, sample); | 863 | dump_sample(evsel, event, sample); |
865 | if (evsel == NULL) { | 864 | if (evsel == NULL) { |
866 | ++session->hists.stats.nr_unknown_id; | 865 | ++session->stats.nr_unknown_id; |
867 | return 0; | 866 | return 0; |
868 | } | 867 | } |
869 | if (machine == NULL) { | 868 | if (machine == NULL) { |
870 | ++session->hists.stats.nr_unprocessable_samples; | 869 | ++session->stats.nr_unprocessable_samples; |
871 | return 0; | 870 | return 0; |
872 | } | 871 | } |
873 | return tool->sample(tool, event, sample, evsel, machine); | 872 | return tool->sample(tool, event, sample, evsel, machine); |
@@ -881,7 +880,7 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
881 | return tool->exit(tool, event, sample, machine); | 880 | return tool->exit(tool, event, sample, machine); |
882 | case PERF_RECORD_LOST: | 881 | case PERF_RECORD_LOST: |
883 | if (tool->lost == perf_event__process_lost) | 882 | if (tool->lost == perf_event__process_lost) |
884 | session->hists.stats.total_lost += event->lost.lost; | 883 | session->stats.total_lost += event->lost.lost; |
885 | return tool->lost(tool, event, sample, machine); | 884 | return tool->lost(tool, event, sample, machine); |
886 | case PERF_RECORD_READ: | 885 | case PERF_RECORD_READ: |
887 | return tool->read(tool, event, sample, evsel, machine); | 886 | return tool->read(tool, event, sample, evsel, machine); |
@@ -890,7 +889,7 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
890 | case PERF_RECORD_UNTHROTTLE: | 889 | case PERF_RECORD_UNTHROTTLE: |
891 | return tool->unthrottle(tool, event, sample, machine); | 890 | return tool->unthrottle(tool, event, sample, machine); |
892 | default: | 891 | default: |
893 | ++session->hists.stats.nr_unknown_events; | 892 | ++session->stats.nr_unknown_events; |
894 | return -1; | 893 | return -1; |
895 | } | 894 | } |
896 | } | 895 | } |
@@ -904,8 +903,8 @@ static int perf_session__preprocess_sample(struct perf_session *session, | |||
904 | 903 | ||
905 | if (!ip_callchain__valid(sample->callchain, event)) { | 904 | if (!ip_callchain__valid(sample->callchain, event)) { |
906 | pr_debug("call-chain problem with event, skipping it.\n"); | 905 | pr_debug("call-chain problem with event, skipping it.\n"); |
907 | ++session->hists.stats.nr_invalid_chains; | 906 | ++session->stats.nr_invalid_chains; |
908 | session->hists.stats.total_invalid_chains += sample->period; | 907 | session->stats.total_invalid_chains += sample->period; |
909 | return -EINVAL; | 908 | return -EINVAL; |
910 | } | 909 | } |
911 | return 0; | 910 | return 0; |
@@ -963,7 +962,7 @@ static int perf_session__process_event(struct perf_session *session, | |||
963 | if (event->header.type >= PERF_RECORD_HEADER_MAX) | 962 | if (event->header.type >= PERF_RECORD_HEADER_MAX) |
964 | return -EINVAL; | 963 | return -EINVAL; |
965 | 964 | ||
966 | hists__inc_nr_events(&session->hists, event->header.type); | 965 | events_stats__inc(&session->stats, event->header.type); |
967 | 966 | ||
968 | if (event->header.type >= PERF_RECORD_USER_TYPE_START) | 967 | if (event->header.type >= PERF_RECORD_USER_TYPE_START) |
969 | return perf_session__process_user_event(session, event, tool, file_offset); | 968 | return perf_session__process_user_event(session, event, tool, file_offset); |
@@ -1018,39 +1017,39 @@ static void perf_session__warn_about_errors(const struct perf_session *session, | |||
1018 | const struct perf_tool *tool) | 1017 | const struct perf_tool *tool) |
1019 | { | 1018 | { |
1020 | if (tool->lost == perf_event__process_lost && | 1019 | if (tool->lost == perf_event__process_lost && |
1021 | session->hists.stats.nr_events[PERF_RECORD_LOST] != 0) { | 1020 | session->stats.nr_events[PERF_RECORD_LOST] != 0) { |
1022 | ui__warning("Processed %d events and lost %d chunks!\n\n" | 1021 | ui__warning("Processed %d events and lost %d chunks!\n\n" |
1023 | "Check IO/CPU overload!\n\n", | 1022 | "Check IO/CPU overload!\n\n", |
1024 | session->hists.stats.nr_events[0], | 1023 | session->stats.nr_events[0], |
1025 | session->hists.stats.nr_events[PERF_RECORD_LOST]); | 1024 | session->stats.nr_events[PERF_RECORD_LOST]); |
1026 | } | 1025 | } |
1027 | 1026 | ||
1028 | if (session->hists.stats.nr_unknown_events != 0) { | 1027 | if (session->stats.nr_unknown_events != 0) { |
1029 | ui__warning("Found %u unknown events!\n\n" | 1028 | ui__warning("Found %u unknown events!\n\n" |
1030 | "Is this an older tool processing a perf.data " | 1029 | "Is this an older tool processing a perf.data " |
1031 | "file generated by a more recent tool?\n\n" | 1030 | "file generated by a more recent tool?\n\n" |
1032 | "If that is not the case, consider " | 1031 | "If that is not the case, consider " |
1033 | "reporting to linux-kernel@vger.kernel.org.\n\n", | 1032 | "reporting to linux-kernel@vger.kernel.org.\n\n", |
1034 | session->hists.stats.nr_unknown_events); | 1033 | session->stats.nr_unknown_events); |
1035 | } | 1034 | } |
1036 | 1035 | ||
1037 | if (session->hists.stats.nr_unknown_id != 0) { | 1036 | if (session->stats.nr_unknown_id != 0) { |
1038 | ui__warning("%u samples with id not present in the header\n", | 1037 | ui__warning("%u samples with id not present in the header\n", |
1039 | session->hists.stats.nr_unknown_id); | 1038 | session->stats.nr_unknown_id); |
1040 | } | 1039 | } |
1041 | 1040 | ||
1042 | if (session->hists.stats.nr_invalid_chains != 0) { | 1041 | if (session->stats.nr_invalid_chains != 0) { |
1043 | ui__warning("Found invalid callchains!\n\n" | 1042 | ui__warning("Found invalid callchains!\n\n" |
1044 | "%u out of %u events were discarded for this reason.\n\n" | 1043 | "%u out of %u events were discarded for this reason.\n\n" |
1045 | "Consider reporting to linux-kernel@vger.kernel.org.\n\n", | 1044 | "Consider reporting to linux-kernel@vger.kernel.org.\n\n", |
1046 | session->hists.stats.nr_invalid_chains, | 1045 | session->stats.nr_invalid_chains, |
1047 | session->hists.stats.nr_events[PERF_RECORD_SAMPLE]); | 1046 | session->stats.nr_events[PERF_RECORD_SAMPLE]); |
1048 | } | 1047 | } |
1049 | 1048 | ||
1050 | if (session->hists.stats.nr_unprocessable_samples != 0) { | 1049 | if (session->stats.nr_unprocessable_samples != 0) { |
1051 | ui__warning("%u unprocessable samples recorded.\n" | 1050 | ui__warning("%u unprocessable samples recorded.\n" |
1052 | "Do you have a KVM guest running and not using 'perf kvm'?\n", | 1051 | "Do you have a KVM guest running and not using 'perf kvm'?\n", |
1053 | session->hists.stats.nr_unprocessable_samples); | 1052 | session->stats.nr_unprocessable_samples); |
1054 | } | 1053 | } |
1055 | } | 1054 | } |
1056 | 1055 | ||
@@ -1353,7 +1352,7 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp) | |||
1353 | struct perf_evsel *pos; | 1352 | struct perf_evsel *pos; |
1354 | size_t ret = fprintf(fp, "Aggregated stats:\n"); | 1353 | size_t ret = fprintf(fp, "Aggregated stats:\n"); |
1355 | 1354 | ||
1356 | ret += events_stats__fprintf(&session->hists.stats, fp); | 1355 | ret += events_stats__fprintf(&session->stats, fp); |
1357 | 1356 | ||
1358 | list_for_each_entry(pos, &session->evlist->entries, node) { | 1357 | list_for_each_entry(pos, &session->evlist->entries, node) { |
1359 | ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos)); | 1358 | ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos)); |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 426ca0c3c5b6..57066cb867a6 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -34,11 +34,7 @@ struct perf_session { | |||
34 | struct rb_root machines; | 34 | struct rb_root machines; |
35 | struct perf_evlist *evlist; | 35 | struct perf_evlist *evlist; |
36 | struct pevent *pevent; | 36 | struct pevent *pevent; |
37 | /* | 37 | struct events_stats stats; |
38 | * FIXME: Need to split this up further, we need global | ||
39 | * stats + per event stats. | ||
40 | */ | ||
41 | struct hists hists; | ||
42 | int fd; | 38 | int fd; |
43 | bool fd_pipe; | 39 | bool fd_pipe; |
44 | bool repipe; | 40 | bool repipe; |