Lines Matching refs:hists

33 static bool hists__filter_entry_by_dso(struct hists *hists,
35 static bool hists__filter_entry_by_thread(struct hists *hists,
37 static bool hists__filter_entry_by_symbol(struct hists *hists,
39 static bool hists__filter_entry_by_socket(struct hists *hists,
42 u16 hists__col_len(struct hists *hists, enum hist_column col)
44 return hists->col_len[col];
47 void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len)
49 hists->col_len[col] = len;
52 bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len)
54 if (len > hists__col_len(hists, col)) {
55 hists__set_col_len(hists, col, len);
61 void hists__reset_col_len(struct hists *hists)
66 hists__set_col_len(hists, col, 0);
69 static void hists__set_unres_dso_col_len(struct hists *hists, int dso)
73 if (hists__col_len(hists, dso) < unresolved_col_width &&
76 hists__set_col_len(hists, dso, unresolved_col_width);
79 void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
96 hists__new_col_len(hists, HISTC_SYMBOL, symlen);
99 hists__new_col_len(hists, HISTC_SYMBOL, symlen);
100 hists__set_unres_dso_col_len(hists, HISTC_DSO);
104 if (hists__new_col_len(hists, HISTC_COMM, len))
105 hists__set_col_len(hists, HISTC_THREAD, len + 8);
109 hists__new_col_len(hists, HISTC_DSO, len);
113 hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen);
120 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
123 hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
126 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
127 hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
134 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
137 hists__new_col_len(hists, HISTC_DSO_TO, symlen);
140 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
141 hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
145 hists__new_col_len(hists, HISTC_SRCLINE_FROM,
148 hists__new_col_len(hists, HISTC_SRCLINE_TO,
156 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
158 hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
162 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
164 hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
171 hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
175 hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
181 hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
185 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
188 hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR,
193 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
194 hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL, symlen);
195 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
198 hists__new_col_len(hists, HISTC_CGROUP, 6);
199 hists__new_col_len(hists, HISTC_CGROUP_ID, 20);
200 hists__new_col_len(hists, HISTC_CPU, 3);
201 hists__new_col_len(hists, HISTC_SOCKET, 6);
202 hists__new_col_len(hists, HISTC_MEM_LOCKED, 6);
203 hists__new_col_len(hists, HISTC_MEM_TLB, 22);
204 hists__new_col_len(hists, HISTC_MEM_SNOOP, 12);
205 hists__new_col_len(hists, HISTC_MEM_LVL, 21 + 3);
206 hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
207 hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
209 hists__new_col_len(hists, HISTC_TIME, 16);
211 hists__new_col_len(hists, HISTC_TIME, 12);
215 hists__new_col_len(hists, HISTC_SRCLINE, len);
219 hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile));
222 hists__new_col_len(hists, HISTC_TRANSACTION,
226 hists__new_col_len(hists, HISTC_TRACE, strlen(h->trace_output));
235 hists__new_col_len(hists, HISTC_CGROUP, strlen(cgrp_name));
239 void hists__output_recalc_col_len(struct hists *hists, int max_rows)
241 struct rb_node *next = rb_first_cached(&hists->entries);
245 hists__reset_col_len(hists);
250 hists__calc_col_len(hists, n);
311 static void hists__delete_entry(struct hists *hists, struct hist_entry *he);
313 static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
329 hists->stats.total_period -= diff;
331 hists->stats.total_non_filtered_period -= diff;
341 if (hists__decay_entry(hists, child))
342 hists__delete_entry(hists, child);
349 static void hists__delete_entry(struct hists *hists, struct hist_entry *he)
358 if (hists__has(hists, need_collapse))
359 root_in = &hists->entries_collapsed;
361 root_in = hists->entries_in;
362 root_out = &hists->entries;
368 --hists->nr_entries;
370 --hists->nr_non_filtered_entries;
375 void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
377 struct rb_node *next = rb_first_cached(&hists->entries);
385 hists__decay_entry(hists, n))) {
386 hists__delete_entry(hists, n);
391 void hists__delete_entries(struct hists *hists)
393 struct rb_node *next = rb_first_cached(&hists->entries);
400 hists__delete_entry(hists, n);
404 struct hist_entry *hists__get_entry(struct hists *hists, int idx)
406 struct rb_node *next = rb_first_cached(&hists->entries);
574 he->hists->callchain_period += period;
576 he->hists->callchain_non_filtered_period += period;
579 static struct hist_entry *hists__findnew_entry(struct hists *hists,
592 p = &hists->entries_in->rb_root.rb_node;
649 hists->nr_entries++;
652 rb_insert_color_cached(&he->rb_node_in, hists->entries_in, leftmost);
688 __hists__add_entry(struct hists *hists,
725 .hists = hists,
734 }, *he = hists__findnew_entry(hists, &entry, al, sample_self);
736 if (!hists->has_callchains && he && he->callchain_size != 0)
737 hists->has_callchains = true;
743 struct hist_entry *hists__add_entry(struct hists *hists,
751 return __hists__add_entry(hists, al, sym_parent, bi, mi, NULL,
755 struct hist_entry *hists__add_entry_ops(struct hists *hists,
764 return __hists__add_entry(hists, al, sym_parent, bi, mi, NULL,
768 struct hist_entry *hists__add_entry_block(struct hists *hists,
774 .hists = hists,
780 }, *he = hists__findnew_entry(hists, &entry, al, false);
818 struct hists *hists = evsel__hists(iter->evsel);
838 he = hists__add_entry(hists, al, iter->parent, NULL, mi,
852 struct hists *hists = evsel__hists(evsel);
859 hists__inc_nr_samples(hists, he->filtered);
923 struct hists *hists = evsel__hists(evsel);
941 he = hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
946 hists__inc_nr_samples(hists, he->filtered);
1033 struct hists *hists = evsel__hists(evsel);
1039 he = hists__add_entry(hists, al, iter->parent, NULL, NULL,
1055 hists__inc_nr_samples(hists, he->filtered);
1096 .hists = evsel__hists(evsel),
1113 bool fast = hists__has(he_tmp.hists, sym);
1249 struct hists *hists = left->hists;
1253 hists__for_each_sort_list(hists, fmt) {
1255 !perf_hpp__defined_dynamic_entry(fmt, hists))
1269 struct hists *hists = left->hists;
1273 hists__for_each_sort_list(hists, fmt) {
1275 !perf_hpp__defined_dynamic_entry(fmt, hists))
1331 if (!list_is_last(&fmt->list, &he->hists->hpp_list->fields)) {
1332 const int width = fmt->width(fmt, hpp, he->hists);
1346 static void hists__apply_filters(struct hists *hists, struct hist_entry *he);
1347 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *he,
1438 hists__apply_filters(he->hists, he);
1441 static struct hist_entry *hierarchy_insert_entry(struct hists *hists,
1482 hists->nr_entries++;
1513 static int hists__hierarchy_insert_entry(struct hists *hists,
1523 list_for_each_entry(node, &hists->hpp_formats, list) {
1529 new_he = hierarchy_insert_entry(hists, root, he, parent, &node->hpp);
1560 static int hists__collapse_insert_entry(struct hists *hists,
1571 return hists__hierarchy_insert_entry(hists, root, he);
1604 hists->nr_entries++;
1611 struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists)
1615 pthread_mutex_lock(&hists->lock);
1617 root = hists->entries_in;
1618 if (++hists->entries_in > &hists->entries_in_array[1])
1619 hists->entries_in = &hists->entries_in_array[0];
1621 pthread_mutex_unlock(&hists->lock);
1626 static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
1628 hists__filter_entry_by_dso(hists, he);
1629 hists__filter_entry_by_thread(hists, he);
1630 hists__filter_entry_by_symbol(hists, he);
1631 hists__filter_entry_by_socket(hists, he);
1634 int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
1641 if (!hists__has(hists, need_collapse))
1644 hists->nr_entries = 0;
1646 root = hists__get_rotate_entries_in(hists);
1657 ret = hists__collapse_insert_entry(hists, &hists->entries_collapsed, n);
1667 hists__apply_filters(hists, n);
1677 struct hists *hists = a->hists;
1681 hists__for_each_sort_list(hists, fmt) {
1682 if (perf_hpp__should_skip(fmt, a->hists))
1693 static void hists__reset_filter_stats(struct hists *hists)
1695 hists->nr_non_filtered_entries = 0;
1696 hists->stats.total_non_filtered_period = 0;
1699 void hists__reset_stats(struct hists *hists)
1701 hists->nr_entries = 0;
1702 hists->stats.total_period = 0;
1704 hists__reset_filter_stats(hists);
1707 static void hists__inc_filter_stats(struct hists *hists, struct hist_entry *h)
1709 hists->nr_non_filtered_entries++;
1710 hists->stats.total_non_filtered_period += h->stat.period;
1713 void hists__inc_stats(struct hists *hists, struct hist_entry *h)
1716 hists__inc_filter_stats(hists, h);
1718 hists->nr_entries++;
1719 hists->stats.total_period += h->stat.period;
1722 static void hierarchy_recalc_total_periods(struct hists *hists)
1727 node = rb_first_cached(&hists->entries);
1729 hists->stats.total_period = 0;
1730 hists->stats.total_non_filtered_period = 0;
1741 hists->stats.total_period += he->stat.period;
1743 hists->stats.total_non_filtered_period += he->stat.period;
1778 static void hists__hierarchy_output_resort(struct hists *hists,
1800 hists->nr_entries++;
1802 hists->nr_non_filtered_entries++;
1803 hists__calc_col_len(hists, he);
1807 hists__hierarchy_output_resort(hists, prog,
1873 perf_hpp__defined_dynamic_entry(fmt, he->hists))
1878 static void output_resort(struct hists *hists, struct ui_progress *prog,
1888 callchain_total = hists->callchain_period;
1890 callchain_total = hists->callchain_non_filtered_period;
1894 hists__reset_stats(hists);
1895 hists__reset_col_len(hists);
1898 hists__hierarchy_output_resort(hists, prog,
1899 &hists->entries_collapsed,
1900 &hists->entries,
1903 hierarchy_recalc_total_periods(hists);
1907 if (hists__has(hists, need_collapse))
1908 root = &hists->entries_collapsed;
1910 root = hists->entries_in;
1913 hists->entries = RB_ROOT_CACHED;
1922 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain);
1923 hists__inc_stats(hists, n);
1926 hists__calc_col_len(hists, n);
1953 void hists__output_resort(struct hists *hists, struct ui_progress *prog)
1955 output_resort(hists, prog, symbol_conf.use_callchain, NULL, NULL);
1958 void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
1961 output_resort(hists, prog, symbol_conf.use_callchain, cb, NULL);
2045 static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
2080 hists->stats.nr_non_filtered_samples += h->stat.nr_events;
2082 hists__inc_filter_stats(hists, h);
2083 hists__calc_col_len(hists, h);
2087 static bool hists__filter_entry_by_dso(struct hists *hists,
2090 if (hists->dso_filter != NULL &&
2091 (he->ms.map == NULL || he->ms.map->dso != hists->dso_filter)) {
2099 static bool hists__filter_entry_by_thread(struct hists *hists,
2102 if (hists->thread_filter != NULL &&
2103 he->thread != hists->thread_filter) {
2111 static bool hists__filter_entry_by_symbol(struct hists *hists,
2114 if (hists->symbol_filter_str != NULL &&
2116 hists->symbol_filter_str) == NULL)) {
2124 static bool hists__filter_entry_by_socket(struct hists *hists,
2127 if ((hists->socket_filter > -1) &&
2128 (he->socket != hists->socket_filter)) {
2136 typedef bool (*filter_fn_t)(struct hists *hists, struct hist_entry *he);
2138 static void hists__filter_by_type(struct hists *hists, int type, filter_fn_t filter)
2142 hists->stats.nr_non_filtered_samples = 0;
2144 hists__reset_filter_stats(hists);
2145 hists__reset_col_len(hists);
2147 for (nd = rb_first_cached(&hists->entries); nd; nd = rb_next(nd)) {
2150 if (filter(hists, h))
2153 hists__remove_entry_filter(hists, h, type);
2198 static void hists__filter_hierarchy(struct hists *hists, int type, const void *arg)
2203 hists->stats.nr_non_filtered_samples = 0;
2205 hists__reset_filter_stats(hists);
2206 hists__reset_col_len(hists);
2208 nd = rb_first_cached(&hists->entries);
2236 * add period to hists and parents, erase the filter marker
2240 hists__remove_entry_filter(hists, h, type);
2246 hierarchy_recalc_total_periods(hists);
2252 nd = rb_first_cached(&hists->entries);
2257 rb_erase_cached(&h->rb_node, &hists->entries);
2262 hists->entries = new_root;
2265 void hists__filter_by_thread(struct hists *hists)
2268 hists__filter_hierarchy(hists, HIST_FILTER__THREAD,
2269 hists->thread_filter);
2271 hists__filter_by_type(hists, HIST_FILTER__THREAD,
2275 void hists__filter_by_dso(struct hists *hists)
2278 hists__filter_hierarchy(hists, HIST_FILTER__DSO,
2279 hists->dso_filter);
2281 hists__filter_by_type(hists, HIST_FILTER__DSO,
2285 void hists__filter_by_symbol(struct hists *hists)
2288 hists__filter_hierarchy(hists, HIST_FILTER__SYMBOL,
2289 hists->symbol_filter_str);
2291 hists__filter_by_type(hists, HIST_FILTER__SYMBOL,
2295 void hists__filter_by_socket(struct hists *hists)
2298 hists__filter_hierarchy(hists, HIST_FILTER__SOCKET,
2299 &hists->socket_filter);
2301 hists__filter_by_type(hists, HIST_FILTER__SOCKET,
2311 void hists__inc_nr_events(struct hists *hists, u32 type)
2313 events_stats__inc(&hists->stats, type);
2316 void hists__inc_nr_samples(struct hists *hists, bool filtered)
2318 events_stats__inc(&hists->stats, PERF_RECORD_SAMPLE);
2320 hists->stats.nr_non_filtered_samples++;
2323 static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
2333 if (hists__has(hists, need_collapse))
2334 root = &hists->entries_collapsed;
2336 root = hists->entries_in;
2360 he->hists = hists;
2365 hists__inc_stats(hists, he);
2372 static struct hist_entry *add_dummy_hierarchy_entry(struct hists *hists,
2411 he->hists = hists;
2413 hists__inc_stats(hists, he);
2419 static struct hist_entry *hists__find_entry(struct hists *hists,
2424 if (hists__has(hists, need_collapse))
2425 n = hists->entries_collapsed.rb_root.rb_node;
2427 n = hists->entries_in->rb_root.rb_node;
2492 void hists__match(struct hists *leader, struct hists *other)
2518 static int hists__link_hierarchy(struct hists *leader_hists,
2533 if (leader->hists == leader_hists) {
2563 * Look for entries in the other hists that are not present in the leader, if
2564 * we find them, just add a dummy entry on the leader hists, with period=0,
2567 int hists__link(struct hists *leader, struct hists *other)
2599 int hists__unlink(struct hists *hists)
2605 if (hists__has(hists, need_collapse))
2606 root = &hists->entries_collapsed;
2608 root = hists->entries_in;
2675 u64 hists__total_period(struct hists *hists)
2677 return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period :
2678 hists->stats.total_period;
2681 int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool show_freq)
2685 const struct dso *dso = hists->dso_filter;
2686 struct thread *thread = hists->thread_filter;
2687 int socket_id = hists->socket_filter;
2688 unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
2689 u64 nr_events = hists->stats.total_period;
2690 struct evsel *evsel = hists_to_evsel(hists);
2698 nr_samples = hists->stats.nr_non_filtered_samples;
2699 nr_events = hists->stats.total_non_filtered_period;
2709 struct hists *pos_hists = evsel__hists(pos);
2735 if (hists->uid_filter_str)
2737 ", UID: %s", hists->uid_filter_str);
2739 if (hists__has(hists, thread)) {
2783 int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list)
2785 memset(hists, 0, sizeof(*hists));
2786 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT_CACHED;
2787 hists->entries_in = &hists->entries_in_array[0];
2788 hists->entries_collapsed = RB_ROOT_CACHED;
2789 hists->entries = RB_ROOT_CACHED;
2790 pthread_mutex_init(&hists->lock, NULL);
2791 hists->socket_filter = -1;
2792 hists->hpp_list = hpp_list;
2793 INIT_LIST_HEAD(&hists->hpp_formats);
2811 static void hists__delete_all_entries(struct hists *hists)
2813 hists__delete_entries(hists);
2814 hists__delete_remaining_entries(&hists->entries_in_array[0]);
2815 hists__delete_remaining_entries(&hists->entries_in_array[1]);
2816 hists__delete_remaining_entries(&hists->entries_collapsed);
2821 struct hists *hists = evsel__hists(evsel);
2825 hists__delete_all_entries(hists);
2827 list_for_each_entry_safe(node, tmp, &hists->hpp_formats, list) {
2839 struct hists *hists = evsel__hists(evsel);
2841 __hists__init(hists, &perf_hpp_list);
2855 fputs("FATAL ERROR: Couldn't setup hists class\n", stderr);