26 unsigned int chain_size =
event->header.size;
27 chain_size -= (
unsigned long)&event->
ip.__more_data - (
unsigned long)
event;
28 return chain->
nr *
sizeof(
u64) <= chain_size;
31 #define chain_for_each_child(child, parent) \
32 list_for_each_entry(child, &parent->children, siblings)
34 #define chain_for_each_child_safe(child, next, parent) \
35 list_for_each_entry_safe(child, next, &parent->children, siblings)
44 u64 chain_cumul = callchain_cumul_hits(chain);
51 rnode_cumul = callchain_cumul_hits(rnode);
55 if (rnode->
hit < chain->
hit)
62 if (rnode_cumul < chain_cumul)
73 rb_link_node(&chain->
rb_node, parent, p);
84 __sort_chain_flat(rb_root, child, min_hit);
86 if (node->
hit && node->
hit >= min_hit)
87 rb_insert_callchain(rb_root, node,
CHAIN_FLAT);
98 __sort_chain_flat(rb_root, &root->node, min_hit);
109 __sort_chain_graph_abs(child, min_hit);
110 if (callchain_cumul_hits(child) >= min_hit)
111 rb_insert_callchain(&node->
rb_root, child,
117 sort_chain_graph_abs(
struct rb_root *rb_root,
struct callchain_root *chain_root,
120 __sort_chain_graph_abs(&chain_root->
node, min_hit);
121 rb_root->
rb_node = chain_root->
node.rb_root.rb_node;
134 __sort_chain_graph_rel(child, min_percent);
135 if (callchain_cumul_hits(child) >= min_hit)
136 rb_insert_callchain(&node->
rb_root, child,
142 sort_chain_graph_rel(
struct rb_root *rb_root,
struct callchain_root *chain_root,
146 rb_root->
rb_node = chain_root->
node.rb_root.rb_node;
151 switch (param->
mode) {
153 param->
sort = sort_chain_graph_abs;
156 param->
sort = sort_chain_graph_rel;
159 param->
sort = sort_chain_flat;
177 new =
zalloc(
sizeof(*
new));
179 perror(
"not enough memory to create child for code path tree");
183 INIT_LIST_HEAD(&new->children);
184 INIT_LIST_HEAD(&new->val);
186 if (inherit_children) {
189 list_splice(&parent->
children, &new->children);
209 node->val_nr = cursor->nr - cursor->pos;
211 pr_warning(
"Warning: empty node in callchain tree\n");
213 cursor_node = callchain_cursor_current(cursor);
215 while (cursor_node) {
218 call =
zalloc(
sizeof(*call));
220 perror(
"not enough memory for the code path tree");
223 call->
ip = cursor_node->
ip;
224 call->
ms.sym = cursor_node->
sym;
225 call->
ms.map = cursor_node->
map;
228 callchain_cursor_advance(cursor);
229 cursor_node = callchain_cursor_current(cursor);
240 new = create_child(parent,
false);
241 fill_node(
new, cursor);
243 new->children_hit = 0;
260 unsigned int idx_total = idx_parents + idx_local;
263 new = create_child(parent,
true);
266 old_tail = parent->
val.prev;
267 list_del_range(&to_split->
list, old_tail);
268 new->val.next = &to_split->
list;
269 new->val.prev = old_tail;
270 to_split->
list.prev = &
new->val;
271 old_tail->
next = &
new->val;
274 new->hit = parent->
hit;
277 new->val_nr = parent->
val_nr - idx_local;
278 parent->
val_nr = idx_local;
281 if (idx_total < cursor->
nr) {
304 unsigned int ret = append_chain(rnode, cursor, period);
307 goto inc_children_hit;
336 node = callchain_cursor_current(cursor);
342 if (cnode->
ms.sym && sym) {
343 if (cnode->
ms.sym->start != sym->
start)
345 }
else if (cnode->
ip != node->
ip)
351 callchain_cursor_advance(cursor);
356 cursor->
curr = curr_snap;
364 if (matches < root->val_nr) {
365 split_add_child(root, cursor, cnode, start, matches, period);
370 if (matches == root->
val_nr && cursor->
pos == cursor->
nr) {
376 append_chain_children(root, cursor, period);
388 callchain_cursor_commit(cursor);
390 append_chain_children(&root->
node, cursor, period);
405 int old_pos = cursor->
nr;
410 list->
ms.map, list->
ms.sym);
416 callchain_cursor_commit(cursor);
417 append_chain_children(dst, cursor, src->
hit);
421 err = merge_chain_branch(cursor, dst, child);
429 cursor->
nr = old_pos;
430 cursor->
last = old_last;
438 return merge_chain_branch(cursor, &dst->
node, &src->
node);
447 node = calloc(
sizeof(*node), 1);