perf tools: Complete tracepoint event names
[linux-2.6-block.git] / tools / perf / util / hist.c
CommitLineData
78f7defe 1#include "annotate.h"
8a0ecfb8 2#include "util.h"
598357eb 3#include "build-id.h"
3d1d07ec 4#include "hist.h"
4e4f06e4
ACM
5#include "session.h"
6#include "sort.h"
9b33827d 7#include <math.h>
3d1d07ec 8
90cf1fb5
ACM
9static bool hists__filter_entry_by_dso(struct hists *hists,
10 struct hist_entry *he);
11static bool hists__filter_entry_by_thread(struct hists *hists,
12 struct hist_entry *he);
e94d53eb
NK
13static bool hists__filter_entry_by_symbol(struct hists *hists,
14 struct hist_entry *he);
90cf1fb5 15
7a007ca9
ACM
16enum hist_filter {
17 HIST_FILTER__DSO,
18 HIST_FILTER__THREAD,
19 HIST_FILTER__PARENT,
e94d53eb 20 HIST_FILTER__SYMBOL,
7a007ca9
ACM
21};
22
3d1d07ec
JK
23struct callchain_param callchain_param = {
24 .mode = CHAIN_GRAPH_REL,
d797fdc5
SL
25 .min_percent = 0.5,
26 .order = ORDER_CALLEE
3d1d07ec
JK
27};
28
42b28ac0 29u16 hists__col_len(struct hists *hists, enum hist_column col)
8a6c5b26 30{
42b28ac0 31 return hists->col_len[col];
8a6c5b26
ACM
32}
33
42b28ac0 34void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len)
8a6c5b26 35{
42b28ac0 36 hists->col_len[col] = len;
8a6c5b26
ACM
37}
38
42b28ac0 39bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len)
8a6c5b26 40{
42b28ac0
ACM
41 if (len > hists__col_len(hists, col)) {
42 hists__set_col_len(hists, col, len);
8a6c5b26
ACM
43 return true;
44 }
45 return false;
46}
47
7ccf4f90 48void hists__reset_col_len(struct hists *hists)
8a6c5b26
ACM
49{
50 enum hist_column col;
51
52 for (col = 0; col < HISTC_NR_COLS; ++col)
42b28ac0 53 hists__set_col_len(hists, col, 0);
8a6c5b26
ACM
54}
55
b5387528
RAV
56static void hists__set_unres_dso_col_len(struct hists *hists, int dso)
57{
58 const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
59
60 if (hists__col_len(hists, dso) < unresolved_col_width &&
61 !symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
62 !symbol_conf.dso_list)
63 hists__set_col_len(hists, dso, unresolved_col_width);
64}
65
7ccf4f90 66void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
8a6c5b26 67{
b5387528 68 const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
8a6c5b26
ACM
69 u16 len;
70
71 if (h->ms.sym)
b5387528
RAV
72 hists__new_col_len(hists, HISTC_SYMBOL, h->ms.sym->namelen + 4);
73 else
74 hists__set_unres_dso_col_len(hists, HISTC_DSO);
8a6c5b26
ACM
75
76 len = thread__comm_len(h->thread);
42b28ac0
ACM
77 if (hists__new_col_len(hists, HISTC_COMM, len))
78 hists__set_col_len(hists, HISTC_THREAD, len + 6);
8a6c5b26
ACM
79
80 if (h->ms.map) {
81 len = dso__name_len(h->ms.map->dso);
42b28ac0 82 hists__new_col_len(hists, HISTC_DSO, len);
8a6c5b26 83 }
b5387528
RAV
84
85 if (h->branch_info) {
86 int symlen;
87 /*
88 * +4 accounts for '[x] ' priv level info
89 * +2 account of 0x prefix on raw addresses
90 */
91 if (h->branch_info->from.sym) {
92 symlen = (int)h->branch_info->from.sym->namelen + 4;
93 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
94
95 symlen = dso__name_len(h->branch_info->from.map->dso);
96 hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
97 } else {
98 symlen = unresolved_col_width + 4 + 2;
99 hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
100 hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
101 }
102
103 if (h->branch_info->to.sym) {
104 symlen = (int)h->branch_info->to.sym->namelen + 4;
105 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
106
107 symlen = dso__name_len(h->branch_info->to.map->dso);
108 hists__new_col_len(hists, HISTC_DSO_TO, symlen);
109 } else {
110 symlen = unresolved_col_width + 4 + 2;
111 hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
112 hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
113 }
114 }
8a6c5b26
ACM
115}
116
7ccf4f90
NK
117void hists__output_recalc_col_len(struct hists *hists, int max_rows)
118{
119 struct rb_node *next = rb_first(&hists->entries);
120 struct hist_entry *n;
121 int row = 0;
122
123 hists__reset_col_len(hists);
124
125 while (next && row++ < max_rows) {
126 n = rb_entry(next, struct hist_entry, rb_node);
127 if (!n->filtered)
128 hists__calc_col_len(hists, n);
129 next = rb_next(&n->rb_node);
130 }
131}
132
12c14278 133static void hist_entry__add_cpumode_period(struct hist_entry *he,
c82ee828 134 unsigned int cpumode, u64 period)
a1645ce1 135{
28e2a106 136 switch (cpumode) {
a1645ce1 137 case PERF_RECORD_MISC_KERNEL:
12c14278 138 he->period_sys += period;
a1645ce1
ZY
139 break;
140 case PERF_RECORD_MISC_USER:
12c14278 141 he->period_us += period;
a1645ce1
ZY
142 break;
143 case PERF_RECORD_MISC_GUEST_KERNEL:
12c14278 144 he->period_guest_sys += period;
a1645ce1
ZY
145 break;
146 case PERF_RECORD_MISC_GUEST_USER:
12c14278 147 he->period_guest_us += period;
a1645ce1
ZY
148 break;
149 default:
150 break;
151 }
152}
153
ab81f3fd
ACM
154static void hist_entry__decay(struct hist_entry *he)
155{
156 he->period = (he->period * 7) / 8;
157 he->nr_events = (he->nr_events * 7) / 8;
158}
159
160static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
161{
c64550cf
ACM
162 u64 prev_period = he->period;
163
164 if (prev_period == 0)
df71d95f 165 return true;
c64550cf 166
ab81f3fd 167 hist_entry__decay(he);
c64550cf
ACM
168
169 if (!he->filtered)
170 hists->stats.total_period -= prev_period - he->period;
171
ab81f3fd
ACM
172 return he->period == 0;
173}
174
b079d4e9
ACM
175static void __hists__decay_entries(struct hists *hists, bool zap_user,
176 bool zap_kernel, bool threaded)
ab81f3fd
ACM
177{
178 struct rb_node *next = rb_first(&hists->entries);
179 struct hist_entry *n;
180
181 while (next) {
182 n = rb_entry(next, struct hist_entry, rb_node);
183 next = rb_next(&n->rb_node);
df71d95f
ACM
184 /*
185 * We may be annotating this, for instance, so keep it here in
186 * case some it gets new samples, we'll eventually free it when
187 * the user stops browsing and it agains gets fully decayed.
188 */
b079d4e9
ACM
189 if (((zap_user && n->level == '.') ||
190 (zap_kernel && n->level != '.') ||
191 hists__decay_entry(hists, n)) &&
192 !n->used) {
ab81f3fd
ACM
193 rb_erase(&n->rb_node, &hists->entries);
194
e345fa18 195 if (sort__need_collapse || threaded)
ab81f3fd
ACM
196 rb_erase(&n->rb_node_in, &hists->entries_collapsed);
197
198 hist_entry__free(n);
199 --hists->nr_entries;
200 }
201 }
202}
203
b079d4e9 204void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
e345fa18 205{
b079d4e9 206 return __hists__decay_entries(hists, zap_user, zap_kernel, false);
e345fa18
ACM
207}
208
b079d4e9
ACM
209void hists__decay_entries_threaded(struct hists *hists,
210 bool zap_user, bool zap_kernel)
e345fa18 211{
b079d4e9 212 return __hists__decay_entries(hists, zap_user, zap_kernel, true);
e345fa18
ACM
213}
214
3d1d07ec 215/*
c82ee828 216 * histogram, sorted on item, collects periods
3d1d07ec
JK
217 */
218
28e2a106
ACM
219static struct hist_entry *hist_entry__new(struct hist_entry *template)
220{
d2009c51 221 size_t callchain_size = symbol_conf.use_callchain ? sizeof(struct callchain_root) : 0;
12c14278 222 struct hist_entry *he = malloc(sizeof(*he) + callchain_size);
28e2a106 223
12c14278
ACM
224 if (he != NULL) {
225 *he = *template;
226 he->nr_events = 1;
227 if (he->ms.map)
228 he->ms.map->referenced = true;
28e2a106 229 if (symbol_conf.use_callchain)
12c14278 230 callchain_init(he->callchain);
28e2a106
ACM
231 }
232
12c14278 233 return he;
28e2a106
ACM
234}
235
42b28ac0 236static void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h)
fefb0b94 237{
8a6c5b26 238 if (!h->filtered) {
42b28ac0
ACM
239 hists__calc_col_len(hists, h);
240 ++hists->nr_entries;
1980c2eb 241 hists->stats.total_period += h->period;
8a6c5b26 242 }
fefb0b94
ACM
243}
244
7a007ca9
ACM
245static u8 symbol__parent_filter(const struct symbol *parent)
246{
247 if (symbol_conf.exclude_other && parent == NULL)
248 return 1 << HIST_FILTER__PARENT;
249 return 0;
250}
251
b5387528
RAV
252static struct hist_entry *add_hist_entry(struct hists *hists,
253 struct hist_entry *entry,
1c02c4d2 254 struct addr_location *al,
b5387528 255 u64 period)
9735abf1 256{
1980c2eb 257 struct rb_node **p;
9735abf1
ACM
258 struct rb_node *parent = NULL;
259 struct hist_entry *he;
9735abf1
ACM
260 int cmp;
261
1980c2eb
ACM
262 pthread_mutex_lock(&hists->lock);
263
264 p = &hists->entries_in->rb_node;
265
9735abf1
ACM
266 while (*p != NULL) {
267 parent = *p;
1980c2eb 268 he = rb_entry(parent, struct hist_entry, rb_node_in);
9735abf1 269
b5387528 270 cmp = hist_entry__cmp(entry, he);
9735abf1
ACM
271
272 if (!cmp) {
c82ee828
ACM
273 he->period += period;
274 ++he->nr_events;
63fa471d
DM
275
276 /* If the map of an existing hist_entry has
277 * become out-of-date due to an exec() or
278 * similar, update it. Otherwise we will
279 * mis-adjust symbol addresses when computing
280 * the history counter to increment.
281 */
282 if (he->ms.map != entry->ms.map) {
283 he->ms.map = entry->ms.map;
284 if (he->ms.map)
285 he->ms.map->referenced = true;
286 }
28e2a106 287 goto out;
9735abf1
ACM
288 }
289
290 if (cmp < 0)
291 p = &(*p)->rb_left;
292 else
293 p = &(*p)->rb_right;
294 }
295
b5387528 296 he = hist_entry__new(entry);
9735abf1 297 if (!he)
1980c2eb
ACM
298 goto out_unlock;
299
300 rb_link_node(&he->rb_node_in, parent, p);
301 rb_insert_color(&he->rb_node_in, hists->entries_in);
28e2a106 302out:
c82ee828 303 hist_entry__add_cpumode_period(he, al->cpumode, period);
1980c2eb
ACM
304out_unlock:
305 pthread_mutex_unlock(&hists->lock);
9735abf1
ACM
306 return he;
307}
308
b5387528
RAV
309struct hist_entry *__hists__add_branch_entry(struct hists *self,
310 struct addr_location *al,
311 struct symbol *sym_parent,
312 struct branch_info *bi,
313 u64 period)
314{
315 struct hist_entry entry = {
316 .thread = al->thread,
317 .ms = {
318 .map = bi->to.map,
319 .sym = bi->to.sym,
320 },
321 .cpu = al->cpu,
322 .ip = bi->to.addr,
323 .level = al->level,
324 .period = period,
325 .parent = sym_parent,
326 .filtered = symbol__parent_filter(sym_parent),
327 .branch_info = bi,
328 };
329
330 return add_hist_entry(self, &entry, al, period);
331}
332
333struct hist_entry *__hists__add_entry(struct hists *self,
334 struct addr_location *al,
335 struct symbol *sym_parent, u64 period)
336{
337 struct hist_entry entry = {
338 .thread = al->thread,
339 .ms = {
340 .map = al->map,
341 .sym = al->sym,
342 },
343 .cpu = al->cpu,
344 .ip = al->addr,
345 .level = al->level,
346 .period = period,
347 .parent = sym_parent,
348 .filtered = symbol__parent_filter(sym_parent),
349 };
350
351 return add_hist_entry(self, &entry, al, period);
352}
353
3d1d07ec
JK
354int64_t
355hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
356{
357 struct sort_entry *se;
358 int64_t cmp = 0;
359
360 list_for_each_entry(se, &hist_entry__sort_list, list) {
fcd14984 361 cmp = se->se_cmp(left, right);
3d1d07ec
JK
362 if (cmp)
363 break;
364 }
365
366 return cmp;
367}
368
369int64_t
370hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
371{
372 struct sort_entry *se;
373 int64_t cmp = 0;
374
375 list_for_each_entry(se, &hist_entry__sort_list, list) {
376 int64_t (*f)(struct hist_entry *, struct hist_entry *);
377
fcd14984 378 f = se->se_collapse ?: se->se_cmp;
3d1d07ec
JK
379
380 cmp = f(left, right);
381 if (cmp)
382 break;
383 }
384
385 return cmp;
386}
387
388void hist_entry__free(struct hist_entry *he)
389{
390 free(he);
391}
392
393/*
394 * collapse the histogram
395 */
396
1d037ca1 397static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
1b3a0e95
FW
398 struct rb_root *root,
399 struct hist_entry *he)
3d1d07ec 400{
b9bf0892 401 struct rb_node **p = &root->rb_node;
3d1d07ec
JK
402 struct rb_node *parent = NULL;
403 struct hist_entry *iter;
404 int64_t cmp;
405
406 while (*p != NULL) {
407 parent = *p;
1980c2eb 408 iter = rb_entry(parent, struct hist_entry, rb_node_in);
3d1d07ec
JK
409
410 cmp = hist_entry__collapse(iter, he);
411
412 if (!cmp) {
9ec60972
NK
413 iter->period += he->period;
414 iter->period_sys += he->period_sys;
415 iter->period_us += he->period_us;
416 iter->period_guest_sys += he->period_guest_sys;
417 iter->period_guest_us += he->period_guest_us;
418 iter->nr_events += he->nr_events;
419
1b3a0e95 420 if (symbol_conf.use_callchain) {
47260645
NK
421 callchain_cursor_reset(&callchain_cursor);
422 callchain_merge(&callchain_cursor,
423 iter->callchain,
1b3a0e95
FW
424 he->callchain);
425 }
3d1d07ec 426 hist_entry__free(he);
fefb0b94 427 return false;
3d1d07ec
JK
428 }
429
430 if (cmp < 0)
431 p = &(*p)->rb_left;
432 else
433 p = &(*p)->rb_right;
434 }
435
1980c2eb
ACM
436 rb_link_node(&he->rb_node_in, parent, p);
437 rb_insert_color(&he->rb_node_in, root);
fefb0b94 438 return true;
3d1d07ec
JK
439}
440
1980c2eb 441static struct rb_root *hists__get_rotate_entries_in(struct hists *hists)
3d1d07ec 442{
1980c2eb
ACM
443 struct rb_root *root;
444
445 pthread_mutex_lock(&hists->lock);
446
447 root = hists->entries_in;
448 if (++hists->entries_in > &hists->entries_in_array[1])
449 hists->entries_in = &hists->entries_in_array[0];
450
451 pthread_mutex_unlock(&hists->lock);
452
453 return root;
454}
455
90cf1fb5
ACM
456static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
457{
458 hists__filter_entry_by_dso(hists, he);
459 hists__filter_entry_by_thread(hists, he);
e94d53eb 460 hists__filter_entry_by_symbol(hists, he);
90cf1fb5
ACM
461}
462
1980c2eb
ACM
463static void __hists__collapse_resort(struct hists *hists, bool threaded)
464{
465 struct rb_root *root;
3d1d07ec
JK
466 struct rb_node *next;
467 struct hist_entry *n;
468
1980c2eb 469 if (!sort__need_collapse && !threaded)
3d1d07ec
JK
470 return;
471
1980c2eb
ACM
472 root = hists__get_rotate_entries_in(hists);
473 next = rb_first(root);
b9bf0892 474
3d1d07ec 475 while (next) {
1980c2eb
ACM
476 n = rb_entry(next, struct hist_entry, rb_node_in);
477 next = rb_next(&n->rb_node_in);
3d1d07ec 478
1980c2eb 479 rb_erase(&n->rb_node_in, root);
90cf1fb5
ACM
480 if (hists__collapse_insert_entry(hists, &hists->entries_collapsed, n)) {
481 /*
482 * If it wasn't combined with one of the entries already
483 * collapsed, we need to apply the filters that may have
484 * been set by, say, the hist_browser.
485 */
486 hists__apply_filters(hists, n);
90cf1fb5 487 }
3d1d07ec 488 }
1980c2eb 489}
b9bf0892 490
1980c2eb
ACM
491void hists__collapse_resort(struct hists *hists)
492{
493 return __hists__collapse_resort(hists, false);
494}
495
496void hists__collapse_resort_threaded(struct hists *hists)
497{
498 return __hists__collapse_resort(hists, true);
3d1d07ec
JK
499}
500
501/*
c82ee828 502 * reverse the map, sort on period.
3d1d07ec
JK
503 */
504
1c02c4d2
ACM
505static void __hists__insert_output_entry(struct rb_root *entries,
506 struct hist_entry *he,
507 u64 min_callchain_hits)
3d1d07ec 508{
1c02c4d2 509 struct rb_node **p = &entries->rb_node;
3d1d07ec
JK
510 struct rb_node *parent = NULL;
511 struct hist_entry *iter;
512
d599db3f 513 if (symbol_conf.use_callchain)
b9fb9304 514 callchain_param.sort(&he->sorted_chain, he->callchain,
3d1d07ec
JK
515 min_callchain_hits, &callchain_param);
516
517 while (*p != NULL) {
518 parent = *p;
519 iter = rb_entry(parent, struct hist_entry, rb_node);
520
c82ee828 521 if (he->period > iter->period)
3d1d07ec
JK
522 p = &(*p)->rb_left;
523 else
524 p = &(*p)->rb_right;
525 }
526
527 rb_link_node(&he->rb_node, parent, p);
1c02c4d2 528 rb_insert_color(&he->rb_node, entries);
3d1d07ec
JK
529}
530
1980c2eb 531static void __hists__output_resort(struct hists *hists, bool threaded)
3d1d07ec 532{
1980c2eb 533 struct rb_root *root;
3d1d07ec
JK
534 struct rb_node *next;
535 struct hist_entry *n;
3d1d07ec
JK
536 u64 min_callchain_hits;
537
42b28ac0 538 min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
3d1d07ec 539
1980c2eb
ACM
540 if (sort__need_collapse || threaded)
541 root = &hists->entries_collapsed;
542 else
543 root = hists->entries_in;
544
545 next = rb_first(root);
546 hists->entries = RB_ROOT;
3d1d07ec 547
42b28ac0 548 hists->nr_entries = 0;
7928631a 549 hists->stats.total_period = 0;
42b28ac0 550 hists__reset_col_len(hists);
fefb0b94 551
3d1d07ec 552 while (next) {
1980c2eb
ACM
553 n = rb_entry(next, struct hist_entry, rb_node_in);
554 next = rb_next(&n->rb_node_in);
3d1d07ec 555
1980c2eb 556 __hists__insert_output_entry(&hists->entries, n, min_callchain_hits);
42b28ac0 557 hists__inc_nr_entries(hists, n);
3d1d07ec 558 }
1980c2eb 559}
b9bf0892 560
1980c2eb
ACM
561void hists__output_resort(struct hists *hists)
562{
563 return __hists__output_resort(hists, false);
564}
565
566void hists__output_resort_threaded(struct hists *hists)
567{
568 return __hists__output_resort(hists, true);
3d1d07ec 569}
4ecf84d0 570
42b28ac0 571static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
cc5edb0e
ACM
572 enum hist_filter filter)
573{
574 h->filtered &= ~(1 << filter);
575 if (h->filtered)
576 return;
577
42b28ac0 578 ++hists->nr_entries;
0f0cbf7a 579 if (h->ms.unfolded)
42b28ac0 580 hists->nr_entries += h->nr_rows;
0f0cbf7a 581 h->row_offset = 0;
42b28ac0
ACM
582 hists->stats.total_period += h->period;
583 hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
cc5edb0e 584
42b28ac0 585 hists__calc_col_len(hists, h);
cc5edb0e
ACM
586}
587
90cf1fb5
ACM
588
589static bool hists__filter_entry_by_dso(struct hists *hists,
590 struct hist_entry *he)
591{
592 if (hists->dso_filter != NULL &&
593 (he->ms.map == NULL || he->ms.map->dso != hists->dso_filter)) {
594 he->filtered |= (1 << HIST_FILTER__DSO);
595 return true;
596 }
597
598 return false;
599}
600
d7b76f09 601void hists__filter_by_dso(struct hists *hists)
b09e0190
ACM
602{
603 struct rb_node *nd;
604
42b28ac0
ACM
605 hists->nr_entries = hists->stats.total_period = 0;
606 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
607 hists__reset_col_len(hists);
b09e0190 608
42b28ac0 609 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
b09e0190
ACM
610 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
611
612 if (symbol_conf.exclude_other && !h->parent)
613 continue;
614
90cf1fb5 615 if (hists__filter_entry_by_dso(hists, h))
b09e0190 616 continue;
b09e0190 617
42b28ac0 618 hists__remove_entry_filter(hists, h, HIST_FILTER__DSO);
b09e0190
ACM
619 }
620}
621
90cf1fb5
ACM
622static bool hists__filter_entry_by_thread(struct hists *hists,
623 struct hist_entry *he)
624{
625 if (hists->thread_filter != NULL &&
626 he->thread != hists->thread_filter) {
627 he->filtered |= (1 << HIST_FILTER__THREAD);
628 return true;
629 }
630
631 return false;
632}
633
d7b76f09 634void hists__filter_by_thread(struct hists *hists)
b09e0190
ACM
635{
636 struct rb_node *nd;
637
42b28ac0
ACM
638 hists->nr_entries = hists->stats.total_period = 0;
639 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
640 hists__reset_col_len(hists);
b09e0190 641
42b28ac0 642 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
b09e0190
ACM
643 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
644
90cf1fb5 645 if (hists__filter_entry_by_thread(hists, h))
b09e0190 646 continue;
cc5edb0e 647
42b28ac0 648 hists__remove_entry_filter(hists, h, HIST_FILTER__THREAD);
b09e0190
ACM
649 }
650}
ef7b93a1 651
e94d53eb
NK
652static bool hists__filter_entry_by_symbol(struct hists *hists,
653 struct hist_entry *he)
654{
655 if (hists->symbol_filter_str != NULL &&
656 (!he->ms.sym || strstr(he->ms.sym->name,
657 hists->symbol_filter_str) == NULL)) {
658 he->filtered |= (1 << HIST_FILTER__SYMBOL);
659 return true;
660 }
661
662 return false;
663}
664
665void hists__filter_by_symbol(struct hists *hists)
666{
667 struct rb_node *nd;
668
669 hists->nr_entries = hists->stats.total_period = 0;
670 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
671 hists__reset_col_len(hists);
672
673 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
674 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
675
676 if (hists__filter_entry_by_symbol(hists, h))
677 continue;
678
679 hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
680 }
681}
682
2f525d01 683int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
ef7b93a1 684{
2f525d01 685 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
ef7b93a1
ACM
686}
687
ce6f4fab 688int hist_entry__annotate(struct hist_entry *he, size_t privsize)
ef7b93a1 689{
ce6f4fab 690 return symbol__annotate(he->ms.sym, he->ms.map, privsize);
ef7b93a1 691}
c8446b9b 692
42b28ac0 693void hists__inc_nr_events(struct hists *hists, u32 type)
c8446b9b 694{
42b28ac0
ACM
695 ++hists->stats.nr_events[0];
696 ++hists->stats.nr_events[type];
c8446b9b 697}