Lines Matching +full:entry +full:- +full:latency
1 // SPDX-License-Identifier: GPL-2.0
5 #include "build-id.h"
7 #include "kvm-stat.h"
11 #include "mem-events.h"
12 #include "mem-info.h"
24 #include "block-info.h"
51 return hists->col_len[col]; in hists__col_len()
56 hists->col_len[col] = len; in hists__set_col_len()
92 if (h->block_info) in hists__calc_col_len()
99 if (h->ms.sym) { in hists__calc_col_len()
100 symlen = h->ms.sym->namelen + 4; in hists__calc_col_len()
110 len = thread__comm_len(h->thread); in hists__calc_col_len()
114 if (h->ms.map) { in hists__calc_col_len()
115 len = dso__name_len(map__dso(h->ms.map)); in hists__calc_col_len()
119 if (h->parent) in hists__calc_col_len()
120 hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen); in hists__calc_col_len()
122 if (h->branch_info) { in hists__calc_col_len()
123 if (h->branch_info->from.ms.sym) { in hists__calc_col_len()
124 symlen = (int)h->branch_info->from.ms.sym->namelen + 4; in hists__calc_col_len()
129 symlen = dso__name_len(map__dso(h->branch_info->from.ms.map)); in hists__calc_col_len()
138 if (h->branch_info->to.ms.sym) { in hists__calc_col_len()
139 symlen = (int)h->branch_info->to.ms.sym->namelen + 4; in hists__calc_col_len()
144 symlen = dso__name_len(map__dso(h->branch_info->to.ms.map)); in hists__calc_col_len()
153 if (h->branch_info->srcline_from) in hists__calc_col_len()
155 strlen(h->branch_info->srcline_from)); in hists__calc_col_len()
156 if (h->branch_info->srcline_to) in hists__calc_col_len()
158 strlen(h->branch_info->srcline_to)); in hists__calc_col_len()
161 if (h->mem_info) { in hists__calc_col_len()
162 if (mem_info__daddr(h->mem_info)->ms.sym) { in hists__calc_col_len()
163 symlen = (int)mem_info__daddr(h->mem_info)->ms.sym->namelen + 4 in hists__calc_col_len()
177 if (mem_info__iaddr(h->mem_info)->ms.sym) { in hists__calc_col_len()
178 symlen = (int)mem_info__iaddr(h->mem_info)->ms.sym->namelen + 4 in hists__calc_col_len()
188 if (mem_info__daddr(h->mem_info)->ms.map) { in hists__calc_col_len()
189 symlen = dso__name_len(map__dso(mem_info__daddr(h->mem_info)->ms.map)); in hists__calc_col_len()
237 if (h->srcline) { in hists__calc_col_len()
238 len = MAX(strlen(h->srcline), strlen(sort_srcline.se_header)); in hists__calc_col_len()
242 if (h->srcfile) in hists__calc_col_len()
243 hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile)); in hists__calc_col_len()
245 if (h->transaction) in hists__calc_col_len()
249 if (h->trace_output) in hists__calc_col_len()
250 hists__new_col_len(hists, HISTC_TRACE, strlen(h->trace_output)); in hists__calc_col_len()
252 if (h->cgroup) { in hists__calc_col_len()
254 struct cgroup *cgrp = cgroup__find(maps__machine(h->ms.maps)->env, in hists__calc_col_len()
255 h->cgroup); in hists__calc_col_len()
257 cgrp_name = cgrp->name; in hists__calc_col_len()
265 struct rb_node *next = rb_first_cached(&hists->entries); in hists__output_recalc_col_len()
273 if (!n->filtered) in hists__output_recalc_col_len()
275 next = rb_next(&n->rb_node); in hists__output_recalc_col_len()
284 he_stat->period_sys += period; in he_stat__add_cpumode_period()
287 he_stat->period_us += period; in he_stat__add_cpumode_period()
290 he_stat->period_guest_sys += period; in he_stat__add_cpumode_period()
293 he_stat->period_guest_us += period; in he_stat__add_cpumode_period()
308 static void he_stat__add_period(struct he_stat *he_stat, u64 period, u64 latency) in he_stat__add_period() argument
310 he_stat->period += period; in he_stat__add_period()
311 he_stat->latency += latency; in he_stat__add_period()
312 he_stat->nr_events += 1; in he_stat__add_period()
317 dest->period += src->period; in he_stat__add_stat()
318 dest->period_sys += src->period_sys; in he_stat__add_stat()
319 dest->period_us += src->period_us; in he_stat__add_stat()
320 dest->period_guest_sys += src->period_guest_sys; in he_stat__add_stat()
321 dest->period_guest_us += src->period_guest_us; in he_stat__add_stat()
322 dest->weight1 += src->weight1; in he_stat__add_stat()
323 dest->weight2 += src->weight2; in he_stat__add_stat()
324 dest->weight3 += src->weight3; in he_stat__add_stat()
325 dest->nr_events += src->nr_events; in he_stat__add_stat()
326 dest->latency += src->latency; in he_stat__add_stat()
331 he_stat->period = (he_stat->period * 7) / 8; in he_stat__decay()
332 he_stat->nr_events = (he_stat->nr_events * 7) / 8; in he_stat__decay()
333 he_stat->weight1 = (he_stat->weight1 * 7) / 8; in he_stat__decay()
334 he_stat->weight2 = (he_stat->weight2 * 7) / 8; in he_stat__decay()
335 he_stat->weight3 = (he_stat->weight3 * 7) / 8; in he_stat__decay()
336 he_stat->latency = (he_stat->latency * 7) / 8; in he_stat__decay()
342 if (hists->nr_mem_stats == 0) in hists__update_mem_stat()
345 if (he->mem_stat == NULL) { in hists__update_mem_stat()
346 he->mem_stat = calloc(hists->nr_mem_stats, sizeof(*he->mem_stat)); in hists__update_mem_stat()
347 if (he->mem_stat == NULL) in hists__update_mem_stat()
348 return -1; in hists__update_mem_stat()
351 for (int i = 0; i < hists->nr_mem_stats; i++) { in hists__update_mem_stat()
352 int idx = mem_stat_index(hists->mem_stat_types[i], in hists__update_mem_stat()
353 mem_info__const_data_src(mi)->val); in hists__update_mem_stat()
356 he->mem_stat[i].entries[idx] += period; in hists__update_mem_stat()
357 hists->mem_stat_total[i].entries[idx] += period; in hists__update_mem_stat()
365 if (hists->nr_mem_stats == 0) in hists__add_mem_stat()
368 for (int i = 0; i < hists->nr_mem_stats; i++) { in hists__add_mem_stat()
370 dst->mem_stat[i].entries[k] += src->mem_stat[i].entries[k]; in hists__add_mem_stat()
377 if (hists->nr_mem_stats == 0) in hists__clone_mem_stat()
380 dst->mem_stat = calloc(hists->nr_mem_stats, sizeof(*dst->mem_stat)); in hists__clone_mem_stat()
381 if (dst->mem_stat == NULL) in hists__clone_mem_stat()
382 return -1; in hists__clone_mem_stat()
384 for (int i = 0; i < hists->nr_mem_stats; i++) { in hists__clone_mem_stat()
386 dst->mem_stat[i].entries[k] = src->mem_stat[i].entries[k]; in hists__clone_mem_stat()
393 if (hists->nr_mem_stats == 0) in hists__decay_mem_stat()
396 for (int i = 0; i < hists->nr_mem_stats; i++) { in hists__decay_mem_stat()
398 he->mem_stat[i].entries[k] = (he->mem_stat[i].entries[k] * 7) / 8; in hists__decay_mem_stat()
406 u64 prev_period = he->stat.period; in hists__decay_entry()
407 u64 prev_latency = he->stat.latency; in hists__decay_entry()
412 he_stat__decay(&he->stat); in hists__decay_entry()
414 he_stat__decay(he->stat_acc); in hists__decay_entry()
415 decay_callchain(he->callchain); in hists__decay_entry()
418 if (!he->depth) { in hists__decay_entry()
419 u64 period_diff = prev_period - he->stat.period; in hists__decay_entry()
420 u64 latency_diff = prev_latency - he->stat.latency; in hists__decay_entry()
422 hists->stats.total_period -= period_diff; in hists__decay_entry()
423 hists->stats.total_latency -= latency_diff; in hists__decay_entry()
424 if (!he->filtered) { in hists__decay_entry()
425 hists->stats.total_non_filtered_period -= period_diff; in hists__decay_entry()
426 hists->stats.total_non_filtered_latency -= latency_diff; in hists__decay_entry()
430 if (!he->leaf) { in hists__decay_entry()
432 struct rb_node *node = rb_first_cached(&he->hroot_out); in hists__decay_entry()
442 return he->stat.period == 0 && he->stat.latency == 0; in hists__decay_entry()
450 if (he->parent_he) { in hists__delete_entry()
451 root_in = &he->parent_he->hroot_in; in hists__delete_entry()
452 root_out = &he->parent_he->hroot_out; in hists__delete_entry()
455 root_in = &hists->entries_collapsed; in hists__delete_entry()
457 root_in = hists->entries_in; in hists__delete_entry()
458 root_out = &hists->entries; in hists__delete_entry()
461 rb_erase_cached(&he->rb_node_in, root_in); in hists__delete_entry()
462 rb_erase_cached(&he->rb_node, root_out); in hists__delete_entry()
464 --hists->nr_entries; in hists__delete_entry()
465 if (!he->filtered) in hists__delete_entry()
466 --hists->nr_non_filtered_entries; in hists__delete_entry()
473 struct rb_node *next = rb_first_cached(&hists->entries); in hists__decay_entries()
478 next = rb_next(&n->rb_node); in hists__decay_entries()
479 if (((zap_user && n->level == '.') || in hists__decay_entries()
480 (zap_kernel && n->level != '.') || in hists__decay_entries()
489 struct rb_node *next = rb_first_cached(&hists->entries); in hists__delete_entries()
494 next = rb_next(&n->rb_node); in hists__delete_entries()
502 struct rb_node *next = rb_first_cached(&hists->entries); in hists__get_entry()
511 next = rb_next(&n->rb_node); in hists__get_entry()
528 he->callchain_size = callchain_size; in hist_entry__init()
531 he->stat_acc = malloc(sizeof(he->stat)); in hist_entry__init()
532 if (he->stat_acc == NULL) in hist_entry__init()
533 return -ENOMEM; in hist_entry__init()
534 memcpy(he->stat_acc, &he->stat, sizeof(he->stat)); in hist_entry__init()
536 memset(&he->stat, 0, sizeof(he->stat)); in hist_entry__init()
539 he->ms.maps = maps__get(he->ms.maps); in hist_entry__init()
540 he->ms.map = map__get(he->ms.map); in hist_entry__init()
542 if (he->branch_info) { in hist_entry__init()
548 he->branch_info = malloc(sizeof(*he->branch_info)); in hist_entry__init()
549 if (he->branch_info == NULL) in hist_entry__init()
552 memcpy(he->branch_info, template->branch_info, in hist_entry__init()
553 sizeof(*he->branch_info)); in hist_entry__init()
555 he->branch_info->from.ms.maps = maps__get(he->branch_info->from.ms.maps); in hist_entry__init()
556 he->branch_info->from.ms.map = map__get(he->branch_info->from.ms.map); in hist_entry__init()
557 he->branch_info->to.ms.maps = maps__get(he->branch_info->to.ms.maps); in hist_entry__init()
558 he->branch_info->to.ms.map = map__get(he->branch_info->to.ms.map); in hist_entry__init()
561 if (he->mem_info) { in hist_entry__init()
562 he->mem_info = mem_info__clone(template->mem_info); in hist_entry__init()
563 if (he->mem_info == NULL) in hist_entry__init()
568 callchain_init(he->callchain); in hist_entry__init()
570 if (he->raw_data) { in hist_entry__init()
571 he->raw_data = memdup(he->raw_data, he->raw_size); in hist_entry__init()
572 if (he->raw_data == NULL) in hist_entry__init()
576 if (he->srcline && he->srcline != SRCLINE_UNKNOWN) { in hist_entry__init()
577 he->srcline = strdup(he->srcline); in hist_entry__init()
578 if (he->srcline == NULL) in hist_entry__init()
583 he->res_samples = calloc(symbol_conf.res_sample, in hist_entry__init()
585 if (!he->res_samples) in hist_entry__init()
589 INIT_LIST_HEAD(&he->pairs.node); in hist_entry__init()
590 he->thread = thread__get(he->thread); in hist_entry__init()
591 he->hroot_in = RB_ROOT_CACHED; in hist_entry__init()
592 he->hroot_out = RB_ROOT_CACHED; in hist_entry__init()
595 he->leaf = true; in hist_entry__init()
600 zfree(&he->srcline); in hist_entry__init()
603 zfree(&he->raw_data); in hist_entry__init()
606 if (he->branch_info) { in hist_entry__init()
607 map_symbol__exit(&he->branch_info->from.ms); in hist_entry__init()
608 map_symbol__exit(&he->branch_info->to.ms); in hist_entry__init()
609 zfree(&he->branch_info); in hist_entry__init()
611 if (he->mem_info) { in hist_entry__init()
612 map_symbol__exit(&mem_info__iaddr(he->mem_info)->ms); in hist_entry__init()
613 map_symbol__exit(&mem_info__daddr(he->mem_info)->ms); in hist_entry__init()
616 map_symbol__exit(&he->ms); in hist_entry__init()
617 zfree(&he->stat_acc); in hist_entry__init()
618 return -ENOMEM; in hist_entry__init()
639 struct hist_entry_ops *ops = template->ops; in hist_entry__new()
645 ops = template->ops = &default_ops; in hist_entry__new()
650 he = ops->new(callchain_size); in hist_entry__new()
654 ops->free(he); in hist_entry__new()
668 static void hist_entry__add_callchain_period(struct hist_entry *he, u64 period, u64 latency) in hist_entry__add_callchain_period() argument
673 he->hists->callchain_period += period; in hist_entry__add_callchain_period()
674 he->hists->callchain_latency += latency; in hist_entry__add_callchain_period()
675 if (!he->filtered) { in hist_entry__add_callchain_period()
676 he->hists->callchain_non_filtered_period += period; in hist_entry__add_callchain_period()
677 he->hists->callchain_non_filtered_latency += latency; in hist_entry__add_callchain_period()
682 struct hist_entry *entry, in hists__findnew_entry() argument
690 u64 period = entry->stat.period; in hists__findnew_entry()
691 u64 latency = entry->stat.latency; in hists__findnew_entry() local
694 p = &hists->entries_in->rb_root.rb_node; in hists__findnew_entry()
703 * function when searching an entry regardless which sort in hists__findnew_entry()
706 cmp = hist_entry__cmp(he, entry); in hists__findnew_entry()
709 he_stat__add_stat(&he->stat, &entry->stat); in hists__findnew_entry()
710 hist_entry__add_callchain_period(he, period, latency); in hists__findnew_entry()
713 he_stat__add_period(he->stat_acc, period, latency); in hists__findnew_entry()
715 block_info__delete(entry->block_info); in hists__findnew_entry()
717 kvm_info__zput(entry->kvm_info); in hists__findnew_entry()
720 * become out-of-date due to an exec() or in hists__findnew_entry()
722 * mis-adjust symbol addresses when computing in hists__findnew_entry()
725 if (hists__has(hists, sym) && he->ms.map != entry->ms.map) { in hists__findnew_entry()
726 if (he->ms.sym) { in hists__findnew_entry()
727 u64 addr = he->ms.sym->start; in hists__findnew_entry()
728 he->ms.sym = map__find_symbol(entry->ms.map, addr); in hists__findnew_entry()
731 map__put(he->ms.map); in hists__findnew_entry()
732 he->ms.map = map__get(entry->ms.map); in hists__findnew_entry()
738 p = &(*p)->rb_left; in hists__findnew_entry()
740 p = &(*p)->rb_right; in hists__findnew_entry()
745 he = hist_entry__new(entry, sample_self); in hists__findnew_entry()
750 hist_entry__add_callchain_period(he, period, latency); in hists__findnew_entry()
751 hists->nr_entries++; in hists__findnew_entry()
753 rb_link_node(&he->rb_node_in, parent, p); in hists__findnew_entry()
754 rb_insert_color_cached(&he->rb_node_in, hists->entries_in, leftmost); in hists__findnew_entry()
757 he_stat__add_cpumode_period(&he->stat, al->cpumode, period); in hists__findnew_entry()
759 he_stat__add_cpumode_period(he->stat_acc, al->cpumode, period); in hists__findnew_entry()
760 if (hists__update_mem_stat(hists, he, entry->mem_info, period) < 0) { in hists__findnew_entry()
769 unsigned thresh = -high % high; in random_max()
782 if (he->num_res < symbol_conf.res_sample) { in hists__res_sample()
783 j = he->num_res++; in hists__res_sample()
787 r = &he->res_samples[j]; in hists__res_sample()
788 r->time = sample->time; in hists__res_sample()
789 r->cpu = sample->cpu; in hists__res_sample()
790 r->tid = sample->tid; in hists__res_sample()
805 struct namespaces *ns = thread__namespaces(al->thread); in __hists__add_entry()
806 struct hist_entry entry = { in __hists__add_entry() local
807 .thread = al->thread, in __hists__add_entry()
808 .comm = thread__comm(al->thread), in __hists__add_entry()
810 .dev = ns ? ns->link_info[CGROUP_NS_INDEX].dev : 0, in __hists__add_entry()
811 .ino = ns ? ns->link_info[CGROUP_NS_INDEX].ino : 0, in __hists__add_entry()
813 .cgroup = sample->cgroup, in __hists__add_entry()
815 .maps = al->maps, in __hists__add_entry()
816 .map = al->map, in __hists__add_entry()
817 .sym = al->sym, in __hists__add_entry()
819 .srcline = (char *) al->srcline, in __hists__add_entry()
820 .socket = al->socket, in __hists__add_entry()
821 .cpu = al->cpu, in __hists__add_entry()
822 .cpumode = al->cpumode, in __hists__add_entry()
823 .ip = al->addr, in __hists__add_entry()
824 .level = al->level, in __hists__add_entry()
825 .code_page_size = sample->code_page_size, in __hists__add_entry()
826 .parallelism = al->parallelism, in __hists__add_entry()
829 .period = sample->period, in __hists__add_entry()
830 .weight1 = sample->weight, in __hists__add_entry()
831 .weight2 = sample->ins_lat, in __hists__add_entry()
832 .weight3 = sample->weight3, in __hists__add_entry()
833 .latency = al->latency, in __hists__add_entry()
836 .filtered = symbol__parent_filter(sym_parent) | al->filtered, in __hists__add_entry()
842 .transaction = sample->transaction, in __hists__add_entry()
843 .raw_data = sample->raw_data, in __hists__add_entry()
844 .raw_size = sample->raw_size, in __hists__add_entry()
846 .time = hist_time(sample->time), in __hists__add_entry()
847 .weight = sample->weight, in __hists__add_entry()
848 .ins_lat = sample->ins_lat, in __hists__add_entry()
849 .weight3 = sample->weight3, in __hists__add_entry()
850 .simd_flags = sample->simd_flags, in __hists__add_entry()
851 }, *he = hists__findnew_entry(hists, &entry, al, sample_self); in __hists__add_entry()
853 if (!hists->has_callchains && he && he->callchain_size != 0) in __hists__add_entry()
854 hists->has_callchains = true; in __hists__add_entry()
891 struct hist_entry entry = { in hists__add_entry_block() local
895 .maps = al->maps, in hists__add_entry_block()
896 .map = al->map, in hists__add_entry_block()
897 .sym = al->sym, in hists__add_entry_block()
899 }, *he = hists__findnew_entry(hists, &entry, al, false); in hists__add_entry_block()
921 struct perf_sample *sample = iter->sample; in iter_prepare_mem_entry()
926 return -ENOMEM; in iter_prepare_mem_entry()
928 iter->mi = mi; in iter_prepare_mem_entry()
936 struct mem_info *mi = iter->mi; in iter_add_single_mem_entry()
937 struct hists *hists = evsel__hists(iter->evsel); in iter_add_single_mem_entry()
938 struct perf_sample *sample = iter->sample; in iter_add_single_mem_entry()
942 return -EINVAL; in iter_add_single_mem_entry()
944 cost = sample->weight; in iter_add_single_mem_entry()
955 sample->period = cost; in iter_add_single_mem_entry()
957 he = hists__add_entry(hists, al, iter->parent, NULL, mi, NULL, in iter_add_single_mem_entry()
960 return -ENOMEM; in iter_add_single_mem_entry()
962 iter->he = he; in iter_add_single_mem_entry()
970 struct evsel *evsel = iter->evsel; in iter_finish_mem_entry()
972 struct hist_entry *he = iter->he; in iter_finish_mem_entry()
973 int err = -EINVAL; in iter_finish_mem_entry()
978 hists__inc_nr_samples(hists, he->filtered); in iter_finish_mem_entry()
980 err = hist_entry__append_callchain(he, iter->sample); in iter_finish_mem_entry()
983 mem_info__zput(iter->mi); in iter_finish_mem_entry()
985 iter->he = NULL; in iter_finish_mem_entry()
993 struct perf_sample *sample = iter->sample; in iter_prepare_branch_entry()
997 return -ENOMEM; in iter_prepare_branch_entry()
999 iter->curr = 0; in iter_prepare_branch_entry()
1000 iter->total = sample->branch_stack->nr; in iter_prepare_branch_entry()
1002 iter->bi = bi; in iter_prepare_branch_entry()
1016 struct branch_info *bi = iter->bi; in iter_next_branch_entry()
1017 int i = iter->curr; in iter_next_branch_entry()
1022 if (iter->curr >= iter->total) in iter_next_branch_entry()
1025 maps__put(al->maps); in iter_next_branch_entry()
1026 al->maps = maps__get(bi[i].to.ms.maps); in iter_next_branch_entry()
1027 map__put(al->map); in iter_next_branch_entry()
1028 al->map = map__get(bi[i].to.ms.map); in iter_next_branch_entry()
1029 al->sym = bi[i].to.ms.sym; in iter_next_branch_entry()
1030 al->addr = bi[i].to.addr; in iter_next_branch_entry()
1038 struct evsel *evsel = iter->evsel; in iter_add_next_branch_entry()
1040 struct perf_sample *sample = iter->sample; in iter_add_next_branch_entry()
1042 int i = iter->curr; in iter_add_next_branch_entry()
1045 bi = iter->bi; in iter_add_next_branch_entry()
1047 if (iter->hide_unresolved && !(bi[i].from.ms.sym && bi[i].to.ms.sym)) in iter_add_next_branch_entry()
1054 sample->period = 1; in iter_add_next_branch_entry()
1055 sample->weight = bi->flags.cycles ? bi->flags.cycles : 1; in iter_add_next_branch_entry()
1057 he = hists__add_entry(hists, al, iter->parent, &bi[i], NULL, NULL, in iter_add_next_branch_entry()
1060 return -ENOMEM; in iter_add_next_branch_entry()
1063 iter->he = he; in iter_add_next_branch_entry()
1064 iter->curr++; in iter_add_next_branch_entry()
1070 map_symbol__exit(&bi->from.ms); in branch_info__exit()
1071 map_symbol__exit(&bi->to.ms); in branch_info__exit()
1072 zfree_srcline(&bi->srcline_from); in branch_info__exit()
1073 zfree_srcline(&bi->srcline_to); in branch_info__exit()
1080 struct evsel *evsel = iter->evsel; in iter_finish_branch_entry()
1083 for (int i = 0; i < iter->total; i++) in iter_finish_branch_entry()
1084 branch_info__exit(&iter->bi[i]); in iter_finish_branch_entry()
1086 if (iter->he) in iter_finish_branch_entry()
1087 hists__inc_nr_samples(hists, iter->he->filtered); in iter_finish_branch_entry()
1089 zfree(&iter->bi); in iter_finish_branch_entry()
1090 iter->he = NULL; in iter_finish_branch_entry()
1092 return iter->curr >= iter->total ? 0 : -1; in iter_finish_branch_entry()
1105 struct evsel *evsel = iter->evsel; in iter_add_single_normal_entry()
1106 struct perf_sample *sample = iter->sample; in iter_add_single_normal_entry()
1109 he = hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL, in iter_add_single_normal_entry()
1112 return -ENOMEM; in iter_add_single_normal_entry()
1114 iter->he = he; in iter_add_single_normal_entry()
1122 struct hist_entry *he = iter->he; in iter_finish_normal_entry()
1123 struct evsel *evsel = iter->evsel; in iter_finish_normal_entry()
1124 struct perf_sample *sample = iter->sample; in iter_finish_normal_entry()
1129 iter->he = NULL; in iter_finish_normal_entry()
1131 hists__inc_nr_samples(evsel__hists(evsel), he->filtered); in iter_finish_normal_entry()
1144 return -ENOMEM; in iter_prepare_cumulative_entry()
1153 he_cache = malloc(sizeof(*he_cache) * (cursor->nr + 1)); in iter_prepare_cumulative_entry()
1155 return -ENOMEM; in iter_prepare_cumulative_entry()
1157 iter->he_cache = he_cache; in iter_prepare_cumulative_entry()
1158 iter->curr = 0; in iter_prepare_cumulative_entry()
1167 struct evsel *evsel = iter->evsel; in iter_add_single_cumulative_entry()
1169 struct perf_sample *sample = iter->sample; in iter_add_single_cumulative_entry()
1170 struct hist_entry **he_cache = iter->he_cache; in iter_add_single_cumulative_entry()
1174 he = hists__add_entry(hists, al, iter->parent, NULL, NULL, NULL, in iter_add_single_cumulative_entry()
1177 return -ENOMEM; in iter_add_single_cumulative_entry()
1179 iter->he = he; in iter_add_single_cumulative_entry()
1180 he_cache[iter->curr++] = he; in iter_add_single_cumulative_entry()
1185 * We need to re-initialize the cursor since callchain_append() in iter_add_single_cumulative_entry()
1190 hists__inc_nr_samples(hists, he->filtered); in iter_add_single_cumulative_entry()
1205 return fill_callchain_info(al, node, iter->hide_unresolved); in iter_next_cumulative_entry()
1212 struct symbol *sym_l = left->ms.sym; in hist_entry__fast__sym_diff()
1213 struct symbol *sym_r = right->ms.sym; in hist_entry__fast__sym_diff()
1216 return left->ip != right->ip; in hist_entry__fast__sym_diff()
1226 struct evsel *evsel = iter->evsel; in iter_add_next_cumulative_entry()
1227 struct perf_sample *sample = iter->sample; in iter_add_next_cumulative_entry()
1228 struct hist_entry **he_cache = iter->he_cache; in iter_add_next_cumulative_entry()
1232 .cpu = al->cpu, in iter_add_next_cumulative_entry()
1233 .thread = al->thread, in iter_add_next_cumulative_entry()
1234 .comm = thread__comm(al->thread), in iter_add_next_cumulative_entry()
1235 .ip = al->addr, in iter_add_next_cumulative_entry()
1237 .maps = al->maps, in iter_add_next_cumulative_entry()
1238 .map = al->map, in iter_add_next_cumulative_entry()
1239 .sym = al->sym, in iter_add_next_cumulative_entry()
1241 .srcline = (char *) al->srcline, in iter_add_next_cumulative_entry()
1242 .parent = iter->parent, in iter_add_next_cumulative_entry()
1243 .raw_data = sample->raw_data, in iter_add_next_cumulative_entry()
1244 .raw_size = sample->raw_size, in iter_add_next_cumulative_entry()
1251 return -ENOMEM; in iter_add_next_cumulative_entry()
1261 for (i = 0; i < iter->curr; i++) { in iter_add_next_cumulative_entry()
1272 iter->he = NULL; in iter_add_next_cumulative_entry()
1277 he = hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL, in iter_add_next_cumulative_entry()
1280 return -ENOMEM; in iter_add_next_cumulative_entry()
1282 iter->he = he; in iter_add_next_cumulative_entry()
1283 he_cache[iter->curr++] = he; in iter_add_next_cumulative_entry()
1286 callchain_append(he->callchain, &cursor, sample->period); in iter_add_next_cumulative_entry()
1294 mem_info__zput(iter->mi); in iter_finish_cumulative_entry()
1295 zfree(&iter->bi); in iter_finish_cumulative_entry()
1296 zfree(&iter->he_cache); in iter_finish_cumulative_entry()
1297 iter->he = NULL; in iter_finish_cumulative_entry()
1341 alm = map__get(al->map); in hist_entry_iter__add()
1343 err = sample__resolve_callchain(iter->sample, get_tls_callchain_cursor(), &iter->parent, in hist_entry_iter__add()
1344 iter->evsel, al, max_stack_depth); in hist_entry_iter__add()
1350 err = iter->ops->prepare_entry(iter, al); in hist_entry_iter__add()
1354 err = iter->ops->add_single_entry(iter, al); in hist_entry_iter__add()
1358 if (iter->he && iter->add_entry_cb) { in hist_entry_iter__add()
1359 err = iter->add_entry_cb(iter, al, true, arg); in hist_entry_iter__add()
1364 while (iter->ops->next_entry(iter, al)) { in hist_entry_iter__add()
1365 err = iter->ops->add_next_entry(iter, al); in hist_entry_iter__add()
1369 if (iter->he && iter->add_entry_cb) { in hist_entry_iter__add()
1370 err = iter->add_entry_cb(iter, al, false, arg); in hist_entry_iter__add()
1377 err2 = iter->ops->finish_entry(iter, al); in hist_entry_iter__add()
1391 struct hists *hists = left->hists; in hist_entry__cmp_impl()
1397 * Never collapse filtered and non-filtered entries. in hist_entry__cmp_impl()
1401 cmp = (int64_t)!!left->filtered - (int64_t)!!right->filtered; in hist_entry__cmp_impl()
1425 return hist_entry__cmp_impl(left->hists->hpp_list, left, right, in hist_entry__cmp()
1432 return hist_entry__cmp_impl(left->hists->hpp_list, left, right, in hist_entry__sort()
1439 return hist_entry__cmp_impl(left->hists->hpp_list, left, right, in hist_entry__collapse()
1454 struct hist_entry_ops *ops = he->ops; in hist_entry__delete()
1457 struct rb_root *root = &he->hroot_out.rb_root; in hist_entry__delete()
1466 thread__zput(he->thread); in hist_entry__delete()
1467 map_symbol__exit(&he->ms); in hist_entry__delete()
1469 if (he->branch_info) { in hist_entry__delete()
1470 branch_info__exit(he->branch_info); in hist_entry__delete()
1471 zfree(&he->branch_info); in hist_entry__delete()
1474 if (he->mem_info) { in hist_entry__delete()
1475 map_symbol__exit(&mem_info__iaddr(he->mem_info)->ms); in hist_entry__delete()
1476 map_symbol__exit(&mem_info__daddr(he->mem_info)->ms); in hist_entry__delete()
1477 mem_info__zput(he->mem_info); in hist_entry__delete()
1480 if (he->block_info) in hist_entry__delete()
1481 block_info__delete(he->block_info); in hist_entry__delete()
1483 if (he->kvm_info) in hist_entry__delete()
1484 kvm_info__zput(he->kvm_info); in hist_entry__delete()
1486 zfree(&he->res_samples); in hist_entry__delete()
1487 zfree(&he->stat_acc); in hist_entry__delete()
1488 zfree_srcline(&he->srcline); in hist_entry__delete()
1489 if (he->srcfile && he->srcfile[0]) in hist_entry__delete()
1490 zfree(&he->srcfile); in hist_entry__delete()
1491 free_callchain(he->callchain); in hist_entry__delete()
1492 zfree(&he->trace_output); in hist_entry__delete()
1493 zfree(&he->raw_data); in hist_entry__delete()
1494 zfree(&he->mem_stat); in hist_entry__delete()
1495 ops->free(he); in hist_entry__delete()
1500 * pre-calculated max length for this column, otherwise don't bother adding
1508 if (!list_is_last(&fmt->list, &he->hists->hpp_list->fields)) { in hist_entry__snprintf_alignment()
1509 const int width = fmt->width(fmt, hpp, he->hists); in hist_entry__snprintf_alignment()
1512 printed = scnprintf(hpp->buf, hpp->size, "%-*s", width - printed, " "); in hist_entry__snprintf_alignment()
1540 struct hist_entry *parent = he->parent_he; in hist_entry__check_and_remove_filter()
1571 perf_hpp_list__for_each_format(he->hpp_list, fmt) { in hist_entry__check_and_remove_filter()
1580 * If the filter is for current level entry, propagate in hist_entry__check_and_remove_filter()
1583 * non-filtered entries. in hist_entry__check_and_remove_filter()
1585 if (!(he->filtered & (1 << type))) { in hist_entry__check_and_remove_filter()
1587 parent->filtered &= ~(1 << type); in hist_entry__check_and_remove_filter()
1588 parent = parent->parent_he; in hist_entry__check_and_remove_filter()
1593 * If current entry doesn't have matching formats, set in hist_entry__check_and_remove_filter()
1597 * For lower-level entries, it inherits parent's in hist_entry__check_and_remove_filter()
1599 * non-filtered entry won't set the filter marker. in hist_entry__check_and_remove_filter()
1602 he->filtered |= (1 << type); in hist_entry__check_and_remove_filter()
1604 he->filtered |= (parent->filtered & (1 << type)); in hist_entry__check_and_remove_filter()
1622 hists__apply_filters(he->hists, he); in hist_entry__apply_hierarchy_filters()
1631 struct rb_node **p = &root->rb_root.rb_node; in hierarchy_insert_entry()
1643 he_stat__add_stat(&iter->stat, &he->stat); in hierarchy_insert_entry()
1649 p = &parent->rb_left; in hierarchy_insert_entry()
1651 p = &parent->rb_right; in hierarchy_insert_entry()
1660 hists->nr_entries++; in hierarchy_insert_entry()
1663 new->hpp_list = hpp_list; in hierarchy_insert_entry()
1664 new->parent_he = parent_he; in hierarchy_insert_entry()
1671 he->trace_output = NULL; in hierarchy_insert_entry()
1673 new->trace_output = NULL; in hierarchy_insert_entry()
1676 he->srcline = NULL; in hierarchy_insert_entry()
1678 new->srcline = NULL; in hierarchy_insert_entry()
1681 he->srcfile = NULL; in hierarchy_insert_entry()
1683 new->srcfile = NULL; in hierarchy_insert_entry()
1691 rb_link_node(&new->rb_node_in, parent, p); in hierarchy_insert_entry()
1692 rb_insert_color_cached(&new->rb_node_in, root, leftmost); in hierarchy_insert_entry()
1706 list_for_each_entry(node, &hists->hpp_formats, list) { in hists__hierarchy_insert_entry()
1708 if (node->level == 0 || node->skip) in hists__hierarchy_insert_entry()
1712 new_he = hierarchy_insert_entry(hists, root, he, parent, &node->hpp); in hists__hierarchy_insert_entry()
1714 ret = -1; in hists__hierarchy_insert_entry()
1718 root = &new_he->hroot_in; in hists__hierarchy_insert_entry()
1719 new_he->depth = depth++; in hists__hierarchy_insert_entry()
1724 new_he->leaf = true; in hists__hierarchy_insert_entry()
1731 return -1; in hists__hierarchy_insert_entry()
1735 new_he->callchain, in hists__hierarchy_insert_entry()
1736 he->callchain) < 0) in hists__hierarchy_insert_entry()
1737 ret = -1; in hists__hierarchy_insert_entry()
1744 /* return 0 (or -1) since it already applied filters */ in hists__hierarchy_insert_entry()
1752 struct rb_node **p = &root->rb_root.rb_node; in hists__collapse_insert_entry()
1770 he_stat__add_stat(&iter->stat, &he->stat); in hists__collapse_insert_entry()
1772 he_stat__add_stat(iter->stat_acc, he->stat_acc); in hists__collapse_insert_entry()
1780 if (callchain_merge(cursor, iter->callchain, he->callchain) < 0) in hists__collapse_insert_entry()
1781 ret = -1; in hists__collapse_insert_entry()
1791 p = &(*p)->rb_left; in hists__collapse_insert_entry()
1793 p = &(*p)->rb_right; in hists__collapse_insert_entry()
1797 hists->nr_entries++; in hists__collapse_insert_entry()
1799 rb_link_node(&he->rb_node_in, parent, p); in hists__collapse_insert_entry()
1800 rb_insert_color_cached(&he->rb_node_in, root, leftmost); in hists__collapse_insert_entry()
1808 mutex_lock(&hists->lock); in hists__get_rotate_entries_in()
1810 root = hists->entries_in; in hists__get_rotate_entries_in()
1811 if (++hists->entries_in > &hists->entries_in_array[1]) in hists__get_rotate_entries_in()
1812 hists->entries_in = &hists->entries_in_array[0]; in hists__get_rotate_entries_in()
1814 mutex_unlock(&hists->lock); in hists__get_rotate_entries_in()
1838 hists->nr_entries = 0; in hists__collapse_resort()
1848 next = rb_next(&n->rb_node_in); in hists__collapse_resort()
1850 rb_erase_cached(&n->rb_node_in, root); in hists__collapse_resort()
1851 ret = hists__collapse_insert_entry(hists, &hists->entries_collapsed, n); in hists__collapse_resort()
1853 return -1; in hists__collapse_resort()
1871 hists->nr_non_filtered_entries = 0; in hists__reset_filter_stats()
1872 hists->stats.total_non_filtered_period = 0; in hists__reset_filter_stats()
1873 hists->stats.total_non_filtered_latency = 0; in hists__reset_filter_stats()
1878 hists->nr_entries = 0; in hists__reset_stats()
1879 hists->stats.total_period = 0; in hists__reset_stats()
1880 hists->stats.total_latency = 0; in hists__reset_stats()
1887 hists->nr_non_filtered_entries++; in hists__inc_filter_stats()
1888 hists->stats.total_non_filtered_period += h->stat.period; in hists__inc_filter_stats()
1889 hists->stats.total_non_filtered_latency += h->stat.latency; in hists__inc_filter_stats()
1894 if (!h->filtered) in hists__inc_stats()
1897 hists->nr_entries++; in hists__inc_stats()
1898 hists->stats.total_period += h->stat.period; in hists__inc_stats()
1899 hists->stats.total_latency += h->stat.latency; in hists__inc_stats()
1907 node = rb_first_cached(&hists->entries); in hierarchy_recalc_total_periods()
1909 hists->stats.total_period = 0; in hierarchy_recalc_total_periods()
1910 hists->stats.total_non_filtered_period = 0; in hierarchy_recalc_total_periods()
1911 hists->stats.total_latency = 0; in hierarchy_recalc_total_periods()
1912 hists->stats.total_non_filtered_latency = 0; in hierarchy_recalc_total_periods()
1915 * recalculate total period using top-level entries only in hierarchy_recalc_total_periods()
1916 * since lower level entries only see non-filtered entries in hierarchy_recalc_total_periods()
1923 hists->stats.total_period += he->stat.period; in hierarchy_recalc_total_periods()
1924 hists->stats.total_latency += he->stat.latency; in hierarchy_recalc_total_periods()
1925 if (!he->filtered) { in hierarchy_recalc_total_periods()
1926 hists->stats.total_non_filtered_period += he->stat.period; in hierarchy_recalc_total_periods()
1927 hists->stats.total_non_filtered_latency += he->stat.latency; in hierarchy_recalc_total_periods()
1935 struct rb_node **p = &root->rb_root.rb_node; in hierarchy_insert_output_entry()
1946 p = &parent->rb_left; in hierarchy_insert_output_entry()
1948 p = &parent->rb_right; in hierarchy_insert_output_entry()
1953 rb_link_node(&he->rb_node, parent, p); in hierarchy_insert_output_entry()
1954 rb_insert_color_cached(&he->rb_node, root, leftmost); in hierarchy_insert_output_entry()
1956 /* update column width of dynamic entry */ in hierarchy_insert_output_entry()
1957 perf_hpp_list__for_each_sort_list(he->hpp_list, fmt) { in hierarchy_insert_output_entry()
1958 if (fmt->init) in hierarchy_insert_output_entry()
1959 fmt->init(fmt, he); in hierarchy_insert_output_entry()
1985 hists->nr_entries++; in hists__hierarchy_output_resort()
1986 if (!he->filtered) { in hists__hierarchy_output_resort()
1987 hists->nr_non_filtered_entries++; in hists__hierarchy_output_resort()
1991 if (!he->leaf) { in hists__hierarchy_output_resort()
1993 &he->hroot_in, in hists__hierarchy_output_resort()
1994 &he->hroot_out, in hists__hierarchy_output_resort()
2004 u64 total = he->stat.period; in hists__hierarchy_output_resort()
2007 total = he->stat_acc->period; in hists__hierarchy_output_resort()
2012 callchain_param.sort(&he->sorted_chain, he->callchain, in hists__hierarchy_output_resort()
2022 struct rb_node **p = &entries->rb_root.rb_node; in __hists__insert_output_entry()
2030 u64 total = he->stat.period; in __hists__insert_output_entry()
2033 total = he->stat_acc->period; in __hists__insert_output_entry()
2037 callchain_param.sort(&he->sorted_chain, he->callchain, in __hists__insert_output_entry()
2046 p = &(*p)->rb_left; in __hists__insert_output_entry()
2048 p = &(*p)->rb_right; in __hists__insert_output_entry()
2053 rb_link_node(&he->rb_node, parent, p); in __hists__insert_output_entry()
2054 rb_insert_color_cached(&he->rb_node, entries, leftmost); in __hists__insert_output_entry()
2058 if (fmt->init) in __hists__insert_output_entry()
2059 fmt->init(fmt, he); in __hists__insert_output_entry()
2073 callchain_total = hists->callchain_period; in output_resort()
2075 callchain_total = hists->callchain_non_filtered_period; in output_resort()
2084 &hists->entries_collapsed, in output_resort()
2085 &hists->entries, in output_resort()
2093 root = &hists->entries_collapsed; in output_resort()
2095 root = hists->entries_in; in output_resort()
2098 hists->entries = RB_ROOT_CACHED; in output_resort()
2102 next = rb_next(&n->rb_node_in); in output_resort()
2107 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain); in output_resort()
2110 if (!n->filtered) in output_resort()
2151 if (he->leaf || hmd == HMD_FORCE_SIBLING) in can_goto_child()
2154 if (he->unfolded || hmd == HMD_FORCE_CHILD) in can_goto_child()
2165 node = rb_last(&he->hroot_out.rb_root); in rb_hierarchy_last()
2176 node = rb_first_cached(&he->hroot_out); in __rb_hierarchy_next()
2181 he = he->parent_he; in __rb_hierarchy_next()
2185 node = rb_next(&he->rb_node); in __rb_hierarchy_next()
2198 he = he->parent_he; in rb_hierarchy_prev()
2202 return &he->rb_node; in rb_hierarchy_prev()
2211 if (he->leaf) in hist_entry__has_hierarchy_children()
2214 node = rb_first_cached(&he->hroot_out); in hist_entry__has_hierarchy_children()
2217 while (node && child->filtered) { in hist_entry__has_hierarchy_children()
2233 h->filtered &= ~(1 << filter); in hists__remove_entry_filter()
2236 struct hist_entry *parent = h->parent_he; in hists__remove_entry_filter()
2239 he_stat__add_stat(&parent->stat, &h->stat); in hists__remove_entry_filter()
2241 parent->filtered &= ~(1 << filter); in hists__remove_entry_filter()
2243 if (parent->filtered) in hists__remove_entry_filter()
2246 /* force fold unfiltered entry for simplicity */ in hists__remove_entry_filter()
2247 parent->unfolded = false; in hists__remove_entry_filter()
2248 parent->has_no_entry = false; in hists__remove_entry_filter()
2249 parent->row_offset = 0; in hists__remove_entry_filter()
2250 parent->nr_rows = 0; in hists__remove_entry_filter()
2252 parent = parent->parent_he; in hists__remove_entry_filter()
2256 if (h->filtered) in hists__remove_entry_filter()
2259 /* force fold unfiltered entry for simplicity */ in hists__remove_entry_filter()
2260 h->unfolded = false; in hists__remove_entry_filter()
2261 h->has_no_entry = false; in hists__remove_entry_filter()
2262 h->row_offset = 0; in hists__remove_entry_filter()
2263 h->nr_rows = 0; in hists__remove_entry_filter()
2265 hists->stats.nr_non_filtered_samples += h->stat.nr_events; in hists__remove_entry_filter()
2275 if (hists->dso_filter != NULL && in hists__filter_entry_by_dso()
2276 (he->ms.map == NULL || !RC_CHK_EQUAL(map__dso(he->ms.map), hists->dso_filter))) { in hists__filter_entry_by_dso()
2277 he->filtered |= (1 << HIST_FILTER__DSO); in hists__filter_entry_by_dso()
2287 if (hists->thread_filter != NULL && in hists__filter_entry_by_thread()
2288 !RC_CHK_EQUAL(he->thread, hists->thread_filter)) { in hists__filter_entry_by_thread()
2289 he->filtered |= (1 << HIST_FILTER__THREAD); in hists__filter_entry_by_thread()
2299 if (hists->symbol_filter_str != NULL && in hists__filter_entry_by_symbol()
2300 (!he->ms.sym || strstr(he->ms.sym->name, in hists__filter_entry_by_symbol()
2301 hists->symbol_filter_str) == NULL)) { in hists__filter_entry_by_symbol()
2302 he->filtered |= (1 << HIST_FILTER__SYMBOL); in hists__filter_entry_by_symbol()
2312 if ((hists->socket_filter > -1) && in hists__filter_entry_by_socket()
2313 (he->socket != hists->socket_filter)) { in hists__filter_entry_by_socket()
2314 he->filtered |= (1 << HIST_FILTER__SOCKET); in hists__filter_entry_by_socket()
2324 if (test_bit(he->parallelism, hists->parallelism_filter)) { in hists__filter_entry_by_parallelism()
2325 he->filtered |= (1 << HIST_FILTER__PARALLELISM); in hists__filter_entry_by_parallelism()
2337 hists->stats.nr_non_filtered_samples = 0; in hists__filter_by_type()
2342 for (nd = rb_first_cached(&hists->entries); nd; nd = rb_next(nd)) { in hists__filter_by_type()
2355 struct rb_node **p = &root->rb_root.rb_node; in resort_filtered_entry()
2367 p = &(*p)->rb_left; in resort_filtered_entry()
2369 p = &(*p)->rb_right; in resort_filtered_entry()
2374 rb_link_node(&he->rb_node, parent, p); in resort_filtered_entry()
2375 rb_insert_color_cached(&he->rb_node, root, leftmost); in resort_filtered_entry()
2377 if (he->leaf || he->filtered) in resort_filtered_entry()
2380 nd = rb_first_cached(&he->hroot_out); in resort_filtered_entry()
2385 rb_erase_cached(&h->rb_node, &he->hroot_out); in resort_filtered_entry()
2390 he->hroot_out = new_root; in resort_filtered_entry()
2398 hists->stats.nr_non_filtered_samples = 0; in hists__filter_hierarchy()
2403 nd = rb_first_cached(&hists->entries); in hists__filter_hierarchy()
2411 * case 1. non-matching type in hists__filter_hierarchy()
2415 memset(&h->stat, 0, sizeof(h->stat)); in hists__filter_hierarchy()
2416 h->filtered |= (1 << type); in hists__filter_hierarchy()
2418 nd = __rb_hierarchy_next(&h->rb_node, HMD_FORCE_CHILD); in hists__filter_hierarchy()
2425 h->filtered |= (1 << type); in hists__filter_hierarchy()
2427 nd = __rb_hierarchy_next(&h->rb_node, HMD_FORCE_SIBLING); in hists__filter_hierarchy()
2437 nd = __rb_hierarchy_next(&h->rb_node, HMD_FORCE_SIBLING); in hists__filter_hierarchy()
2447 nd = rb_first_cached(&hists->entries); in hists__filter_hierarchy()
2452 rb_erase_cached(&h->rb_node, &hists->entries); in hists__filter_hierarchy()
2457 hists->entries = new_root; in hists__filter_hierarchy()
2464 hists->thread_filter); in hists__filter_by_thread()
2474 hists->dso_filter); in hists__filter_by_dso()
2484 hists->symbol_filter_str); in hists__filter_by_symbol()
2494 &hists->socket_filter); in hists__filter_by_socket()
2504 hists->parallelism_filter); in hists__filter_by_parallelism()
2512 ++stats->nr_events[0]; in events_stats__inc()
2513 ++stats->nr_events[type]; in events_stats__inc()
2518 ++stats->nr_samples; in hists_stats__inc()
2523 hists_stats__inc(&hists->stats); in hists__inc_nr_events()
2528 hists_stats__inc(&hists->stats); in hists__inc_nr_samples()
2530 hists->stats.nr_non_filtered_samples++; in hists__inc_nr_samples()
2535 hists->stats.nr_lost_samples += lost; in hists__inc_nr_lost_samples()
2540 hists->stats.nr_dropped_samples += lost; in hists__inc_nr_dropped_samples()
2554 root = &hists->entries_collapsed; in hists__add_dummy_entry()
2556 root = hists->entries_in; in hists__add_dummy_entry()
2558 p = &root->rb_root.rb_node; in hists__add_dummy_entry()
2570 p = &(*p)->rb_left; in hists__add_dummy_entry()
2572 p = &(*p)->rb_right; in hists__add_dummy_entry()
2579 memset(&he->stat, 0, sizeof(he->stat)); in hists__add_dummy_entry()
2580 he->hists = hists; in hists__add_dummy_entry()
2582 memset(he->stat_acc, 0, sizeof(he->stat)); in hists__add_dummy_entry()
2583 rb_link_node(&he->rb_node_in, parent, p); in hists__add_dummy_entry()
2584 rb_insert_color_cached(&he->rb_node_in, root, leftmost); in hists__add_dummy_entry()
2586 he->dummy = true; in hists__add_dummy_entry()
2601 p = &root->rb_root.rb_node; in add_dummy_hierarchy_entry()
2607 cmp = hist_entry__collapse_hierarchy(he->hpp_list, he, pair); in add_dummy_hierarchy_entry()
2612 p = &parent->rb_left; in add_dummy_hierarchy_entry()
2614 p = &parent->rb_right; in add_dummy_hierarchy_entry()
2621 rb_link_node(&he->rb_node_in, parent, p); in add_dummy_hierarchy_entry()
2622 rb_insert_color_cached(&he->rb_node_in, root, leftmost); in add_dummy_hierarchy_entry()
2624 he->dummy = true; in add_dummy_hierarchy_entry()
2625 he->hists = hists; in add_dummy_hierarchy_entry()
2626 memset(&he->stat, 0, sizeof(he->stat)); in add_dummy_hierarchy_entry()
2639 n = hists->entries_collapsed.rb_root.rb_node; in hists__find_entry()
2641 n = hists->entries_in->rb_root.rb_node; in hists__find_entry()
2648 n = n->rb_left; in hists__find_entry()
2650 n = n->rb_right; in hists__find_entry()
2661 struct rb_node *n = root->rb_root.rb_node; in hists__find_hierarchy_entry()
2668 cmp = hist_entry__collapse_hierarchy(he->hpp_list, iter, he); in hists__find_hierarchy_entry()
2670 n = n->rb_left; in hists__find_hierarchy_entry()
2672 n = n->rb_right; in hists__find_hierarchy_entry()
2692 hists__match_hierarchy(&pos->hroot_in, &pair->hroot_in); in hists__match_hierarchy()
2708 return hists__match_hierarchy(&leader->entries_collapsed, in hists__match()
2709 &other->entries_collapsed); in hists__match()
2713 root = &leader->entries_collapsed; in hists__match()
2715 root = leader->entries_in; in hists__match()
2740 list_for_each_entry(leader, &pos->pairs.head, pairs.node) { in hists__link_hierarchy()
2741 if (leader->hists == leader_hists) { in hists__link_hierarchy()
2747 return -1; in hists__link_hierarchy()
2752 return -1; in hists__link_hierarchy()
2755 leader->parent_he = parent; in hists__link_hierarchy()
2760 if (!pos->leaf) { in hists__link_hierarchy()
2762 &leader->hroot_in, in hists__link_hierarchy()
2763 &pos->hroot_in) < 0) in hists__link_hierarchy()
2764 return -1; in hists__link_hierarchy()
2772 * we find them, just add a dummy entry on the leader hists, with period=0,
2784 &leader->entries_collapsed, in hists__link()
2785 &other->entries_collapsed); in hists__link()
2789 root = &other->entries_collapsed; in hists__link()
2791 root = other->entries_in; in hists__link()
2799 return -1; in hists__link()
2814 root = &hists->entries_collapsed; in hists__unlink()
2816 root = hists->entries_in; in hists__unlink()
2820 list_del_init(&pos->pairs.node); in hists__unlink()
2834 if (bs && bs->nr && entries[0].flags.cycles) { in hist__account_cycles()
2849 for (int i = bs->nr - 1; i >= 0; i--) { in hist__account_cycles()
2859 for (unsigned int i = 0; i < bs->nr; i++) { in hist__account_cycles()
2875 u64 total_samples = hists->stats.nr_samples; in evlist__fprintf_nr_events()
2877 total_samples += hists->stats.nr_lost_samples; in evlist__fprintf_nr_events()
2878 total_samples += hists->stats.nr_dropped_samples; in evlist__fprintf_nr_events()
2884 if (hists->stats.nr_samples) in evlist__fprintf_nr_events()
2886 "SAMPLE", hists->stats.nr_samples); in evlist__fprintf_nr_events()
2887 if (hists->stats.nr_lost_samples) in evlist__fprintf_nr_events()
2889 "LOST_SAMPLES", hists->stats.nr_lost_samples); in evlist__fprintf_nr_events()
2890 if (hists->stats.nr_dropped_samples) in evlist__fprintf_nr_events()
2892 "LOST_SAMPLES (BPF)", hists->stats.nr_dropped_samples); in evlist__fprintf_nr_events()
2901 return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period : in hists__total_period()
2902 hists->stats.total_period; in hists__total_period()
2907 return symbol_conf.filter_relative ? hists->stats.total_non_filtered_latency : in hists__total_latency()
2908 hists->stats.total_latency; in hists__total_latency()
2915 const struct dso *dso = hists->dso_filter; in __hists__scnprintf_title()
2916 struct thread *thread = hists->thread_filter; in __hists__scnprintf_title()
2917 int socket_id = hists->socket_filter; in __hists__scnprintf_title()
2918 unsigned long nr_samples = hists->stats.nr_samples; in __hists__scnprintf_title()
2919 u64 nr_events = hists->stats.total_period; in __hists__scnprintf_title()
2928 nr_samples = hists->stats.nr_non_filtered_samples; in __hists__scnprintf_title()
2929 nr_events = hists->stats.total_non_filtered_period; in __hists__scnprintf_title()
2942 nr_samples += pos_hists->stats.nr_non_filtered_samples; in __hists__scnprintf_title()
2943 nr_events += pos_hists->stats.total_non_filtered_period; in __hists__scnprintf_title()
2945 nr_samples += pos_hists->stats.nr_samples; in __hists__scnprintf_title()
2946 nr_events += pos_hists->stats.total_period; in __hists__scnprintf_title()
2952 strstr(ev_name, "call-graph=no")) in __hists__scnprintf_title()
2956 scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", evsel->core.attr.sample_freq); in __hists__scnprintf_title()
2961 nr_samples, unit, evsel->core.nr_members > 1 ? "s" : "", in __hists__scnprintf_title()
2965 if (hists->uid_filter_str) in __hists__scnprintf_title()
2966 printed += snprintf(bf + printed, size - printed, in __hists__scnprintf_title()
2967 ", UID: %s", hists->uid_filter_str); in __hists__scnprintf_title()
2970 printed += scnprintf(bf + printed, size - printed, in __hists__scnprintf_title()
2975 printed += scnprintf(bf + printed, size - printed, in __hists__scnprintf_title()
2981 printed += scnprintf(bf + printed, size - printed, in __hists__scnprintf_title()
2983 if (socket_id > -1) in __hists__scnprintf_title()
2984 printed += scnprintf(bf + printed, size - printed, in __hists__scnprintf_title()
2999 return -1; in parse_filter_percentage()
3016 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT_CACHED; in __hists__init()
3017 hists->entries_in = &hists->entries_in_array[0]; in __hists__init()
3018 hists->entries_collapsed = RB_ROOT_CACHED; in __hists__init()
3019 hists->entries = RB_ROOT_CACHED; in __hists__init()
3020 mutex_init(&hists->lock); in __hists__init()
3021 hists->socket_filter = -1; in __hists__init()
3022 hists->parallelism_filter = symbol_conf.parallelism_filter; in __hists__init()
3023 hists->hpp_list = hpp_list; in __hists__init()
3024 INIT_LIST_HEAD(&hists->hpp_formats); in __hists__init()
3033 while (!RB_EMPTY_ROOT(&root->rb_root)) { in hists__delete_remaining_entries()
3045 hists__delete_remaining_entries(&hists->entries_in_array[0]); in hists__delete_all_entries()
3046 hists__delete_remaining_entries(&hists->entries_in_array[1]); in hists__delete_all_entries()
3047 hists__delete_remaining_entries(&hists->entries_collapsed); in hists__delete_all_entries()
3057 zfree(&hists->mem_stat_types); in hists_evsel__exit()
3058 zfree(&hists->mem_stat_total); in hists_evsel__exit()
3060 list_for_each_entry_safe(node, tmp, &hists->hpp_formats, list) { in hists_evsel__exit()
3061 perf_hpp_list__for_each_format_safe(&node->hpp, fmt, pos) { in hists_evsel__exit()
3062 list_del_init(&fmt->list); in hists_evsel__exit()
3065 list_del_init(&node->list); in hists_evsel__exit()
3095 INIT_LIST_HEAD(&list->fields); in perf_hpp_list__init()
3096 INIT_LIST_HEAD(&list->sorts); in perf_hpp_list__init()