.min_percent = 0.5
};
-void __perf_session__add_count(struct hist_entry *he,
- struct addr_location *al,
- u64 count)
+static void perf_session__add_cpumode_count(struct hist_entry *he,
+ unsigned int cpumode, u64 count)
{
- he->count += count;
-
- switch (al->cpumode) {
+ switch (cpumode) {
case PERF_RECORD_MISC_KERNEL:
he->count_sys += count;
break;
* histogram, sorted on item, collects counts
*/
+static struct hist_entry *hist_entry__new(struct hist_entry *template)
+{
+ size_t callchain_size = symbol_conf.use_callchain ? sizeof(struct callchain_node) : 0;
+ struct hist_entry *self = malloc(sizeof(*self) + callchain_size);
+
+ if (self != NULL) {
+ *self = *template;
+ if (symbol_conf.use_callchain)
+ callchain_init(self->callchain);
+ }
+
+ return self;
+}
+
struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists,
struct addr_location *al,
struct symbol *sym_parent,
- u64 count, bool *hit)
+ u64 count)
{
struct rb_node **p = &hists->rb_node;
struct rb_node *parent = NULL;
cmp = hist_entry__cmp(&entry, he);
if (!cmp) {
- *hit = true;
- return he;
+ he->count += count;
+ goto out;
}
if (cmp < 0)
p = &(*p)->rb_right;
}
- he = malloc(sizeof(*he) + (symbol_conf.use_callchain ?
- sizeof(struct callchain_node) : 0));
+ he = hist_entry__new(&entry);
if (!he)
return NULL;
- *he = entry;
rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, hists);
- *hit = false;
+out:
+ perf_session__add_cpumode_count(he, al->cpumode, count);
return he;
}
u64 remaining;
size_t ret = 0;
int i;
+ uint entries_printed = 0;
if (callchain_param.mode == CHAIN_GRAPH_REL)
new_total = self->children_hit;
new_depth_mask | (1 << depth),
left_margin);
node = next;
+ if (++entries_printed == callchain_param.print_limit)
+ break;
}
if (callchain_param.mode == CHAIN_GRAPH_REL &&
bool printed = false;
int i = 0;
int ret = 0;
+ u32 entries_printed = 0;
list_for_each_entry(chain, &self->val, list) {
if (!i++ && sort__first_dimension == SORT_SYM)
ret += fprintf(fp, " %s\n", chain->ms.sym->name);
else
ret += fprintf(fp, " %p\n", (void *)(long)chain->ip);
+
+ if (++entries_printed == callchain_param.print_limit)
+ break;
}
ret += __callchain__fprintf_graph(fp, self, total_samples, 1, 1, left_margin);
struct rb_node *rb_node;
struct callchain_node *chain;
size_t ret = 0;
+ u32 entries_printed = 0;
rb_node = rb_first(&self->sorted_chain);
while (rb_node) {
break;
}
ret += fprintf(fp, "\n");
+ if (++entries_printed == callchain_param.print_limit)
+ break;
rb_node = rb_next(rb_node);
}