Lines Matching +full:child +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2009-2011, Frederic Weisbecker <fweisbec@gmail.com>
5 * Handle the callchains from the stream in an ad-hoc radix tree and then
53 * -e cycles/call-graph=dwarf/
61 /* Used for thread-local struct callchain_cursor. */
87 return -1; in parse_callchain_mode()
102 return -1; in parse_callchain_order()
123 return -1; in parse_callchain_sort_key()
140 return -1; in parse_callchain_value()
166 return -1; in get_stack_size()
196 /* parsing ok - move on to the next */ in __parse_callchain_report_opt()
216 return -1; in __parse_callchain_report_opt()
223 return -1; in __parse_callchain_report_opt()
229 return -1; in __parse_callchain_report_opt()
237 return -1; in __parse_callchain_report_opt()
256 int ret = -1; in parse_callchain_record()
261 return -ENOMEM; in parse_callchain_record()
272 param->record_mode = CALLCHAIN_FP; in parse_callchain_record()
280 param->max_stack = size; in parse_callchain_record()
289 param->record_mode = CALLCHAIN_DWARF; in parse_callchain_record()
290 param->dump_size = default_stack_dump_size; in parse_callchain_record()
298 param->dump_size = size; in parse_callchain_record()
302 param->record_mode = CALLCHAIN_LBR; in parse_callchain_record()
306 "needed for --call-graph lbr\n"); in parse_callchain_record()
309 pr_err("callchain: Unknown --call-graph option " in parse_callchain_record()
324 if (!strstarts(var, "call-graph.")) in perf_callchain_config()
326 var += sizeof("call-graph.") - 1; in perf_callchain_config()
328 if (!strcmp(var, "record-mode")) in perf_callchain_config()
330 if (!strcmp(var, "dump-size")) { in perf_callchain_config()
339 if (!strcmp(var, "print-type")){ in perf_callchain_config()
342 if (ret == -1) in perf_callchain_config()
349 if (ret == -1) in perf_callchain_config()
353 if (!strcmp(var, "sort-key")){ in perf_callchain_config()
356 if (ret == -1) in perf_callchain_config()
364 return -1; in perf_callchain_config()
367 if (!strcmp(var, "print-limit")) { in perf_callchain_config()
371 return -1; in perf_callchain_config()
382 struct rb_node **p = &root->rb_node; in rb_insert_callchain()
397 if (rnode->hit < chain->hit) in rb_insert_callchain()
398 p = &(*p)->rb_left; in rb_insert_callchain()
400 p = &(*p)->rb_right; in rb_insert_callchain()
405 p = &(*p)->rb_left; in rb_insert_callchain()
407 p = &(*p)->rb_right; in rb_insert_callchain()
415 rb_link_node(&chain->rb_node, parent, p); in rb_insert_callchain()
416 rb_insert_color(&chain->rb_node, root); in rb_insert_callchain()
420 __sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node, in __sort_chain_flat() argument
424 struct callchain_node *child; in __sort_chain_flat() local
426 n = rb_first(&node->rb_root_in); in __sort_chain_flat()
428 child = rb_entry(n, struct callchain_node, rb_node_in); in __sort_chain_flat()
431 __sort_chain_flat(rb_root, child, min_hit); in __sort_chain_flat()
434 if (node->hit && node->hit >= min_hit) in __sort_chain_flat()
435 rb_insert_callchain(rb_root, node, CHAIN_FLAT); in __sort_chain_flat()
447 __sort_chain_flat(rb_root, &root->node, min_hit); in sort_chain_flat()
450 static void __sort_chain_graph_abs(struct callchain_node *node, in __sort_chain_graph_abs() argument
454 struct callchain_node *child; in __sort_chain_graph_abs() local
456 node->rb_root = RB_ROOT; in __sort_chain_graph_abs()
457 n = rb_first(&node->rb_root_in); in __sort_chain_graph_abs()
460 child = rb_entry(n, struct callchain_node, rb_node_in); in __sort_chain_graph_abs()
463 __sort_chain_graph_abs(child, min_hit); in __sort_chain_graph_abs()
464 if (callchain_cumul_hits(child) >= min_hit) in __sort_chain_graph_abs()
465 rb_insert_callchain(&node->rb_root, child, in __sort_chain_graph_abs()
474 __sort_chain_graph_abs(&chain_root->node, min_hit); in sort_chain_graph_abs()
475 rb_root->rb_node = chain_root->node.rb_root.rb_node; in sort_chain_graph_abs()
478 static void __sort_chain_graph_rel(struct callchain_node *node, in __sort_chain_graph_rel() argument
482 struct callchain_node *child; in __sort_chain_graph_rel() local
485 node->rb_root = RB_ROOT; in __sort_chain_graph_rel()
486 min_hit = ceil(node->children_hit * min_percent); in __sort_chain_graph_rel()
488 n = rb_first(&node->rb_root_in); in __sort_chain_graph_rel()
490 child = rb_entry(n, struct callchain_node, rb_node_in); in __sort_chain_graph_rel()
493 __sort_chain_graph_rel(child, min_percent); in __sort_chain_graph_rel()
494 if (callchain_cumul_hits(child) >= min_hit) in __sort_chain_graph_rel()
495 rb_insert_callchain(&node->rb_root, child, in __sort_chain_graph_rel()
504 __sort_chain_graph_rel(&chain_root->node, param->min_percent / 100.0); in sort_chain_graph_rel()
505 rb_root->rb_node = chain_root->node.rb_root.rb_node; in sort_chain_graph_rel()
510 switch (param->mode) { in callchain_register_param()
512 param->sort = sort_chain_graph_abs; in callchain_register_param()
515 param->sort = sort_chain_graph_rel; in callchain_register_param()
519 param->sort = sort_chain_flat; in callchain_register_param()
523 return -1; in callchain_register_param()
529 * Create a child for a parent. If inherit_children, then the new child
539 perror("not enough memory to create child for code path tree"); in create_child()
542 new->parent = parent; in create_child()
543 INIT_LIST_HEAD(&new->val); in create_child()
544 INIT_LIST_HEAD(&new->parent_val); in create_child()
548 struct callchain_node *child; in create_child() local
550 new->rb_root_in = parent->rb_root_in; in create_child()
551 parent->rb_root_in = RB_ROOT; in create_child()
553 n = rb_first(&new->rb_root_in); in create_child()
555 child = rb_entry(n, struct callchain_node, rb_node_in); in create_child()
556 child->parent = new; in create_child()
560 /* make it the first child */ in create_child()
561 rb_link_node(&new->rb_node_in, NULL, &parent->rb_root_in.rb_node); in create_child()
562 rb_insert_color(&new->rb_node_in, &parent->rb_root_in); in create_child()
570 * Fill the node with callchain values
573 fill_node(struct callchain_node *node, struct callchain_cursor *cursor) in fill_node() argument
577 node->val_nr = cursor->nr - cursor->pos; in fill_node()
578 if (!node->val_nr) in fill_node()
579 pr_warning("Warning: empty node in callchain tree\n"); in fill_node()
589 return -1; in fill_node()
591 call->ip = cursor_node->ip; in fill_node()
592 call->ms = cursor_node->ms; in fill_node()
593 call->ms.map = map__get(call->ms.map); in fill_node()
594 call->ms.maps = maps__get(call->ms.maps); in fill_node()
595 call->srcline = cursor_node->srcline; in fill_node()
597 if (cursor_node->branch) { in fill_node()
598 call->branch_count = 1; in fill_node()
600 if (cursor_node->branch_from) { in fill_node()
605 call->brtype_stat.branch_to = true; in fill_node()
607 if (cursor_node->branch_flags.predicted) in fill_node()
608 call->predicted_count = 1; in fill_node()
610 if (cursor_node->branch_flags.abort) in fill_node()
611 call->abort_count = 1; in fill_node()
613 branch_type_count(&call->brtype_stat, in fill_node()
614 &cursor_node->branch_flags, in fill_node()
615 cursor_node->branch_from, in fill_node()
616 cursor_node->ip); in fill_node()
621 call->brtype_stat.branch_to = false; in fill_node()
622 call->cycles_count = in fill_node()
623 cursor_node->branch_flags.cycles; in fill_node()
624 call->iter_count = cursor_node->nr_loop_iter; in fill_node()
625 call->iter_cycles = cursor_node->iter_cycles; in fill_node()
629 list_add_tail(&call->list, &node->val); in fill_node()
651 list_for_each_entry_safe(call, tmp, &new->val, list) { in add_child()
652 list_del_init(&call->list); in add_child()
653 map__zput(call->ms.map); in add_child()
654 maps__zput(call->ms.maps); in add_child()
661 new->children_hit = 0; in add_child()
662 new->hit = period; in add_child()
663 new->children_count = 0; in add_child()
664 new->count = 1; in add_child()
669 MATCH_ERROR = -1,
686 cmp = -1; in match_chain_strings()
702 * to compare just relative addresses. -acme
719 static enum match_result match_chain(struct callchain_cursor_node *node, in match_chain() argument
726 match = match_chain_strings(cnode->srcline, node->srcline); in match_chain()
729 /* otherwise fall-back to symbol-based comparison below */ in match_chain()
732 if (node->ms.sym && cnode->ms.sym) { in match_chain()
739 if (cnode->ms.sym->inlined || node->ms.sym->inlined) { in match_chain()
740 match = match_chain_strings(cnode->ms.sym->name, in match_chain()
741 node->ms.sym->name); in match_chain()
745 match = match_chain_dso_addresses(cnode->ms.map, cnode->ms.sym->start, in match_chain()
746 node->ms.map, node->ms.sym->start); in match_chain()
750 /* otherwise fall-back to IP-based comparison below */ in match_chain()
754 match = match_chain_dso_addresses(cnode->ms.map, cnode->ip, node->ms.map, node->ip); in match_chain()
758 if (match == MATCH_EQ && node->branch) { in match_chain()
759 cnode->branch_count++; in match_chain()
761 if (node->branch_from) { in match_chain()
765 cnode->brtype_stat.branch_to = true; in match_chain()
767 if (node->branch_flags.predicted) in match_chain()
768 cnode->predicted_count++; in match_chain()
770 if (node->branch_flags.abort) in match_chain()
771 cnode->abort_count++; in match_chain()
773 branch_type_count(&cnode->brtype_stat, in match_chain()
774 &node->branch_flags, in match_chain()
775 node->branch_from, in match_chain()
776 node->ip); in match_chain()
781 cnode->brtype_stat.branch_to = false; in match_chain()
782 cnode->cycles_count += node->branch_flags.cycles; in match_chain()
783 cnode->iter_count += node->nr_loop_iter; in match_chain()
784 cnode->iter_cycles += node->iter_cycles; in match_chain()
785 cnode->from_count++; in match_chain()
793 * Split the parent in two parts (a new child is created) and
794 * give a part of its callchain to the created child.
795 * Then create another child to host the given callchain of new branch
810 return -1; in split_add_child()
812 /* split the callchain and move a part to the new child */ in split_add_child()
813 old_tail = parent->val.prev; in split_add_child()
814 list_del_range(&to_split->list, old_tail); in split_add_child()
815 new->val.next = &to_split->list; in split_add_child()
816 new->val.prev = old_tail; in split_add_child()
817 to_split->list.prev = &new->val; in split_add_child()
818 old_tail->next = &new->val; in split_add_child()
821 new->hit = parent->hit; in split_add_child()
822 new->children_hit = parent->children_hit; in split_add_child()
823 parent->children_hit = callchain_cumul_hits(new); in split_add_child()
824 new->val_nr = parent->val_nr - idx_local; in split_add_child()
825 parent->val_nr = idx_local; in split_add_child()
826 new->count = parent->count; in split_add_child()
827 new->children_count = parent->children_count; in split_add_child()
828 parent->children_count = callchain_cumul_counts(new); in split_add_child()
830 /* create a new child for the new branch if any */ in split_add_child()
831 if (idx_total < cursor->nr) { in split_add_child()
834 struct callchain_cursor_node *node; in split_add_child() local
837 parent->hit = 0; in split_add_child()
838 parent->children_hit += period; in split_add_child()
839 parent->count = 0; in split_add_child()
840 parent->children_count += 1; in split_add_child()
842 node = callchain_cursor_current(cursor); in split_add_child()
845 return -1; in split_add_child()
848 * This is second child since we moved parent's children in split_add_child()
849 * to new (first) child above. in split_add_child()
851 p = parent->rb_root_in.rb_node; in split_add_child()
853 cnode = list_first_entry(&first->val, struct callchain_list, in split_add_child()
856 if (match_chain(node, cnode) == MATCH_LT) in split_add_child()
857 pp = &p->rb_left; in split_add_child()
859 pp = &p->rb_right; in split_add_child()
861 rb_link_node(&new->rb_node_in, p, pp); in split_add_child()
862 rb_insert_color(&new->rb_node_in, &parent->rb_root_in); in split_add_child()
864 parent->hit = period; in split_add_child()
865 parent->count = 1; in split_add_child()
881 struct callchain_cursor_node *node; in append_chain_children() local
882 struct rb_node **p = &root->rb_root_in.rb_node; in append_chain_children()
885 node = callchain_cursor_current(cursor); in append_chain_children()
886 if (!node) in append_chain_children()
887 return -1; in append_chain_children()
901 return -1; in append_chain_children()
904 p = &parent->rb_left; in append_chain_children()
906 p = &parent->rb_right; in append_chain_children()
908 /* nothing in children, add to the current node */ in append_chain_children()
911 return -1; in append_chain_children()
913 rb_link_node(&rnode->rb_node_in, parent, p); in append_chain_children()
914 rb_insert_color(&rnode->rb_node_in, &root->rb_root_in); in append_chain_children()
917 root->children_hit += period; in append_chain_children()
918 root->children_count++; in append_chain_children()
928 u64 start = cursor->pos; in append_chain()
934 * Lookup in the current node in append_chain()
939 list_for_each_entry(cnode, &root->val, list) { in append_chain()
940 struct callchain_cursor_node *node; in append_chain() local
942 node = callchain_cursor_current(cursor); in append_chain()
943 if (!node) in append_chain()
946 cmp = match_chain(node, cnode); in append_chain()
961 matches = cursor->pos - start; in append_chain()
963 /* we match only a part of the node. Split it and add the new chain */ in append_chain()
964 if (matches < root->val_nr) { in append_chain()
973 if (matches == root->val_nr && cursor->pos == cursor->nr) { in append_chain()
974 root->hit += period; in append_chain()
975 root->count++; in append_chain()
979 /* We match the node and still have a part remaining */ in append_chain()
991 return -1; in callchain_append()
993 if (!cursor->nr) in callchain_append()
998 if (append_chain_children(&root->node, cursor, period) < 0) in callchain_append()
999 return -1; in callchain_append()
1001 if (cursor->nr > root->max_depth) in callchain_append()
1002 root->max_depth = cursor->nr; in callchain_append()
1011 struct callchain_cursor_node **old_last = cursor->last; in merge_chain_branch()
1012 struct callchain_node *child; in merge_chain_branch() local
1015 int old_pos = cursor->nr; in merge_chain_branch()
1018 list_for_each_entry_safe(list, next_list, &src->val, list) { in merge_chain_branch()
1020 .maps = maps__get(list->ms.maps), in merge_chain_branch()
1021 .map = map__get(list->ms.map), in merge_chain_branch()
1023 callchain_cursor_append(cursor, list->ip, &ms, false, NULL, 0, 0, 0, list->srcline); in merge_chain_branch()
1024 list_del_init(&list->list); in merge_chain_branch()
1027 map__zput(list->ms.map); in merge_chain_branch()
1028 maps__zput(list->ms.maps); in merge_chain_branch()
1032 if (src->hit) { in merge_chain_branch()
1034 if (append_chain_children(dst, cursor, src->hit) < 0) in merge_chain_branch()
1035 return -1; in merge_chain_branch()
1038 n = rb_first(&src->rb_root_in); in merge_chain_branch()
1040 child = container_of(n, struct callchain_node, rb_node_in); in merge_chain_branch()
1042 rb_erase(&child->rb_node_in, &src->rb_root_in); in merge_chain_branch()
1044 err = merge_chain_branch(cursor, dst, child); in merge_chain_branch()
1048 free(child); in merge_chain_branch()
1051 cursor->nr = old_pos; in merge_chain_branch()
1052 cursor->last = old_last; in merge_chain_branch()
1060 return merge_chain_branch(cursor, &dst->node, &src->node); in callchain_merge()
1069 struct callchain_cursor_node *node = *cursor->last; in callchain_cursor_append() local
1071 if (!node) { in callchain_cursor_append()
1072 node = calloc(1, sizeof(*node)); in callchain_cursor_append()
1073 if (!node) in callchain_cursor_append()
1074 return -ENOMEM; in callchain_cursor_append()
1076 *cursor->last = node; in callchain_cursor_append()
1079 node->ip = ip; in callchain_cursor_append()
1080 maps__zput(node->ms.maps); in callchain_cursor_append()
1081 map__zput(node->ms.map); in callchain_cursor_append()
1082 node->ms = *ms; in callchain_cursor_append()
1083 node->ms.maps = maps__get(ms->maps); in callchain_cursor_append()
1084 node->ms.map = map__get(ms->map); in callchain_cursor_append()
1085 node->branch = branch; in callchain_cursor_append()
1086 node->nr_loop_iter = nr_loop_iter; in callchain_cursor_append()
1087 node->iter_cycles = iter_cycles; in callchain_cursor_append()
1088 node->srcline = srcline; in callchain_cursor_append()
1091 memcpy(&node->branch_flags, flags, in callchain_cursor_append()
1094 node->branch_from = branch_from; in callchain_cursor_append()
1095 cursor->nr++; in callchain_cursor_append()
1097 cursor->last = &node->next; in callchain_cursor_append()
1107 if (sample->callchain == NULL && !symbol_conf.show_branchflag_count) in sample__resolve_callchain()
1112 return thread__resolve_callchain(al->thread, cursor, evsel, sample, in sample__resolve_callchain()
1120 if ((!symbol_conf.use_callchain || sample->callchain == NULL) && in hist_entry__append_callchain()
1123 return callchain_append(he->callchain, get_tls_callchain_cursor(), sample->period); in hist_entry__append_callchain()
1126 int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node, in fill_callchain_info() argument
1129 struct machine *machine = maps__machine(node->ms.maps); in fill_callchain_info()
1131 maps__put(al->maps); in fill_callchain_info()
1132 al->maps = maps__get(node->ms.maps); in fill_callchain_info()
1133 map__put(al->map); in fill_callchain_info()
1134 al->map = map__get(node->ms.map); in fill_callchain_info()
1135 al->sym = node->ms.sym; in fill_callchain_info()
1136 al->srcline = node->srcline; in fill_callchain_info()
1137 al->addr = node->ip; in fill_callchain_info()
1139 if (al->sym == NULL) { in fill_callchain_info()
1142 if (al->map == NULL) in fill_callchain_info()
1145 if (RC_CHK_ACCESS(al->maps) == RC_CHK_ACCESS(machine__kernel_maps(machine))) { in fill_callchain_info()
1147 al->cpumode = PERF_RECORD_MISC_KERNEL; in fill_callchain_info()
1148 al->level = 'k'; in fill_callchain_info()
1150 al->cpumode = PERF_RECORD_MISC_GUEST_KERNEL; in fill_callchain_info()
1151 al->level = 'g'; in fill_callchain_info()
1155 al->cpumode = PERF_RECORD_MISC_USER; in fill_callchain_info()
1156 al->level = '.'; in fill_callchain_info()
1158 al->cpumode = PERF_RECORD_MISC_GUEST_USER; in fill_callchain_info()
1159 al->level = 'u'; in fill_callchain_info()
1161 al->cpumode = PERF_RECORD_MISC_HYPERVISOR; in fill_callchain_info()
1162 al->level = 'H'; in fill_callchain_info()
1177 if (cl->ms.sym) { in callchain_list__sym_name()
1178 const char *inlined = cl->ms.sym->inlined ? " (inlined)" : ""; in callchain_list__sym_name()
1180 if (show_srcline && cl->srcline) in callchain_list__sym_name()
1182 cl->ms.sym->name, cl->srcline, in callchain_list__sym_name()
1186 cl->ms.sym->name, inlined); in callchain_list__sym_name()
1188 printed = scnprintf(bf, bfsize, "%#" PRIx64, cl->ip); in callchain_list__sym_name()
1191 scnprintf(bf + printed, bfsize - printed, " %s", in callchain_list__sym_name()
1192 cl->ms.map ? in callchain_list__sym_name()
1193 map__dso(cl->ms.map)->short_name : in callchain_list__sym_name()
1199 char *callchain_node__scnprintf_value(struct callchain_node *node, in callchain_node__scnprintf_value() argument
1203 u64 period = callchain_cumul_hits(node); in callchain_node__scnprintf_value()
1204 unsigned count = callchain_cumul_counts(node); in callchain_node__scnprintf_value()
1207 period = node->hit; in callchain_node__scnprintf_value()
1208 count = node->count; in callchain_node__scnprintf_value()
1228 int callchain_node__fprintf_value(struct callchain_node *node, in callchain_node__fprintf_value() argument
1232 u64 period = callchain_cumul_hits(node); in callchain_node__fprintf_value()
1233 unsigned count = callchain_cumul_counts(node); in callchain_node__fprintf_value()
1236 period = node->hit; in callchain_node__fprintf_value()
1237 count = node->count; in callchain_node__fprintf_value()
1254 static void callchain_counts_value(struct callchain_node *node, in callchain_counts_value() argument
1260 list_for_each_entry(clist, &node->val, list) { in callchain_counts_value()
1262 *branch_count += clist->branch_count; in callchain_counts_value()
1265 *predicted_count += clist->predicted_count; in callchain_counts_value()
1268 *abort_count += clist->abort_count; in callchain_counts_value()
1271 *cycles_count += clist->cycles_count; in callchain_counts_value()
1275 static int callchain_node_branch_counts_cumul(struct callchain_node *node, in callchain_node_branch_counts_cumul() argument
1281 struct callchain_node *child; in callchain_node_branch_counts_cumul() local
1284 n = rb_first(&node->rb_root_in); in callchain_node_branch_counts_cumul()
1286 child = rb_entry(n, struct callchain_node, rb_node_in); in callchain_node_branch_counts_cumul()
1289 callchain_node_branch_counts_cumul(child, branch_count, in callchain_node_branch_counts_cumul()
1294 callchain_counts_value(child, branch_count, in callchain_node_branch_counts_cumul()
1318 return callchain_node_branch_counts_cumul(&root->node, in callchain_branch_counts()
1353 bf + printed, bfsize - printed, 0.0); in branch_to_str()
1359 bf + printed, bfsize - printed, 0.1); in branch_to_str()
1363 printed += scnprintf(bf + printed, bfsize - printed, ")"); in branch_to_str()
1380 bf + printed, bfsize - printed); in branch_from_str()
1387 v, bf + printed, bfsize - printed); in branch_from_str()
1391 bf + printed, bfsize - printed); in branch_from_str()
1396 printed += scnprintf(bf + printed, bfsize - printed, ")"); in branch_from_str()
1413 if (brtype_stat->branch_to) { in counts_str_build()
1455 branch_count = clist->branch_count; in callchain_list_counts__printf_value()
1456 predicted_count = clist->predicted_count; in callchain_list_counts__printf_value()
1457 abort_count = clist->abort_count; in callchain_list_counts__printf_value()
1458 cycles_count = clist->cycles_count; in callchain_list_counts__printf_value()
1459 iter_count = clist->iter_count; in callchain_list_counts__printf_value()
1460 iter_cycles = clist->iter_cycles; in callchain_list_counts__printf_value()
1461 from_count = clist->from_count; in callchain_list_counts__printf_value()
1466 from_count, &clist->brtype_stat); in callchain_list_counts__printf_value()
1469 static void free_callchain_node(struct callchain_node *node) in free_callchain_node() argument
1472 struct callchain_node *child; in free_callchain_node() local
1475 list_for_each_entry_safe(list, tmp, &node->parent_val, list) { in free_callchain_node()
1476 list_del_init(&list->list); in free_callchain_node()
1477 map__zput(list->ms.map); in free_callchain_node()
1478 maps__zput(list->ms.maps); in free_callchain_node()
1482 list_for_each_entry_safe(list, tmp, &node->val, list) { in free_callchain_node()
1483 list_del_init(&list->list); in free_callchain_node()
1484 map__zput(list->ms.map); in free_callchain_node()
1485 maps__zput(list->ms.maps); in free_callchain_node()
1489 n = rb_first(&node->rb_root_in); in free_callchain_node()
1491 child = container_of(n, struct callchain_node, rb_node_in); in free_callchain_node()
1493 rb_erase(&child->rb_node_in, &node->rb_root_in); in free_callchain_node()
1495 free_callchain_node(child); in free_callchain_node()
1496 free(child); in free_callchain_node()
1505 free_callchain_node(&root->node); in free_callchain()
1508 static u64 decay_callchain_node(struct callchain_node *node) in decay_callchain_node() argument
1510 struct callchain_node *child; in decay_callchain_node() local
1514 n = rb_first(&node->rb_root_in); in decay_callchain_node()
1516 child = container_of(n, struct callchain_node, rb_node_in); in decay_callchain_node()
1518 child_hits += decay_callchain_node(child); in decay_callchain_node()
1522 node->hit = (node->hit * 7) / 8; in decay_callchain_node()
1523 node->children_hit = child_hits; in decay_callchain_node()
1525 return node->hit; in decay_callchain_node()
1533 decay_callchain_node(&root->node); in decay_callchain()
1536 int callchain_node__make_parent_list(struct callchain_node *node) in callchain_node__make_parent_list() argument
1538 struct callchain_node *parent = node->parent; in callchain_node__make_parent_list()
1543 list_for_each_entry_reverse(chain, &parent->val, list) { in callchain_node__make_parent_list()
1548 new->has_children = false; in callchain_node__make_parent_list()
1549 new->ms.map = map__get(new->ms.map); in callchain_node__make_parent_list()
1550 list_add_tail(&new->list, &head); in callchain_node__make_parent_list()
1552 parent = parent->parent; in callchain_node__make_parent_list()
1556 list_move_tail(&chain->list, &node->parent_val); in callchain_node__make_parent_list()
1558 if (!list_empty(&node->parent_val)) { in callchain_node__make_parent_list()
1559 chain = list_first_entry(&node->parent_val, struct callchain_list, list); in callchain_node__make_parent_list()
1560 chain->has_children = rb_prev(&node->rb_node) || rb_next(&node->rb_node); in callchain_node__make_parent_list()
1562 chain = list_first_entry(&node->val, struct callchain_list, list); in callchain_node__make_parent_list()
1563 chain->has_children = false; in callchain_node__make_parent_list()
1569 list_del_init(&chain->list); in callchain_node__make_parent_list()
1570 map__zput(chain->ms.map); in callchain_node__make_parent_list()
1571 maps__zput(chain->ms.maps); in callchain_node__make_parent_list()
1574 return -ENOMEM; in callchain_node__make_parent_list()
1580 struct callchain_cursor_node *node, *next; in callchain_cursor__delete() local
1583 for (node = cursor->first; node != NULL; node = next) { in callchain_cursor__delete()
1584 next = node->next; in callchain_cursor__delete()
1585 free(node); in callchain_cursor__delete()
1623 struct callchain_cursor_node *node; in callchain_cursor__copy() local
1625 node = callchain_cursor_current(src); in callchain_cursor__copy()
1626 if (node == NULL) in callchain_cursor__copy()
1629 rc = callchain_cursor_append(dst, node->ip, &node->ms, in callchain_cursor__copy()
1630 node->branch, &node->branch_flags, in callchain_cursor__copy()
1631 node->nr_loop_iter, in callchain_cursor__copy()
1632 node->iter_cycles, in callchain_cursor__copy()
1633 node->branch_from, node->srcline); in callchain_cursor__copy()
1649 struct callchain_cursor_node *node; in callchain_cursor_reset() local
1651 cursor->nr = 0; in callchain_cursor_reset()
1652 cursor->last = &cursor->first; in callchain_cursor_reset()
1654 for (node = cursor->first; node != NULL; node = node->next) { in callchain_cursor_reset()
1655 map__zput(node->ms.map); in callchain_cursor_reset()
1656 maps__zput(node->ms.maps); in callchain_cursor_reset()
1691 match = match_chain_strings(base_chain->srcline, in chain_match()
1692 pair_chain->srcline); in chain_match()
1696 match = match_chain_dso_addresses(base_chain->ms.map, in chain_match()
1697 base_chain->ip, in chain_match()
1698 pair_chain->ms.map, in chain_match()
1699 pair_chain->ip); in chain_match()
1710 pair_chain = list_first_entry(&pair_cnode->val, in callchain_cnode_matched()
1714 list_for_each_entry(base_chain, &base_cnode->val, list) { in callchain_cnode_matched()
1715 if (&pair_chain->list == &pair_cnode->val) in callchain_cnode_matched()
1718 if (!base_chain->srcline || !pair_chain->srcline) { in callchain_cnode_matched()
1734 if (pair_chain && (&pair_chain->list != &pair_cnode->val)) in callchain_cnode_matched()
1742 struct rb_root *root = &he->sorted_chain; in count_callchain_hits()
1744 struct callchain_node *node; in count_callchain_hits() local
1748 node = rb_entry(rb_node, struct callchain_node, rb_node); in count_callchain_hits()
1749 chain_hits += node->hit; in count_callchain_hits()
1758 struct rb_node *next = rb_first_cached(&hists->entries); in callchain_total_hits()
1766 next = rb_next(&he->rb_node); in callchain_total_hits()
1777 list_for_each_entry(chain, &cnode->val, list) { in callchain_avg_cycles()
1778 if (chain->srcline && chain->branch_count) in callchain_avg_cycles()
1779 cycles += chain->cycles_count / chain->branch_count; in callchain_avg_cycles()