perf hist: Calculate max_sym name len and nr_entries
Better done when we are adding entries, be it initially of when we're re-sorting the histograms. 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>
This commit is contained in:
parent
1c02c4d2e9
commit
fefb0b94bb
|
@ -296,13 +296,13 @@ static int __cmd_report(void)
|
||||||
next = rb_first(&session->hists_tree);
|
next = rb_first(&session->hists_tree);
|
||||||
while (next) {
|
while (next) {
|
||||||
struct hists *hists;
|
struct hists *hists;
|
||||||
u64 nr_hists;
|
|
||||||
|
|
||||||
hists = rb_entry(next, struct hists, rb_node);
|
hists = rb_entry(next, struct hists, rb_node);
|
||||||
hists__collapse_resort(hists);
|
hists__collapse_resort(hists);
|
||||||
nr_hists = hists__output_resort(hists);
|
hists__output_resort(hists);
|
||||||
if (use_browser)
|
if (use_browser)
|
||||||
perf_session__browse_hists(&hists->entries, nr_hists,
|
perf_session__browse_hists(&hists->entries,
|
||||||
|
hists->nr_entries,
|
||||||
hists->stats.total, help,
|
hists->stats.total, help,
|
||||||
input_name);
|
input_name);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -47,6 +47,13 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hists__inc_nr_entries(struct hists *self, struct hist_entry *entry)
|
||||||
|
{
|
||||||
|
if (entry->ms.sym && self->max_sym_namelen < entry->ms.sym->namelen)
|
||||||
|
self->max_sym_namelen = entry->ms.sym->namelen;
|
||||||
|
++self->nr_entries;
|
||||||
|
}
|
||||||
|
|
||||||
struct hist_entry *__hists__add_entry(struct hists *self,
|
struct hist_entry *__hists__add_entry(struct hists *self,
|
||||||
struct addr_location *al,
|
struct addr_location *al,
|
||||||
struct symbol *sym_parent, u64 count)
|
struct symbol *sym_parent, u64 count)
|
||||||
|
@ -89,6 +96,7 @@ struct hist_entry *__hists__add_entry(struct hists *self,
|
||||||
return NULL;
|
return NULL;
|
||||||
rb_link_node(&he->rb_node, parent, p);
|
rb_link_node(&he->rb_node, parent, p);
|
||||||
rb_insert_color(&he->rb_node, &self->entries);
|
rb_insert_color(&he->rb_node, &self->entries);
|
||||||
|
hists__inc_nr_entries(self, he);
|
||||||
out:
|
out:
|
||||||
hist_entry__add_cpumode_count(he, al->cpumode, count);
|
hist_entry__add_cpumode_count(he, al->cpumode, count);
|
||||||
return he;
|
return he;
|
||||||
|
@ -137,7 +145,7 @@ void hist_entry__free(struct hist_entry *he)
|
||||||
* collapse the histogram
|
* collapse the histogram
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
|
static bool collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
|
||||||
{
|
{
|
||||||
struct rb_node **p = &root->rb_node;
|
struct rb_node **p = &root->rb_node;
|
||||||
struct rb_node *parent = NULL;
|
struct rb_node *parent = NULL;
|
||||||
|
@ -153,7 +161,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
|
||||||
if (!cmp) {
|
if (!cmp) {
|
||||||
iter->count += he->count;
|
iter->count += he->count;
|
||||||
hist_entry__free(he);
|
hist_entry__free(he);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
|
@ -164,6 +172,7 @@ static void collapse__insert_entry(struct rb_root *root, 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, root);
|
rb_insert_color(&he->rb_node, root);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hists__collapse_resort(struct hists *self)
|
void hists__collapse_resort(struct hists *self)
|
||||||
|
@ -177,13 +186,16 @@ void hists__collapse_resort(struct hists *self)
|
||||||
|
|
||||||
tmp = RB_ROOT;
|
tmp = RB_ROOT;
|
||||||
next = rb_first(&self->entries);
|
next = rb_first(&self->entries);
|
||||||
|
self->nr_entries = 0;
|
||||||
|
self->max_sym_namelen = 0;
|
||||||
|
|
||||||
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, &self->entries);
|
rb_erase(&n->rb_node, &self->entries);
|
||||||
collapse__insert_entry(&tmp, n);
|
if (collapse__insert_entry(&tmp, n))
|
||||||
|
hists__inc_nr_entries(self, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->entries = tmp;
|
self->entries = tmp;
|
||||||
|
@ -219,30 +231,31 @@ static void __hists__insert_output_entry(struct rb_root *entries,
|
||||||
rb_insert_color(&he->rb_node, entries);
|
rb_insert_color(&he->rb_node, entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 hists__output_resort(struct hists *self)
|
void hists__output_resort(struct hists *self)
|
||||||
{
|
{
|
||||||
struct rb_root tmp;
|
struct rb_root tmp;
|
||||||
struct rb_node *next;
|
struct rb_node *next;
|
||||||
struct hist_entry *n;
|
struct hist_entry *n;
|
||||||
u64 min_callchain_hits;
|
u64 min_callchain_hits;
|
||||||
u64 nr_hists = 0;
|
|
||||||
|
|
||||||
min_callchain_hits = self->stats.total * (callchain_param.min_percent / 100);
|
min_callchain_hits = self->stats.total * (callchain_param.min_percent / 100);
|
||||||
|
|
||||||
tmp = RB_ROOT;
|
tmp = RB_ROOT;
|
||||||
next = rb_first(&self->entries);
|
next = rb_first(&self->entries);
|
||||||
|
|
||||||
|
self->nr_entries = 0;
|
||||||
|
self->max_sym_namelen = 0;
|
||||||
|
|
||||||
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, &self->entries);
|
rb_erase(&n->rb_node, &self->entries);
|
||||||
__hists__insert_output_entry(&tmp, n, min_callchain_hits);
|
__hists__insert_output_entry(&tmp, n, min_callchain_hits);
|
||||||
++nr_hists;
|
hists__inc_nr_entries(self, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->entries = tmp;
|
self->entries = tmp;
|
||||||
return nr_hists;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
|
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
|
||||||
|
|
|
@ -19,10 +19,12 @@ struct events_stats {
|
||||||
struct hists {
|
struct hists {
|
||||||
struct rb_node rb_node;
|
struct rb_node rb_node;
|
||||||
struct rb_root entries;
|
struct rb_root entries;
|
||||||
|
u64 nr_entries;
|
||||||
struct events_stats stats;
|
struct events_stats stats;
|
||||||
u64 config;
|
u64 config;
|
||||||
u64 event_stream;
|
u64 event_stream;
|
||||||
u32 type;
|
u32 type;
|
||||||
|
u32 max_sym_namelen;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hist_entry *__hists__add_entry(struct hists *self,
|
struct hist_entry *__hists__add_entry(struct hists *self,
|
||||||
|
@ -38,7 +40,7 @@ int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
|
||||||
long displacement, bool color, u64 total);
|
long displacement, bool color, u64 total);
|
||||||
void hist_entry__free(struct hist_entry *);
|
void hist_entry__free(struct hist_entry *);
|
||||||
|
|
||||||
u64 hists__output_resort(struct hists *self);
|
void hists__output_resort(struct hists *self);
|
||||||
void hists__collapse_resort(struct hists *self);
|
void hists__collapse_resort(struct hists *self);
|
||||||
size_t hists__fprintf(struct hists *self, struct hists *pair,
|
size_t hists__fprintf(struct hists *self, struct hists *pair,
|
||||||
bool show_displacement, FILE *fp);
|
bool show_displacement, FILE *fp);
|
||||||
|
|
|
@ -130,8 +130,9 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name)
|
||||||
if (symbol_conf.priv_size)
|
if (symbol_conf.priv_size)
|
||||||
self = ((void *)self) + symbol_conf.priv_size;
|
self = ((void *)self) + symbol_conf.priv_size;
|
||||||
|
|
||||||
self->start = start;
|
self->start = start;
|
||||||
self->end = len ? start + len - 1 : start;
|
self->end = len ? start + len - 1 : start;
|
||||||
|
self->namelen = namelen - 1;
|
||||||
|
|
||||||
pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end);
|
pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end);
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ struct symbol {
|
||||||
struct rb_node rb_node;
|
struct rb_node rb_node;
|
||||||
u64 start;
|
u64 start;
|
||||||
u64 end;
|
u64 end;
|
||||||
|
u16 namelen;
|
||||||
char name[0];
|
char name[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue