aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-14 13:19:35 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-14 13:19:35 -0400
commitc82ee828aa20487d254a5225d256cd422acee459 (patch)
tree6f8132442237bc4f2393e04a5f30b3711a8f91ca /tools/perf/util
parentcee75ac7ecc27084accdb9d9d6fde65a09f047ae (diff)
perf report: Report number of events, not samples
Number of samples is meaningless after we switched to auto-freq, so report the number of events, i.e. not the sum of the different periods, but the number PERF_RECORD_SAMPLE emitted by the kernel. While doing this I noticed that naming "count" to the sum of all the event periods can be confusing, so rename it to .period, just like in struct sample.data, so that we become more consistent. This helps with the next step, that was to record in struct hist_entry the number of sample events for each instance, we need that because we use it to generate the number of events when applying filters to the tree of hist entries like it is being done in the TUI report browser. Suggested-by: Ingo Molnar <mingo@elte.hu> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/hist.c88
-rw-r--r--tools/perf/util/hist.h2
-rw-r--r--tools/perf/util/newt.c8
-rw-r--r--tools/perf/util/sort.h11
-rw-r--r--tools/perf/util/util.c22
-rw-r--r--tools/perf/util/util.h1
6 files changed, 82 insertions, 50 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c59224518083..f75c5f62401c 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -9,21 +9,21 @@ struct callchain_param callchain_param = {
9 .min_percent = 0.5 9 .min_percent = 0.5
10}; 10};
11 11
12static void hist_entry__add_cpumode_count(struct hist_entry *self, 12static void hist_entry__add_cpumode_period(struct hist_entry *self,
13 unsigned int cpumode, u64 count) 13 unsigned int cpumode, u64 period)
14{ 14{
15 switch (cpumode) { 15 switch (cpumode) {
16 case PERF_RECORD_MISC_KERNEL: 16 case PERF_RECORD_MISC_KERNEL:
17 self->count_sys += count; 17 self->period_sys += period;
18 break; 18 break;
19 case PERF_RECORD_MISC_USER: 19 case PERF_RECORD_MISC_USER:
20 self->count_us += count; 20 self->period_us += period;
21 break; 21 break;
22 case PERF_RECORD_MISC_GUEST_KERNEL: 22 case PERF_RECORD_MISC_GUEST_KERNEL:
23 self->count_guest_sys += count; 23 self->period_guest_sys += period;
24 break; 24 break;
25 case PERF_RECORD_MISC_GUEST_USER: 25 case PERF_RECORD_MISC_GUEST_USER:
26 self->count_guest_us += count; 26 self->period_guest_us += period;
27 break; 27 break;
28 default: 28 default:
29 break; 29 break;
@@ -31,7 +31,7 @@ static void hist_entry__add_cpumode_count(struct hist_entry *self,
31} 31}
32 32
33/* 33/*
34 * histogram, sorted on item, collects counts 34 * histogram, sorted on item, collects periods
35 */ 35 */
36 36
37static struct hist_entry *hist_entry__new(struct hist_entry *template) 37static struct hist_entry *hist_entry__new(struct hist_entry *template)
@@ -41,6 +41,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
41 41
42 if (self != NULL) { 42 if (self != NULL) {
43 *self = *template; 43 *self = *template;
44 self->nr_events = 1;
44 if (symbol_conf.use_callchain) 45 if (symbol_conf.use_callchain)
45 callchain_init(self->callchain); 46 callchain_init(self->callchain);
46 } 47 }
@@ -57,7 +58,7 @@ static void hists__inc_nr_entries(struct hists *self, struct hist_entry *entry)
57 58
58struct hist_entry *__hists__add_entry(struct hists *self, 59struct hist_entry *__hists__add_entry(struct hists *self,
59 struct addr_location *al, 60 struct addr_location *al,
60 struct symbol *sym_parent, u64 count) 61 struct symbol *sym_parent, u64 period)
61{ 62{
62 struct rb_node **p = &self->entries.rb_node; 63 struct rb_node **p = &self->entries.rb_node;
63 struct rb_node *parent = NULL; 64 struct rb_node *parent = NULL;
@@ -70,7 +71,7 @@ struct hist_entry *__hists__add_entry(struct hists *self,
70 }, 71 },
71 .ip = al->addr, 72 .ip = al->addr,
72 .level = al->level, 73 .level = al->level,
73 .count = count, 74 .period = period,
74 .parent = sym_parent, 75 .parent = sym_parent,
75 }; 76 };
76 int cmp; 77 int cmp;
@@ -82,7 +83,8 @@ struct hist_entry *__hists__add_entry(struct hists *self,
82 cmp = hist_entry__cmp(&entry, he); 83 cmp = hist_entry__cmp(&entry, he);
83 84
84 if (!cmp) { 85 if (!cmp) {
85 he->count += count; 86 he->period += period;
87 ++he->nr_events;
86 goto out; 88 goto out;
87 } 89 }
88 90
@@ -99,7 +101,7 @@ struct hist_entry *__hists__add_entry(struct hists *self,
99 rb_insert_color(&he->rb_node, &self->entries); 101 rb_insert_color(&he->rb_node, &self->entries);
100 hists__inc_nr_entries(self, he); 102 hists__inc_nr_entries(self, he);
101out: 103out:
102 hist_entry__add_cpumode_count(he, al->cpumode, count); 104 hist_entry__add_cpumode_period(he, al->cpumode, period);
103 return he; 105 return he;
104} 106}
105 107
@@ -160,7 +162,7 @@ static bool collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
160 cmp = hist_entry__collapse(iter, he); 162 cmp = hist_entry__collapse(iter, he);
161 163
162 if (!cmp) { 164 if (!cmp) {
163 iter->count += he->count; 165 iter->period += he->period;
164 hist_entry__free(he); 166 hist_entry__free(he);
165 return false; 167 return false;
166 } 168 }
@@ -203,7 +205,7 @@ void hists__collapse_resort(struct hists *self)
203} 205}
204 206
205/* 207/*
206 * reverse the map, sort on count. 208 * reverse the map, sort on period.
207 */ 209 */
208 210
209static void __hists__insert_output_entry(struct rb_root *entries, 211static void __hists__insert_output_entry(struct rb_root *entries,
@@ -222,7 +224,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
222 parent = *p; 224 parent = *p;
223 iter = rb_entry(parent, struct hist_entry, rb_node); 225 iter = rb_entry(parent, struct hist_entry, rb_node);
224 226
225 if (he->count > iter->count) 227 if (he->period > iter->period)
226 p = &(*p)->rb_left; 228 p = &(*p)->rb_left;
227 else 229 else
228 p = &(*p)->rb_right; 230 p = &(*p)->rb_right;
@@ -288,7 +290,7 @@ static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask,
288} 290}
289 291
290static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, 292static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain,
291 int depth, int depth_mask, int count, 293 int depth, int depth_mask, int period,
292 u64 total_samples, int hits, 294 u64 total_samples, int hits,
293 int left_margin) 295 int left_margin)
294{ 296{
@@ -301,7 +303,7 @@ static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain,
301 ret += fprintf(fp, "|"); 303 ret += fprintf(fp, "|");
302 else 304 else
303 ret += fprintf(fp, " "); 305 ret += fprintf(fp, " ");
304 if (!count && i == depth - 1) { 306 if (!period && i == depth - 1) {
305 double percent; 307 double percent;
306 308
307 percent = hits * 100.0 / total_samples; 309 percent = hits * 100.0 / total_samples;
@@ -516,7 +518,7 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
516 long displacement, bool color, u64 session_total) 518 long displacement, bool color, u64 session_total)
517{ 519{
518 struct sort_entry *se; 520 struct sort_entry *se;
519 u64 count, total, count_sys, count_us, count_guest_sys, count_guest_us; 521 u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us;
520 const char *sep = symbol_conf.field_sep; 522 const char *sep = symbol_conf.field_sep;
521 int ret; 523 int ret;
522 524
@@ -524,57 +526,57 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
524 return 0; 526 return 0;
525 527
526 if (pair_hists) { 528 if (pair_hists) {