aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/util/hist.c36
-rw-r--r--tools/perf/util/hist.h10
4 files changed, 22 insertions, 28 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index e44c54c79be4..f25e89e9c9b0 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -432,7 +432,7 @@ static void find_annotations(void)
432{ 432{
433 struct rb_node *nd; 433 struct rb_node *nd;
434 434
435 for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) { 435 for (nd = rb_first(&hist); nd; nd = rb_next(nd)) {
436 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); 436 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
437 struct sym_priv *priv; 437 struct sym_priv *priv;
438 438
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3487224670a8..9cbdcbc4cd56 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -567,7 +567,7 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
567 fprintf(fp, "#\n"); 567 fprintf(fp, "#\n");
568 568
569print_entries: 569print_entries:
570 for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) { 570 for (nd = rb_first(&hist); nd; nd = rb_next(nd)) {
571 pos = rb_entry(nd, struct hist_entry, rb_node); 571 pos = rb_entry(nd, struct hist_entry, rb_node);
572 ret += hist_entry__fprintf(fp, pos, total_samples); 572 ret += hist_entry__fprintf(fp, pos, total_samples);
573 } 573 }
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 0ebf6ee16caa..b40e37ded4bf 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,8 +1,6 @@
1#include "hist.h" 1#include "hist.h"
2 2
3struct rb_root hist; 3struct rb_root hist;
4struct rb_root collapse_hists;
5struct rb_root output_hists;
6int callchain; 4int callchain;
7 5
8struct callchain_param callchain_param = { 6struct callchain_param callchain_param = {
@@ -102,9 +100,9 @@ void hist_entry__free(struct hist_entry *he)
102 * collapse the histogram 100 * collapse the histogram
103 */ 101 */
104 102
105void collapse__insert_entry(struct hist_entry *he) 103static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
106{ 104{
107 struct rb_node **p = &collapse_hists.rb_node; 105 struct rb_node **p = &root->rb_node;
108 struct rb_node *parent = NULL; 106 struct rb_node *parent = NULL;
109 struct hist_entry *iter; 107 struct hist_entry *iter;
110 int64_t cmp; 108 int64_t cmp;
@@ -128,34 +126,40 @@ void collapse__insert_entry(struct hist_entry *he)
128 } 126 }
129 127
130 rb_link_node(&he->rb_node, parent, p); 128 rb_link_node(&he->rb_node, parent, p);
131 rb_insert_color(&he->rb_node, &collapse_hists); 129 rb_insert_color(&he->rb_node, root);
132} 130}
133 131
134void collapse__resort(void) 132void collapse__resort(void)
135{ 133{
134 struct rb_root tmp;
136 struct rb_node *next; 135 struct rb_node *next;
137 struct hist_entry *n; 136 struct hist_entry *n;
138 137
139 if (!sort__need_collapse) 138 if (!sort__need_collapse)
140 return; 139 return;
141 140
141 tmp = RB_ROOT;
142 next = rb_first(&hist); 142 next = rb_first(&hist);
143
143 while (next) { 144 while (next) {
144 n = rb_entry(next, struct hist_entry, rb_node); 145 n = rb_entry(next, struct hist_entry, rb_node);
145 next = rb_next(&n->rb_node); 146 next = rb_next(&n->rb_node);
146 147
147 rb_erase(&n->rb_node, &hist); 148 rb_erase(&n->rb_node, &hist);
148 collapse__insert_entry(n); 149 collapse__insert_entry(&tmp, n);
149 } 150 }
151
152 hist = tmp;
150} 153}
151 154
152/* 155/*
153 * reverse the map, sort on count. 156 * reverse the map, sort on count.
154 */ 157 */
155 158
156void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits) 159static void output__insert_entry(struct rb_root *root, struct hist_entry *he,
160 u64 min_callchain_hits)
157{ 161{
158 struct rb_node **p = &output_hists.rb_node; 162 struct rb_node **p = &root->rb_node;
159 struct rb_node *parent = NULL; 163 struct rb_node *parent = NULL;
160 struct hist_entry *iter; 164 struct hist_entry *iter;
161 165
@@ -174,29 +178,29 @@ void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits)
174 } 178 }
175 179
176 rb_link_node(&he->rb_node, parent, p); 180 rb_link_node(&he->rb_node, parent, p);
177 rb_insert_color(&he->rb_node, &output_hists); 181 rb_insert_color(&he->rb_node, root);
178} 182}
179 183
180void output__resort(u64 total_samples) 184void output__resort(u64 total_samples)
181{ 185{
186 struct rb_root tmp;
182 struct rb_node *next; 187 struct rb_node *next;
183 struct hist_entry *n; 188 struct hist_entry *n;
184 struct rb_root *tree = &hist;
185 u64 min_callchain_hits; 189 u64 min_callchain_hits;
186 190
187 min_callchain_hits = 191 min_callchain_hits =
188 total_samples * (callchain_param.min_percent / 100); 192 total_samples * (callchain_param.min_percent / 100);
189 193
190 if (sort__need_collapse) 194 tmp = RB_ROOT;
191 tree = &collapse_hists; 195 next = rb_first(&hist);
192
193 next = rb_first(tree);
194 196
195 while (next) { 197 while (next) {
196 n = rb_entry(next, struct hist_entry, rb_node); 198 n = rb_entry(next, struct hist_entry, rb_node);
197 next = rb_next(&n->rb_node); 199 next = rb_next(&n->rb_node);
198 200
199 rb_erase(&n->rb_node, tree); 201 rb_erase(&n->rb_node, &hist);
200 output__insert_entry(n, min_callchain_hits); 202 output__insert_entry(&tmp, n, min_callchain_hits);
201 } 203 }
204
205 hist = tmp;
202} 206}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 3020db0c9292..a6cb1485e3b9 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -25,16 +25,8 @@
25#include "sort.h" 25#include "sort.h"
26 26
27extern struct rb_root hist; 27extern struct rb_root hist;
28extern struct rb_root collapse_hists;
29extern struct rb_root output_hists;
30extern int callchain; 28extern int callchain;
31extern struct callchain_param callchain_param; 29extern struct callchain_param callchain_param;
32extern unsigned long total;
33extern unsigned long total_mmap;
34extern unsigned long total_comm;
35extern unsigned long total_fork;
36extern unsigned long total_unknown;
37extern unsigned long total_lost;
38 30
39struct hist_entry *__hist_entry__add(struct addr_location *al, 31struct hist_entry *__hist_entry__add(struct addr_location *al,
40 struct symbol *parent, 32 struct symbol *parent,
@@ -42,9 +34,7 @@ struct hist_entry *__hist_entry__add(struct addr_location *al,
42extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); 34extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);
43extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); 35extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *);
44extern void hist_entry__free(struct hist_entry *); 36extern void hist_entry__free(struct hist_entry *);
45extern void collapse__insert_entry(struct hist_entry *);
46extern void collapse__resort(void); 37extern void collapse__resort(void);
47extern void output__insert_entry(struct hist_entry *, u64);
48extern void output__resort(u64); 38extern void output__resort(u64);
49 39
50#endif /* __PERF_HIST_H */ 40#endif /* __PERF_HIST_H */