Lines Matching refs:hists
34 static bool hists__filter_entry_by_dso(struct hists *hists,
36 static bool hists__filter_entry_by_thread(struct hists *hists,
38 static bool hists__filter_entry_by_symbol(struct hists *hists,
40 static bool hists__filter_entry_by_socket(struct hists *hists,
43 u16 hists__col_len(struct hists *hists, enum hist_column col)
45 return hists->col_len[col];
48 void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len)
50 hists->col_len[col] = len;
53 bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len)
55 if (len > hists__col_len(hists, col)) {
56 hists__set_col_len(hists, col, len);
62 void hists__reset_col_len(struct hists *hists)
67 hists__set_col_len(hists, col, 0);
70 static void hists__set_unres_dso_col_len(struct hists *hists, int dso)
74 if (hists__col_len(hists, dso) < unresolved_col_width &&
77 hists__set_col_len(hists, dso, unresolved_col_width);
80 void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
97 hists__new_col_len(hists, HISTC_SYMBOL, symlen);
100 hists__new_col_len(hists, HISTC_SYMBOL, symlen);
101 hists__set_unres_dso_col_len(hists, HISTC_DSO);
105 if (hists__new_col_len(hists, HISTC_COMM, len))
106 hists__set_col_len(hists, HISTC_THREAD, len + 8);
110 hists__new_col_len(hists, HISTC_DSO, len);
114 hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen);
121 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
124 hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
127 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
128 hists__new_col_len(hists, HISTC_ADDR_FROM, symlen);
129 hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
136 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
139 hists__new_col_len(hists, HISTC_DSO_TO, symlen);
142 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
143 hists__new_col_len(hists, HISTC_ADDR_TO, symlen);
144 hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
148 hists__new_col_len(hists, HISTC_SRCLINE_FROM,
151 hists__new_col_len(hists, HISTC_SRCLINE_TO,
159 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
161 hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
165 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
167 hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
174 hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
178 hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
184 hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
188 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
191 hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR,
194 hists__new_col_len(hists, HISTC_MEM_DATA_PAGE_SIZE,
199 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
200 hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL, symlen);
201 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
204 hists__new_col_len(hists, HISTC_CGROUP, 6);
205 hists__new_col_len(hists, HISTC_CGROUP_ID, 20);
206 hists__new_col_len(hists, HISTC_CPU, 3);
207 hists__new_col_len(hists, HISTC_SOCKET, 6);
208 hists__new_col_len(hists, HISTC_MEM_LOCKED, 6);
209 hists__new_col_len(hists, HISTC_MEM_TLB, 22);
210 hists__new_col_len(hists, HISTC_MEM_SNOOP, 12);
211 hists__new_col_len(hists, HISTC_MEM_LVL, 36 + 3);
212 hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
213 hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
214 hists__new_col_len(hists, HISTC_MEM_BLOCKED, 10);
215 hists__new_col_len(hists, HISTC_LOCAL_INS_LAT, 13);
216 hists__new_col_len(hists, HISTC_GLOBAL_INS_LAT, 13);
217 hists__new_col_len(hists, HISTC_LOCAL_P_STAGE_CYC, 13);
218 hists__new_col_len(hists, HISTC_GLOBAL_P_STAGE_CYC, 13);
219 hists__new_col_len(hists, HISTC_ADDR, BITS_PER_LONG / 4 + 2);
222 hists__new_col_len(hists, HISTC_TIME, 16);
224 hists__new_col_len(hists, HISTC_TIME, 12);
225 hists__new_col_len(hists, HISTC_CODE_PAGE_SIZE, 6);
229 hists__new_col_len(hists, HISTC_SRCLINE, len);
233 hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile));
236 hists__new_col_len(hists, HISTC_TRANSACTION,
240 hists__new_col_len(hists, HISTC_TRACE, strlen(h->trace_output));
249 hists__new_col_len(hists, HISTC_CGROUP, strlen(cgrp_name));
253 void hists__output_recalc_col_len(struct hists *hists, int max_rows)
255 struct rb_node *next = rb_first_cached(&hists->entries);
259 hists__reset_col_len(hists);
264 hists__calc_col_len(hists, n);
321 static void hists__delete_entry(struct hists *hists, struct hist_entry *he);
323 static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
339 hists->stats.total_period -= diff;
341 hists->stats.total_non_filtered_period -= diff;
351 if (hists__decay_entry(hists, child))
352 hists__delete_entry(hists, child);
359 static void hists__delete_entry(struct hists *hists, struct hist_entry *he)
368 if (hists__has(hists, need_collapse))
369 root_in = &hists->entries_collapsed;
371 root_in = hists->entries_in;
372 root_out = &hists->entries;
378 --hists->nr_entries;
380 --hists->nr_non_filtered_entries;
385 void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
387 struct rb_node *next = rb_first_cached(&hists->entries);
395 hists__decay_entry(hists, n))) {
396 hists__delete_entry(hists, n);
401 void hists__delete_entries(struct hists *hists)
403 struct rb_node *next = rb_first_cached(&hists->entries);
410 hists__delete_entry(hists, n);
414 struct hist_entry *hists__get_entry(struct hists *hists, int idx)
416 struct rb_node *next = rb_first_cached(&hists->entries);
586 he->hists->callchain_period += period;
588 he->hists->callchain_non_filtered_period += period;
591 static struct hist_entry *hists__findnew_entry(struct hists *hists,
603 p = &hists->entries_in->rb_root.rb_node;
661 hists->nr_entries++;
664 rb_insert_color_cached(&he->rb_node_in, hists->entries_in, leftmost);
700 __hists__add_entry(struct hists *hists,
738 .hists = hists,
752 }, *he = hists__findnew_entry(hists, &entry, al, sample_self);
754 if (!hists->has_callchains && he && he->callchain_size != 0)
755 hists->has_callchains = true;
761 struct hist_entry *hists__add_entry(struct hists *hists,
770 return __hists__add_entry(hists, al, sym_parent, bi, mi, ki, NULL,
774 struct hist_entry *hists__add_entry_ops(struct hists *hists,
784 return __hists__add_entry(hists, al, sym_parent, bi, mi, ki, NULL,
788 struct hist_entry *hists__add_entry_block(struct hists *hists,
794 .hists = hists,
800 }, *he = hists__findnew_entry(hists, &entry, al, false);
838 struct hists *hists = evsel__hists(iter->evsel);
858 he = hists__add_entry(hists, al, iter->parent, NULL, mi, NULL,
872 struct hists *hists = evsel__hists(evsel);
879 hists__inc_nr_samples(hists, he->filtered);
945 struct hists *hists = evsel__hists(evsel);
963 he = hists__add_entry(hists, al, iter->parent, &bi[i], NULL, NULL,
968 hists__inc_nr_samples(hists, he->filtered);
1059 struct hists *hists = evsel__hists(evsel);
1065 he = hists__add_entry(hists, al, iter->parent, NULL, NULL, NULL,
1081 hists__inc_nr_samples(hists, he->filtered);
1122 .hists = evsel__hists(evsel),
1139 bool fast = hists__has(he_tmp.hists, sym);
1278 struct hists *hists = left->hists;
1282 hists__for_each_sort_list(hists, fmt) {
1284 !perf_hpp__defined_dynamic_entry(fmt, hists))
1298 struct hists *hists = left->hists;
1302 hists__for_each_sort_list(hists, fmt) {
1304 !perf_hpp__defined_dynamic_entry(fmt, hists))
1364 if (!list_is_last(&fmt->list, &he->hists->hpp_list->fields)) {
1365 const int width = fmt->width(fmt, hpp, he->hists);
1379 static void hists__apply_filters(struct hists *hists, struct hist_entry *he);
1380 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *he,
1471 hists__apply_filters(he->hists, he);
1474 static struct hist_entry *hierarchy_insert_entry(struct hists *hists,
1515 hists->nr_entries++;
1546 static int hists__hierarchy_insert_entry(struct hists *hists,
1556 list_for_each_entry(node, &hists->hpp_formats, list) {
1562 new_he = hierarchy_insert_entry(hists, root, he, parent, &node->hpp);
1598 static int hists__collapse_insert_entry(struct hists *hists,
1609 return hists__hierarchy_insert_entry(hists, root, he);
1646 hists->nr_entries++;
1653 struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists)
1657 mutex_lock(&hists->lock);
1659 root = hists->entries_in;
1660 if (++hists->entries_in > &hists->entries_in_array[1])
1661 hists->entries_in = &hists->entries_in_array[0];
1663 mutex_unlock(&hists->lock);
1668 static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
1670 hists__filter_entry_by_dso(hists, he);
1671 hists__filter_entry_by_thread(hists, he);
1672 hists__filter_entry_by_symbol(hists, he);
1673 hists__filter_entry_by_socket(hists, he);
1676 int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
1683 if (!hists__has(hists, need_collapse))
1686 hists->nr_entries = 0;
1688 root = hists__get_rotate_entries_in(hists);
1699 ret = hists__collapse_insert_entry(hists, &hists->entries_collapsed, n);
1709 hists__apply_filters(hists, n);
1719 struct hists *hists = a->hists;
1723 hists__for_each_sort_list(hists, fmt) {
1724 if (perf_hpp__should_skip(fmt, a->hists))
1735 static void hists__reset_filter_stats(struct hists *hists)
1737 hists->nr_non_filtered_entries = 0;
1738 hists->stats.total_non_filtered_period = 0;
1741 void hists__reset_stats(struct hists *hists)
1743 hists->nr_entries = 0;
1744 hists->stats.total_period = 0;
1746 hists__reset_filter_stats(hists);
1749 static void hists__inc_filter_stats(struct hists *hists, struct hist_entry *h)
1751 hists->nr_non_filtered_entries++;
1752 hists->stats.total_non_filtered_period += h->stat.period;
1755 void hists__inc_stats(struct hists *hists, struct hist_entry *h)
1758 hists__inc_filter_stats(hists, h);
1760 hists->nr_entries++;
1761 hists->stats.total_period += h->stat.period;
1764 static void hierarchy_recalc_total_periods(struct hists *hists)
1769 node = rb_first_cached(&hists->entries);
1771 hists->stats.total_period = 0;
1772 hists->stats.total_non_filtered_period = 0;
1783 hists->stats.total_period += he->stat.period;
1785 hists->stats.total_non_filtered_period += he->stat.period;
1820 static void hists__hierarchy_output_resort(struct hists *hists,
1842 hists->nr_entries++;
1844 hists->nr_non_filtered_entries++;
1845 hists__calc_col_len(hists, he);
1849 hists__hierarchy_output_resort(hists, prog,
1920 static void output_resort(struct hists *hists, struct ui_progress *prog,
1930 callchain_total = hists->callchain_period;
1932 callchain_total = hists->callchain_non_filtered_period;
1936 hists__reset_stats(hists);
1937 hists__reset_col_len(hists);
1940 hists__hierarchy_output_resort(hists, prog,
1941 &hists->entries_collapsed,
1942 &hists->entries,
1945 hierarchy_recalc_total_periods(hists);
1949 if (hists__has(hists, need_collapse))
1950 root = &hists->entries_collapsed;
1952 root = hists->entries_in;
1955 hists->entries = RB_ROOT_CACHED;
1964 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain);
1965 hists__inc_stats(hists, n);
1968 hists__calc_col_len(hists, n);
1995 void hists__output_resort(struct hists *hists, struct ui_progress *prog)
1997 output_resort(hists, prog, symbol_conf.use_callchain, NULL, NULL);
2000 void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
2003 output_resort(hists, prog, symbol_conf.use_callchain, cb, NULL);
2087 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
2122 hists->stats.nr_non_filtered_samples += h->stat.nr_events;
2124 hists__inc_filter_stats(hists, h);
2125 hists__calc_col_len(hists, h);
2129 static bool hists__filter_entry_by_dso(struct hists *hists,
2132 if (hists->dso_filter != NULL &&
2133 (he->ms.map == NULL || map__dso(he->ms.map) != hists->dso_filter)) {
2141 static bool hists__filter_entry_by_thread(struct hists *hists,
2144 if (hists->thread_filter != NULL &&
2145 RC_CHK_ACCESS(he->thread) != RC_CHK_ACCESS(hists->thread_filter)) {
2153 static bool hists__filter_entry_by_symbol(struct hists *hists,
2156 if (hists->symbol_filter_str != NULL &&
2158 hists->symbol_filter_str) == NULL)) {
2166 static bool hists__filter_entry_by_socket(struct hists *hists,
2169 if ((hists->socket_filter > -1) &&
2170 (he->socket != hists->socket_filter)) {
2178 typedef bool (*filter_fn_t)(struct hists *hists, struct hist_entry *he);
2180 static void hists__filter_by_type(struct hists *hists, int type, filter_fn_t filter)
2184 hists->stats.nr_non_filtered_samples = 0;
2186 hists__reset_filter_stats(hists);
2187 hists__reset_col_len(hists);
2189 for (nd = rb_first_cached(&hists->entries); nd; nd = rb_next(nd)) {
2192 if (filter(hists, h))
2195 hists__remove_entry_filter(hists, h, type);
2240 static void hists__filter_hierarchy(struct hists *hists, int type, const void *arg)
2245 hists->stats.nr_non_filtered_samples = 0;
2247 hists__reset_filter_stats(hists);
2248 hists__reset_col_len(hists);
2250 nd = rb_first_cached(&hists->entries);
2278 * add period to hists and parents, erase the filter marker
2282 hists__remove_entry_filter(hists, h, type);
2288 hierarchy_recalc_total_periods(hists);
2294 nd = rb_first_cached(&hists->entries);
2299 rb_erase_cached(&h->rb_node, &hists->entries);
2304 hists->entries = new_root;
2307 void hists__filter_by_thread(struct hists *hists)
2310 hists__filter_hierarchy(hists, HIST_FILTER__THREAD,
2311 hists->thread_filter);
2313 hists__filter_by_type(hists, HIST_FILTER__THREAD,
2317 void hists__filter_by_dso(struct hists *hists)
2320 hists__filter_hierarchy(hists, HIST_FILTER__DSO,
2321 hists->dso_filter);
2323 hists__filter_by_type(hists, HIST_FILTER__DSO,
2327 void hists__filter_by_symbol(struct hists *hists)
2330 hists__filter_hierarchy(hists, HIST_FILTER__SYMBOL,
2331 hists->symbol_filter_str);
2333 hists__filter_by_type(hists, HIST_FILTER__SYMBOL,
2337 void hists__filter_by_socket(struct hists *hists)
2340 hists__filter_hierarchy(hists, HIST_FILTER__SOCKET,
2341 &hists->socket_filter);
2343 hists__filter_by_type(hists, HIST_FILTER__SOCKET,
2358 void hists__inc_nr_events(struct hists *hists)
2360 hists_stats__inc(&hists->stats);
2363 void hists__inc_nr_samples(struct hists *hists, bool filtered)
2365 hists_stats__inc(&hists->stats);
2367 hists->stats.nr_non_filtered_samples++;
2370 void hists__inc_nr_lost_samples(struct hists *hists, u32 lost)
2372 hists->stats.nr_lost_samples += lost;
2375 static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
2385 if (hists__has(hists, need_collapse))
2386 root = &hists->entries_collapsed;
2388 root = hists->entries_in;
2412 he->hists = hists;
2417 hists__inc_stats(hists, he);
2424 static struct hist_entry *add_dummy_hierarchy_entry(struct hists *hists,
2463 he->hists = hists;
2465 hists__inc_stats(hists, he);
2471 static struct hist_entry *hists__find_entry(struct hists *hists,
2476 if (hists__has(hists, need_collapse))
2477 n = hists->entries_collapsed.rb_root.rb_node;
2479 n = hists->entries_in->rb_root.rb_node;
2544 void hists__match(struct hists *leader, struct hists *other)
2570 static int hists__link_hierarchy(struct hists *leader_hists,
2585 if (leader->hists == leader_hists) {
2615 * Look for entries in the other hists that are not present in the leader, if
2616 * we find them, just add a dummy entry on the leader hists, with period=0,
2619 int hists__link(struct hists *leader, struct hists *other)
2651 int hists__unlink(struct hists *hists)
2657 if (hists__has(hists, need_collapse))
2658 root = &hists->entries_collapsed;
2660 root = hists->entries_in;
2720 struct hists *hists = evsel__hists(pos);
2722 if (skip_empty && !hists->stats.nr_samples && !hists->stats.nr_lost_samples)
2726 if (hists->stats.nr_samples)
2728 "SAMPLE", hists->stats.nr_samples);
2729 if (hists->stats.nr_lost_samples)
2731 "LOST_SAMPLES", hists->stats.nr_lost_samples);
2738 u64 hists__total_period(struct hists *hists)
2740 return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period :
2741 hists->stats.total_period;
2744 int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool show_freq)
2748 const struct dso *dso = hists->dso_filter;
2749 struct thread *thread = hists->thread_filter;
2750 int socket_id = hists->socket_filter;
2751 unsigned long nr_samples = hists->stats.nr_samples;
2752 u64 nr_events = hists->stats.total_period;
2753 struct evsel *evsel = hists_to_evsel(hists);
2761 nr_samples = hists->stats.nr_non_filtered_samples;
2762 nr_events = hists->stats.total_non_filtered_period;
2772 struct hists *pos_hists = evsel__hists(pos);
2798 if (hists->uid_filter_str)
2800 ", UID: %s", hists->uid_filter_str);
2802 if (hists__has(hists, thread)) {
2846 int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list)
2848 memset(hists, 0, sizeof(*hists));
2849 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT_CACHED;
2850 hists->entries_in = &hists->entries_in_array[0];
2851 hists->entries_collapsed = RB_ROOT_CACHED;
2852 hists->entries = RB_ROOT_CACHED;
2853 mutex_init(&hists->lock);
2854 hists->socket_filter = -1;
2855 hists->hpp_list = hpp_list;
2856 INIT_LIST_HEAD(&hists->hpp_formats);
2874 static void hists__delete_all_entries(struct hists *hists)
2876 hists__delete_entries(hists);
2877 hists__delete_remaining_entries(&hists->entries_in_array[0]);
2878 hists__delete_remaining_entries(&hists->entries_in_array[1]);
2879 hists__delete_remaining_entries(&hists->entries_collapsed);
2884 struct hists *hists = evsel__hists(evsel);
2888 hists__delete_all_entries(hists);
2890 list_for_each_entry_safe(node, tmp, &hists->hpp_formats, list) {
2902 struct hists *hists = evsel__hists(evsel);
2904 __hists__init(hists, &perf_hpp_list);
2918 fputs("FATAL ERROR: Couldn't setup hists class\n", stderr);