aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-diff.c2
-rw-r--r--tools/perf/builtin-report.c8
-rw-r--r--tools/perf/builtin-sched.c17
-rw-r--r--tools/perf/builtin-trace.c2
-rw-r--r--tools/perf/util/event.c2
-rw-r--r--tools/perf/util/hist.c20
-rw-r--r--tools/perf/util/hist.h16
-rw-r--r--tools/perf/util/newt.c6
-rw-r--r--tools/perf/util/session.c2
9 files changed, 41 insertions, 34 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 3a95a0260a5b..6dd4bdae8a87 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -54,7 +54,7 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
54 return -1; 54 return -1;
55 } 55 }
56 56
57 session->hists.stats.total += data.period; 57 session->hists.stats.total_period += data.period;
58 return 0; 58 return 0;
59} 59}
60 60
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index f13cda1ef059..b8f47ded6287 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -138,14 +138,14 @@ static int add_event_total(struct perf_session *session,
138 if (!hists) 138 if (!hists)
139 return -ENOMEM; 139 return -ENOMEM;
140 140
141 hists->stats.total += data->period; 141 hists->stats.total_period += data->period;
142 /* 142 /*
143 * FIXME: add_event_total should be moved from here to 143 * FIXME: add_event_total should be moved from here to
144 * perf_session__process_event so that the proper hist is passed to 144 * perf_session__process_event so that the proper hist is passed to
145 * the event_op methods. 145 * the event_op methods.
146 */ 146 */
147 hists__inc_nr_events(hists, PERF_RECORD_SAMPLE); 147 hists__inc_nr_events(hists, PERF_RECORD_SAMPLE);
148 session->hists.stats.total += data->period; 148 session->hists.stats.total_period += data->period;
149 return 0; 149 return 0;
150} 150}
151 151
@@ -322,10 +322,10 @@ static int __cmd_report(void)
322 if (rb_first(&session->hists.entries) == 322 if (rb_first(&session->hists.entries) ==
323 rb_last(&session->hists.entries)) 323 rb_last(&session->hists.entries))
324 fprintf(stdout, "# Samples: %Ld\n#\n", 324 fprintf(stdout, "# Samples: %Ld\n#\n",
325 hists->stats.total); 325 hists->stats.total_period);
326 else 326 else
327 fprintf(stdout, "# Samples: %Ld %s\n#\n", 327 fprintf(stdout, "# Samples: %Ld %s\n#\n",
328 hists->stats.total, 328 hists->stats.total_period,
329 __event_name(hists->type, hists->config)); 329 __event_name(hists->type, hists->config));
330 330
331 hists__fprintf(hists, NULL, false, stdout); 331 hists__fprintf(hists, NULL, false, stdout);
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index aef6ed0e119c..be7bc9264710 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1641,19 +1641,10 @@ static int process_sample_event(event_t *event, struct perf_session *session)
1641 return 0; 1641 return 0;
1642} 1642}
1643 1643
1644static int process_lost_event(event_t *event __used,
1645 struct perf_session *session __used)
1646{
1647 nr_lost_chunks++;
1648 nr_lost_events += event->lost.lost;
1649
1650 return 0;
1651}
1652
1653static struct perf_event_ops event_ops = { 1644static struct perf_event_ops event_ops = {
1654 .sample = process_sample_event, 1645 .sample = process_sample_event,
1655 .comm = event__process_comm, 1646 .comm = event__process_comm,
1656 .lost = process_lost_event, 1647 .lost = event__process_lost,
1657 .ordered_samples = true, 1648 .ordered_samples = true,
1658}; 1649};
1659 1650
@@ -1664,8 +1655,12 @@ static int read_events(void)
1664 if (session == NULL) 1655 if (session == NULL)
1665 return -ENOMEM; 1656 return -ENOMEM;
1666 1657
1667 if (perf_session__has_traces(session, "record -R")) 1658 if (perf_session__has_traces(session, "record -R")) {
1668 err = perf_session__process_events(session, &event_ops); 1659 err = perf_session__process_events(session, &event_ops);
1660 nr_events = session->hists.stats.nr_events[0];
1661 nr_lost_events = session->hists.stats.total_lost;
1662 nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
1663 }
1669 1664
1670 perf_session__delete(session); 1665 perf_session__delete(session);
1671 return err; 1666 return err;
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 95fcb0517a9d..dddf3f01b5ab 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -109,7 +109,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
109 data.time, thread->comm); 109 data.time, thread->comm);
110 } 110 }
111 111
112 session->hists.stats.total += data.period; 112 session->hists.stats.total_period += data.period;
113 return 0; 113 return 0;
114} 114}
115 115
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 3e8fec173041..50771b5813ee 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -385,7 +385,7 @@ int event__process_comm(event_t *self, struct perf_session *session)
385int event__process_lost(event_t *self, struct perf_session *session) 385int event__process_lost(event_t *self, struct perf_session *session)
386{ 386{
387 dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); 387 dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost);
388 session->hists.stats.lost += self->lost.lost; 388 session->hists.stats.total_lost += self->lost.lost;
389 return 0; 389 return 0;
390} 390}
391 391
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 1614ad710046..c59224518083 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -239,7 +239,7 @@ void hists__output_resort(struct hists *self)
239 struct hist_entry *n; 239 struct hist_entry *n;
240 u64 min_callchain_hits; 240 u64 min_callchain_hits;
241 241
242 min_callchain_hits = self->stats.total * (callchain_param.min_percent / 100); 242 min_callchain_hits = self->stats.total_period * (callchain_param.min_percent / 100);
243 243
244 tmp = RB_ROOT; 244 tmp = RB_ROOT;
245 next = rb_first(&self->entries); 245 next = rb_first(&self->entries);
@@ -525,7 +525,7 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
525 525
526 if (pair_hists) { 526 if (pair_hists) {
527 count = self->pair ? self->pair->count : 0; 527 count = self->pair ? self->pair->count : 0;
528 total = pair_hists->stats.total; 528 total = pair_hists->stats.total_period;
529 count_sys = self->pair ? self->pair->count_sys : 0; 529 count_sys = self->pair ? self->pair->count_sys : 0;
530 count_us = self->pair ? self->pair->count_us : 0; 530 count_us = self->pair ? self->pair->count_us : 0;
531 count_guest_sys = self->pair ? self->pair->count_guest_sys : 0; 531 count_guest_sys = self->pair ? self->pair->count_guest_sys : 0;
@@ -769,10 +769,10 @@ print_entries:
769 ++position; 769 ++position;
770 } 770 }
771 ret += hist_entry__fprintf(h, pair, show_displacement, 771 ret += hist_entry__fprintf(h, pair, show_displacement,
772 displacement, fp, self->stats.total); 772 displacement, fp, self->stats.total_period);
773 773
774 if (symbol_conf.use_callchain) 774 if (symbol_conf.use_callchain)
775 ret += hist_entry__fprintf_callchain(h, fp, self->stats.total); 775 ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period);
776 776
777 if (h->ms.map == NULL && verbose > 1) { 777 if (h->ms.map == NULL && verbose > 1) {
778 __map_groups__fprintf_maps(&h->thread->mg, 778 __map_groups__fprintf_maps(&h->thread->mg,
@@ -795,7 +795,7 @@ void hists__filter_by_dso(struct hists *self, const struct dso *dso)
795{ 795{
796 struct rb_node *nd; 796 struct rb_node *nd;
797 797
798 self->nr_entries = self->stats.total = 0; 798 self->nr_entries = self->stats.total_period = 0;
799 self->max_sym_namelen = 0; 799 self->max_sym_namelen = 0;
800 800
801 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 801 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
@@ -812,7 +812,7 @@ void hists__filter_by_dso(struct hists *self, const struct dso *dso)
812 h->filtered &= ~(1 << HIST_FILTER__DSO); 812 h->filtered &= ~(1 << HIST_FILTER__DSO);
813 if (!h->filtered) { 813 if (!h->filtered) {
814 ++self->nr_entries; 814 ++self->nr_entries;
815 self->stats.total += h->count; 815 self->stats.total_period += h->count;
816 if (h->ms.sym && 816 if (h->ms.sym &&
817 self->max_sym_namelen < h->ms.sym->namelen) 817 self->max_sym_namelen < h->ms.sym->namelen)
818 self->max_sym_namelen = h->ms.sym->namelen; 818 self->max_sym_namelen = h->ms.sym->namelen;
@@ -824,7 +824,7 @@ void hists__filter_by_thread(struct hists *self, const struct thread *thread)
824{ 824{
825 struct rb_node *nd; 825 struct rb_node *nd;
826 826
827 self->nr_entries = self->stats.total = 0; 827 self->nr_entries = self->stats.total_period = 0;
828 self->max_sym_namelen = 0; 828 self->max_sym_namelen = 0;
829 829
830 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 830 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
@@ -837,7 +837,7 @@ void hists__filter_by_thread(struct hists *self, const struct thread *thread)
837 h->filtered &= ~(1 << HIST_FILTER__THREAD); 837 h->filtered &= ~(1 << HIST_FILTER__THREAD);
838 if (!h->filtered) { 838 if (!h->filtered) {
839 ++self->nr_entries; 839 ++self->nr_entries;
840 self->stats.total += h->count; 840 self->stats.total_period += h->count;
841 if (h->ms.sym && 841 if (h->ms.sym &&
842 self->max_sym_namelen < h->ms.sym->namelen) 842 self->max_sym_namelen < h->ms.sym->namelen)
843 self->max_sym_namelen = h->ms.sym->namelen; 843 self->max_sym_namelen = h->ms.sym->namelen;
@@ -1031,8 +1031,8 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
1031 1031
1032void hists__inc_nr_events(struct hists *self, u32 type) 1032void hists__inc_nr_events(struct hists *self, u32 type)
1033{ 1033{
1034 ++self->hists.stats.nr_events[0]; 1034 ++self->stats.nr_events[0];
1035 ++self->hists.stats.nr_events[type]; 1035 ++self->stats.nr_events[type];
1036} 1036}
1037 1037
1038size_t hists__fprintf_nr_events(struct hists *self, FILE *fp) 1038size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 97b8962ff69a..da6b84814a50 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -37,9 +37,21 @@ struct sym_priv {
37 struct sym_ext *ext; 37 struct sym_ext *ext;
38}; 38};
39 39
40/*
41 * The kernel collects the number of events it couldn't send in a stretch and
42 * when possible sends this number in a PERF_RECORD_LOST event. The number of
43 * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while
44 * total_lost tells exactly how many events the kernel in fact lost, i.e. it is
45 * the sum of all struct lost_event.lost fields reported.
46 *
47 * The total_period is needed because by default auto-freq is used, so
48 * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get
49 * the total number of low level events, it is necessary to to sum all struct
50 * sample_event.period and stash the result in total_period.
51 */
40struct events_stats { 52struct events_stats {
41 u64 total; 53 u64 total_period;
42 u64 lost; 54 u64 total_lost;
43 u32 nr_events[PERF_RECORD_HEADER_MAX]; 55 u32 nr_events[PERF_RECORD_HEADER_MAX];
44 u32 nr_unknown_events; 56 u32 nr_unknown_events;
45}; 57};
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index ba6acd04c082..010bacf40163 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -689,7 +689,7 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
689 } 689 }
690 690
691 snprintf(str, sizeof(str), "Samples: %Ld ", 691 snprintf(str, sizeof(str), "Samples: %Ld ",
692 hists->stats.total); 692 hists->stats.total_period);
693 newtDrawRootText(0, 0, str); 693 newtDrawRootText(0, 0, str);
694 694
695 newtGetScreenSize(NULL, &rows); 695 newtGetScreenSize(NULL, &rows);
@@ -718,12 +718,12 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
718 if (h->filtered) 718 if (h->filtered)
719 continue; 719 continue;
720 720
721 len = hist_entry__append_browser(h, self->tree, hists->stats.total); 721 len = hist_entry__append_browser(h, self->tree, hists->stats.total_period);
722 if (len > max_len) 722 if (len > max_len)
723 max_len = len; 723 max_len = len;
724 if (symbol_conf.use_callchain) 724 if (symbol_conf.use_callchain)
725 hist_entry__append_callchain_browser(h, self->tree, 725 hist_entry__append_callchain_browser(h, self->tree,
726 hists->stats.total, idx++); 726 hists->stats.total_period, idx++);
727 ++curr_hist; 727 ++curr_hist;
728 if (curr_hist % 5) 728 if (curr_hist % 5)
729 ui_progress__update(progress, curr_hist); 729 ui_progress__update(progress, curr_hist);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 7231f6b19fb4..25bfca4f10f0 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -549,7 +549,7 @@ static int perf_session__process_event(struct perf_session *self,
549 dump_printf("%#Lx [%#x]: PERF_RECORD_%s", 549 dump_printf("%#Lx [%#x]: PERF_RECORD_%s",
550 offset + head, event->header.size, 550 offset + head, event->header.size,
551 event__name[event->header.type]); 551 event__name[event->header.type]);
552 hists__inc_nr_events(self, event->header.type); 552 hists__inc_nr_events(&self->hists, event->header.type);
553 } 553 }
554 554
555 if (self->header.needs_swap && event__swap_ops[event->header.type]) 555 if (self->header.needs_swap && event__swap_ops[event->header.type])