|
@@ -1,8 +1,6 @@
|
|
#include "hist.h"
|
|
#include "hist.h"
|
|
|
|
|
|
struct rb_root hist;
|
|
struct rb_root hist;
|
|
-struct rb_root collapse_hists;
|
|
|
|
-struct rb_root output_hists;
|
|
|
|
int callchain;
|
|
int callchain;
|
|
|
|
|
|
struct callchain_param callchain_param = {
|
|
struct callchain_param callchain_param = {
|
|
@@ -102,9 +100,9 @@ void hist_entry__free(struct hist_entry *he)
|
|
* collapse the histogram
|
|
* collapse the histogram
|
|
*/
|
|
*/
|
|
|
|
|
|
-void collapse__insert_entry(struct hist_entry *he)
|
|
|
|
|
|
+static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
|
|
{
|
|
{
|
|
- struct rb_node **p = &collapse_hists.rb_node;
|
|
|
|
|
|
+ struct rb_node **p = &root->rb_node;
|
|
struct rb_node *parent = NULL;
|
|
struct rb_node *parent = NULL;
|
|
struct hist_entry *iter;
|
|
struct hist_entry *iter;
|
|
int64_t cmp;
|
|
int64_t cmp;
|
|
@@ -128,34 +126,40 @@ void collapse__insert_entry(struct hist_entry *he)
|
|
}
|
|
}
|
|
|
|
|
|
rb_link_node(&he->rb_node, parent, p);
|
|
rb_link_node(&he->rb_node, parent, p);
|
|
- rb_insert_color(&he->rb_node, &collapse_hists);
|
|
|
|
|
|
+ rb_insert_color(&he->rb_node, root);
|
|
}
|
|
}
|
|
|
|
|
|
void collapse__resort(void)
|
|
void collapse__resort(void)
|
|
{
|
|
{
|
|
|
|
+ struct rb_root tmp;
|
|
struct rb_node *next;
|
|
struct rb_node *next;
|
|
struct hist_entry *n;
|
|
struct hist_entry *n;
|
|
|
|
|
|
if (!sort__need_collapse)
|
|
if (!sort__need_collapse)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ tmp = RB_ROOT;
|
|
next = rb_first(&hist);
|
|
next = rb_first(&hist);
|
|
|
|
+
|
|
while (next) {
|
|
while (next) {
|
|
n = rb_entry(next, struct hist_entry, rb_node);
|
|
n = rb_entry(next, struct hist_entry, rb_node);
|
|
next = rb_next(&n->rb_node);
|
|
next = rb_next(&n->rb_node);
|
|
|
|
|
|
rb_erase(&n->rb_node, &hist);
|
|
rb_erase(&n->rb_node, &hist);
|
|
- collapse__insert_entry(n);
|
|
|
|
|
|
+ collapse__insert_entry(&tmp, n);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ hist = tmp;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
* reverse the map, sort on count.
|
|
* reverse the map, sort on count.
|
|
*/
|
|
*/
|
|
|
|
|
|
-void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits)
|
|
|
|
|
|
+static void output__insert_entry(struct rb_root *root, struct hist_entry *he,
|
|
|
|
+ u64 min_callchain_hits)
|
|
{
|
|
{
|
|
- struct rb_node **p = &output_hists.rb_node;
|
|
|
|
|
|
+ struct rb_node **p = &root->rb_node;
|
|
struct rb_node *parent = NULL;
|
|
struct rb_node *parent = NULL;
|
|
struct hist_entry *iter;
|
|
struct hist_entry *iter;
|
|
|
|
|
|
@@ -174,29 +178,29 @@ void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits)
|
|
}
|
|
}
|
|
|
|
|
|
rb_link_node(&he->rb_node, parent, p);
|
|
rb_link_node(&he->rb_node, parent, p);
|
|
- rb_insert_color(&he->rb_node, &output_hists);
|
|
|
|
|
|
+ rb_insert_color(&he->rb_node, root);
|
|
}
|
|
}
|
|
|
|
|
|
void output__resort(u64 total_samples)
|
|
void output__resort(u64 total_samples)
|
|
{
|
|
{
|
|
|
|
+ struct rb_root tmp;
|
|
struct rb_node *next;
|
|
struct rb_node *next;
|
|
struct hist_entry *n;
|
|
struct hist_entry *n;
|
|
- struct rb_root *tree = &hist;
|
|
|
|
u64 min_callchain_hits;
|
|
u64 min_callchain_hits;
|
|
|
|
|
|
min_callchain_hits =
|
|
min_callchain_hits =
|
|
total_samples * (callchain_param.min_percent / 100);
|
|
total_samples * (callchain_param.min_percent / 100);
|
|
|
|
|
|
- if (sort__need_collapse)
|
|
|
|
- tree = &collapse_hists;
|
|
|
|
-
|
|
|
|
- next = rb_first(tree);
|
|
|
|
|
|
+ tmp = RB_ROOT;
|
|
|
|
+ next = rb_first(&hist);
|
|
|
|
|
|
while (next) {
|
|
while (next) {
|
|
n = rb_entry(next, struct hist_entry, rb_node);
|
|
n = rb_entry(next, struct hist_entry, rb_node);
|
|
next = rb_next(&n->rb_node);
|
|
next = rb_next(&n->rb_node);
|
|
|
|
|
|
- rb_erase(&n->rb_node, tree);
|
|
|
|
- output__insert_entry(n, min_callchain_hits);
|
|
|
|
|
|
+ rb_erase(&n->rb_node, &hist);
|
|
|
|
+ output__insert_entry(&tmp, n, min_callchain_hits);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ hist = tmp;
|
|
}
|
|
}
|