15 struct callchain_param callchain_param
= {
16 .mode
= CHAIN_GRAPH_REL
,
21 u16
hists__col_len(struct hists
*self
, enum hist_column col
)
23 return self
->col_len
[col
];
26 void hists__set_col_len(struct hists
*self
, enum hist_column col
, u16 len
)
28 self
->col_len
[col
] = len
;
31 bool hists__new_col_len(struct hists
*self
, enum hist_column col
, u16 len
)
33 if (len
> hists__col_len(self
, col
)) {
34 hists__set_col_len(self
, col
, len
);
40 static void hists__reset_col_len(struct hists
*self
)
44 for (col
= 0; col
< HISTC_NR_COLS
; ++col
)
45 hists__set_col_len(self
, col
, 0);
48 static void hists__calc_col_len(struct hists
*self
, struct hist_entry
*h
)
53 hists__new_col_len(self
, HISTC_SYMBOL
, h
->ms
.sym
->namelen
);
55 const unsigned int unresolved_col_width
= BITS_PER_LONG
/ 4;
57 if (hists__col_len(self
, HISTC_DSO
) < unresolved_col_width
&&
58 !symbol_conf
.col_width_list_str
&& !symbol_conf
.field_sep
&&
59 !symbol_conf
.dso_list
)
60 hists__set_col_len(self
, HISTC_DSO
,
61 unresolved_col_width
);
64 len
= thread__comm_len(h
->thread
);
65 if (hists__new_col_len(self
, HISTC_COMM
, len
))
66 hists__set_col_len(self
, HISTC_THREAD
, len
+ 6);
69 len
= dso__name_len(h
->ms
.map
->dso
);
70 hists__new_col_len(self
, HISTC_DSO
, len
);
74 static void hist_entry__add_cpumode_period(struct hist_entry
*self
,
75 unsigned int cpumode
, u64 period
)
78 case PERF_RECORD_MISC_KERNEL
:
79 self
->period_sys
+= period
;
81 case PERF_RECORD_MISC_USER
:
82 self
->period_us
+= period
;
84 case PERF_RECORD_MISC_GUEST_KERNEL
:
85 self
->period_guest_sys
+= period
;
87 case PERF_RECORD_MISC_GUEST_USER
:
88 self
->period_guest_us
+= period
;
96 * histogram, sorted on item, collects periods
99 static struct hist_entry
*hist_entry__new(struct hist_entry
*template)
101 size_t callchain_size
= symbol_conf
.use_callchain
? sizeof(struct callchain_root
) : 0;
102 struct hist_entry
*self
= malloc(sizeof(*self
) + callchain_size
);
108 self
->ms
.map
->referenced
= true;
109 if (symbol_conf
.use_callchain
)
110 callchain_init(self
->callchain
);
116 static void hists__inc_nr_entries(struct hists
*self
, struct hist_entry
*h
)
119 hists__calc_col_len(self
, h
);
124 static u8
symbol__parent_filter(const struct symbol
*parent
)
126 if (symbol_conf
.exclude_other
&& parent
== NULL
)
127 return 1 << HIST_FILTER__PARENT
;
131 struct hist_entry
*__hists__add_entry(struct hists
*self
,
132 struct addr_location
*al
,
133 struct symbol
*sym_parent
, u64 period
)
135 struct rb_node
**p
= &self
->entries
.rb_node
;
136 struct rb_node
*parent
= NULL
;
137 struct hist_entry
*he
;
138 struct hist_entry entry
= {
139 .thread
= al
->thread
,
148 .parent
= sym_parent
,
149 .filtered
= symbol__parent_filter(sym_parent
),
155 he
= rb_entry(parent
, struct hist_entry
, rb_node
);
157 cmp
= hist_entry__cmp(&entry
, he
);
160 he
->period
+= period
;
171 he
= hist_entry__new(&entry
);
174 rb_link_node(&he
->rb_node
, parent
, p
);
175 rb_insert_color(&he
->rb_node
, &self
->entries
);
176 hists__inc_nr_entries(self
, he
);
178 hist_entry__add_cpumode_period(he
, al
->cpumode
, period
);
183 hist_entry__cmp(struct hist_entry
*left
, struct hist_entry
*right
)
185 struct sort_entry
*se
;
188 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
189 cmp
= se
->se_cmp(left
, right
);
198 hist_entry__collapse(struct hist_entry
*left
, struct hist_entry
*right
)
200 struct sort_entry
*se
;
203 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
204 int64_t (*f
)(struct hist_entry
*, struct hist_entry
*);
206 f
= se
->se_collapse
?: se
->se_cmp
;
208 cmp
= f(left
, right
);
216 void hist_entry__free(struct hist_entry
*he
)
222 * collapse the histogram
225 static bool hists__collapse_insert_entry(struct hists
*self
,
226 struct rb_root
*root
,
227 struct hist_entry
*he
)
229 struct rb_node
**p
= &root
->rb_node
;
230 struct rb_node
*parent
= NULL
;
231 struct hist_entry
*iter
;
236 iter
= rb_entry(parent
, struct hist_entry
, rb_node
);
238 cmp
= hist_entry__collapse(iter
, he
);
241 iter
->period
+= he
->period
;
242 if (symbol_conf
.use_callchain
) {
243 callchain_cursor_reset(&self
->callchain_cursor
);
244 callchain_merge(&self
->callchain_cursor
, iter
->callchain
,
247 hist_entry__free(he
);
257 rb_link_node(&he
->rb_node
, parent
, p
);
258 rb_insert_color(&he
->rb_node
, root
);
262 void hists__collapse_resort(struct hists
*self
)
265 struct rb_node
*next
;
266 struct hist_entry
*n
;
268 if (!sort__need_collapse
)
272 next
= rb_first(&self
->entries
);
273 self
->nr_entries
= 0;
274 hists__reset_col_len(self
);
277 n
= rb_entry(next
, struct hist_entry
, rb_node
);
278 next
= rb_next(&n
->rb_node
);
280 rb_erase(&n
->rb_node
, &self
->entries
);
281 if (hists__collapse_insert_entry(self
, &tmp
, n
))
282 hists__inc_nr_entries(self
, n
);
289 * reverse the map, sort on period.
292 static void __hists__insert_output_entry(struct rb_root
*entries
,
293 struct hist_entry
*he
,
294 u64 min_callchain_hits
)
296 struct rb_node
**p
= &entries
->rb_node
;
297 struct rb_node
*parent
= NULL
;
298 struct hist_entry
*iter
;
300 if (symbol_conf
.use_callchain
)
301 callchain_param
.sort(&he
->sorted_chain
, he
->callchain
,
302 min_callchain_hits
, &callchain_param
);
306 iter
= rb_entry(parent
, struct hist_entry
, rb_node
);
308 if (he
->period
> iter
->period
)
314 rb_link_node(&he
->rb_node
, parent
, p
);
315 rb_insert_color(&he
->rb_node
, entries
);
318 void hists__output_resort(struct hists
*self
)
321 struct rb_node
*next
;
322 struct hist_entry
*n
;
323 u64 min_callchain_hits
;
325 min_callchain_hits
= self
->stats
.total_period
* (callchain_param
.min_percent
/ 100);
328 next
= rb_first(&self
->entries
);
330 self
->nr_entries
= 0;
331 hists__reset_col_len(self
);
334 n
= rb_entry(next
, struct hist_entry
, rb_node
);
335 next
= rb_next(&n
->rb_node
);
337 rb_erase(&n
->rb_node
, &self
->entries
);
338 __hists__insert_output_entry(&tmp
, n
, min_callchain_hits
);
339 hists__inc_nr_entries(self
, n
);
345 static size_t callchain__fprintf_left_margin(FILE *fp
, int left_margin
)
348 int ret
= fprintf(fp
, " ");
350 for (i
= 0; i
< left_margin
; i
++)
351 ret
+= fprintf(fp
, " ");
356 static size_t ipchain__fprintf_graph_line(FILE *fp
, int depth
, int depth_mask
,
360 size_t ret
= callchain__fprintf_left_margin(fp
, left_margin
);
362 for (i
= 0; i
< depth
; i
++)
363 if (depth_mask
& (1 << i
))
364 ret
+= fprintf(fp
, "| ");
366 ret
+= fprintf(fp
, " ");
368 ret
+= fprintf(fp
, "\n");
373 static size_t ipchain__fprintf_graph(FILE *fp
, struct callchain_list
*chain
,
374 int depth
, int depth_mask
, int period
,
375 u64 total_samples
, u64 hits
,
381 ret
+= callchain__fprintf_left_margin(fp
, left_margin
);
382 for (i
= 0; i
< depth
; i
++) {
383 if (depth_mask
& (1 << i
))
384 ret
+= fprintf(fp
, "|");
386 ret
+= fprintf(fp
, " ");
387 if (!period
&& i
== depth
- 1) {
390 percent
= hits
* 100.0 / total_samples
;
391 ret
+= percent_color_fprintf(fp
, "--%2.2f%%-- ", percent
);
393 ret
+= fprintf(fp
, "%s", " ");
396 ret
+= fprintf(fp
, "%s\n", chain
->ms
.sym
->name
);
398 ret
+= fprintf(fp
, "%p\n", (void *)(long)chain
->ip
);
403 static struct symbol
*rem_sq_bracket
;
404 static struct callchain_list rem_hits
;
406 static void init_rem_hits(void)
408 rem_sq_bracket
= malloc(sizeof(*rem_sq_bracket
) + 6);
409 if (!rem_sq_bracket
) {
410 fprintf(stderr
, "Not enough memory to display remaining hits\n");
414 strcpy(rem_sq_bracket
->name
, "[...]");
415 rem_hits
.ms
.sym
= rem_sq_bracket
;
418 static size_t __callchain__fprintf_graph(FILE *fp
, struct callchain_node
*self
,
419 u64 total_samples
, int depth
,
420 int depth_mask
, int left_margin
)
422 struct rb_node
*node
, *next
;
423 struct callchain_node
*child
;
424 struct callchain_list
*chain
;
425 int new_depth_mask
= depth_mask
;
430 uint entries_printed
= 0;
432 if (callchain_param
.mode
== CHAIN_GRAPH_REL
)
433 new_total
= self
->children_hit
;
435 new_total
= total_samples
;
437 remaining
= new_total
;
439 node
= rb_first(&self
->rb_root
);
443 child
= rb_entry(node
, struct callchain_node
, rb_node
);
444 cumul
= callchain_cumul_hits(child
);
448 * The depth mask manages the output of pipes that show
449 * the depth. We don't want to keep the pipes of the current
450 * level for the last child of this depth.
451 * Except if we have remaining filtered hits. They will
452 * supersede the last child
454 next
= rb_next(node
);
455 if (!next
&& (callchain_param
.mode
!= CHAIN_GRAPH_REL
|| !remaining
))
456 new_depth_mask
&= ~(1 << (depth
- 1));
459 * But we keep the older depth mask for the line separator
460 * to keep the level link until we reach the last child
462 ret
+= ipchain__fprintf_graph_line(fp
, depth
, depth_mask
,
465 list_for_each_entry(chain
, &child
->val
, list
) {
466 ret
+= ipchain__fprintf_graph(fp
, chain
, depth
,
472 ret
+= __callchain__fprintf_graph(fp
, child
, new_total
,
474 new_depth_mask
| (1 << depth
),
477 if (++entries_printed
== callchain_param
.print_limit
)
481 if (callchain_param
.mode
== CHAIN_GRAPH_REL
&&
482 remaining
&& remaining
!= new_total
) {
487 new_depth_mask
&= ~(1 << (depth
- 1));
489 ret
+= ipchain__fprintf_graph(fp
, &rem_hits
, depth
,
490 new_depth_mask
, 0, new_total
,
491 remaining
, left_margin
);
497 static size_t callchain__fprintf_graph(FILE *fp
, struct callchain_node
*self
,
498 u64 total_samples
, int left_margin
)
500 struct callchain_list
*chain
;
501 bool printed
= false;
504 u32 entries_printed
= 0;
506 list_for_each_entry(chain
, &self
->val
, list
) {
507 if (!i
++ && sort__first_dimension
== SORT_SYM
)
511 ret
+= callchain__fprintf_left_margin(fp
, left_margin
);
512 ret
+= fprintf(fp
, "|\n");
513 ret
+= callchain__fprintf_left_margin(fp
, left_margin
);
514 ret
+= fprintf(fp
, "---");
519 ret
+= callchain__fprintf_left_margin(fp
, left_margin
);
522 ret
+= fprintf(fp
, " %s\n", chain
->ms
.sym
->name
);
524 ret
+= fprintf(fp
, " %p\n", (void *)(long)chain
->ip
);
526 if (++entries_printed
== callchain_param
.print_limit
)
530 ret
+= __callchain__fprintf_graph(fp
, self
, total_samples
, 1, 1, left_margin
);
535 static size_t callchain__fprintf_flat(FILE *fp
, struct callchain_node
*self
,
538 struct callchain_list
*chain
;
544 ret
+= callchain__fprintf_flat(fp
, self
->parent
, total_samples
);
547 list_for_each_entry(chain
, &self
->val
, list
) {
548 if (chain
->ip
>= PERF_CONTEXT_MAX
)
551 ret
+= fprintf(fp
, " %s\n", chain
->ms
.sym
->name
);
553 ret
+= fprintf(fp
, " %p\n",
554 (void *)(long)chain
->ip
);
560 static size_t hist_entry_callchain__fprintf(FILE *fp
, struct hist_entry
*self
,
561 u64 total_samples
, int left_margin
)
563 struct rb_node
*rb_node
;
564 struct callchain_node
*chain
;
566 u32 entries_printed
= 0;
568 rb_node
= rb_first(&self
->sorted_chain
);
572 chain
= rb_entry(rb_node
, struct callchain_node
, rb_node
);
573 percent
= chain
->hit
* 100.0 / total_samples
;
574 switch (callchain_param
.mode
) {
576 ret
+= percent_color_fprintf(fp
, " %6.2f%%\n",
578 ret
+= callchain__fprintf_flat(fp
, chain
, total_samples
);
580 case CHAIN_GRAPH_ABS
: /* Falldown */
581 case CHAIN_GRAPH_REL
:
582 ret
+= callchain__fprintf_graph(fp
, chain
, total_samples
,
588 ret
+= fprintf(fp
, "\n");
589 if (++entries_printed
== callchain_param
.print_limit
)
591 rb_node
= rb_next(rb_node
);
597 int hist_entry__snprintf(struct hist_entry
*self
, char *s
, size_t size
,
598 struct hists
*hists
, struct hists
*pair_hists
,
599 bool show_displacement
, long displacement
,
600 bool color
, u64 session_total
)
602 struct sort_entry
*se
;
603 u64 period
, total
, period_sys
, period_us
, period_guest_sys
, period_guest_us
;
605 const char *sep
= symbol_conf
.field_sep
;
608 if (symbol_conf
.exclude_other
&& !self
->parent
)
612 period
= self
->pair
? self
->pair
->period
: 0;
613 nr_events
= self
->pair
? self
->pair
->nr_events
: 0;
614 total
= pair_hists
->stats
.total_period
;
615 period_sys
= self
->pair
? self
->pair
->period_sys
: 0;
616 period_us
= self
->pair
? self
->pair
->period_us
: 0;
617 period_guest_sys
= self
->pair
? self
->pair
->period_guest_sys
: 0;
618 period_guest_us
= self
->pair
? self
->pair
->period_guest_us
: 0;
620 period
= self
->period
;
621 nr_events
= self
->nr_events
;
622 total
= session_total
;
623 period_sys
= self
->period_sys
;
624 period_us
= self
->period_us
;
625 period_guest_sys
= self
->period_guest_sys
;
626 period_guest_us
= self
->period_guest_us
;
631 ret
= percent_color_snprintf(s
, size
,
632 sep
? "%.2f" : " %6.2f%%",
633 (period
* 100.0) / total
);
635 ret
= snprintf(s
, size
, sep
? "%.2f" : " %6.2f%%",
636 (period
* 100.0) / total
);
637 if (symbol_conf
.show_cpu_utilization
) {
638 ret
+= percent_color_snprintf(s
+ ret
, size
- ret
,
639 sep
? "%.2f" : " %6.2f%%",
640 (period_sys
* 100.0) / total
);
641 ret
+= percent_color_snprintf(s
+ ret
, size
- ret
,
642 sep
? "%.2f" : " %6.2f%%",
643 (period_us
* 100.0) / total
);
645 ret
+= percent_color_snprintf(s
+ ret
,
647 sep
? "%.2f" : " %6.2f%%",
648 (period_guest_sys
* 100.0) /
650 ret
+= percent_color_snprintf(s
+ ret
,
652 sep
? "%.2f" : " %6.2f%%",
653 (period_guest_us
* 100.0) /
658 ret
= snprintf(s
, size
, sep
? "%" PRIu64
: "%12" PRIu64
" ", period
);
660 if (symbol_conf
.show_nr_samples
) {
662 ret
+= snprintf(s
+ ret
, size
- ret
, "%c%" PRIu64
, *sep
, nr_events
);
664 ret
+= snprintf(s
+ ret
, size
- ret
, "%11" PRIu64
, nr_events
);
669 double old_percent
= 0, new_percent
= 0, diff
;
672 old_percent
= (period
* 100.0) / total
;
673 if (session_total
> 0)
674 new_percent
= (self
->period
* 100.0) / session_total
;
676 diff
= new_percent
- old_percent
;
678 if (fabs(diff
) >= 0.01)
679 snprintf(bf
, sizeof(bf
), "%+4.2F%%", diff
);
681 snprintf(bf
, sizeof(bf
), " ");
684 ret
+= snprintf(s
+ ret
, size
- ret
, "%c%s", *sep
, bf
);
686 ret
+= snprintf(s
+ ret
, size
- ret
, "%11.11s", bf
);
688 if (show_displacement
) {
690 snprintf(bf
, sizeof(bf
), "%+4ld", displacement
);
692 snprintf(bf
, sizeof(bf
), " ");
695 ret
+= snprintf(s
+ ret
, size
- ret
, "%c%s", *sep
, bf
);
697 ret
+= snprintf(s
+ ret
, size
- ret
, "%6.6s", bf
);
701 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
705 ret
+= snprintf(s
+ ret
, size
- ret
, "%s", sep
?: " ");
706 ret
+= se
->se_snprintf(self
, s
+ ret
, size
- ret
,
707 hists__col_len(hists
, se
->se_width_idx
));
713 int hist_entry__fprintf(struct hist_entry
*self
, struct hists
*hists
,
714 struct hists
*pair_hists
, bool show_displacement
,
715 long displacement
, FILE *fp
, u64 session_total
)
718 hist_entry__snprintf(self
, bf
, sizeof(bf
), hists
, pair_hists
,
719 show_displacement
, displacement
,
720 true, session_total
);
721 return fprintf(fp
, "%s\n", bf
);
724 static size_t hist_entry__fprintf_callchain(struct hist_entry
*self
,
725 struct hists
*hists
, FILE *fp
,
730 if (sort__first_dimension
== SORT_COMM
) {
731 struct sort_entry
*se
= list_first_entry(&hist_entry__sort_list
,
733 left_margin
= hists__col_len(hists
, se
->se_width_idx
);
734 left_margin
-= thread__comm_len(self
->thread
);
737 return hist_entry_callchain__fprintf(fp
, self
, session_total
,
741 size_t hists__fprintf(struct hists
*self
, struct hists
*pair
,
742 bool show_displacement
, FILE *fp
)
744 struct sort_entry
*se
;
747 unsigned long position
= 1;
748 long displacement
= 0;
750 const char *sep
= symbol_conf
.field_sep
;
751 const char *col_width
= symbol_conf
.col_width_list_str
;
755 fprintf(fp
, "# %s", pair
? "Baseline" : "Overhead");
757 if (symbol_conf
.show_nr_samples
) {
759 fprintf(fp
, "%cSamples", *sep
);
761 fputs(" Samples ", fp
);
764 if (symbol_conf
.show_cpu_utilization
) {
766 ret
+= fprintf(fp
, "%csys", *sep
);
767 ret
+= fprintf(fp
, "%cus", *sep
);
769 ret
+= fprintf(fp
, "%cguest sys", *sep
);
770 ret
+= fprintf(fp
, "%cguest us", *sep
);
773 ret
+= fprintf(fp
, " sys ");
774 ret
+= fprintf(fp
, " us ");
776 ret
+= fprintf(fp
, " guest sys ");
777 ret
+= fprintf(fp
, " guest us ");
784 ret
+= fprintf(fp
, "%cDelta", *sep
);
786 ret
+= fprintf(fp
, " Delta ");
788 if (show_displacement
) {
790 ret
+= fprintf(fp
, "%cDisplacement", *sep
);
792 ret
+= fprintf(fp
, " Displ");
796 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
800 fprintf(fp
, "%c%s", *sep
, se
->se_header
);
803 width
= strlen(se
->se_header
);
804 if (symbol_conf
.col_width_list_str
) {
806 hists__set_col_len(self
, se
->se_width_idx
,
808 col_width
= strchr(col_width
, ',');
813 if (!hists__new_col_len(self
, se
->se_width_idx
, width
))
814 width
= hists__col_len(self
, se
->se_width_idx
);
815 fprintf(fp
, " %*s", width
, se
->se_header
);
822 fprintf(fp
, "# ........");
823 if (symbol_conf
.show_nr_samples
)
824 fprintf(fp
, " ..........");
826 fprintf(fp
, " ..........");
827 if (show_displacement
)
828 fprintf(fp
, " .....");
830 list_for_each_entry(se
, &hist_entry__sort_list
, list
) {
837 width
= hists__col_len(self
, se
->se_width_idx
);
839 width
= strlen(se
->se_header
);
840 for (i
= 0; i
< width
; i
++)
844 fprintf(fp
, "\n#\n");
847 for (nd
= rb_first(&self
->entries
); nd
; nd
= rb_next(nd
)) {
848 struct hist_entry
*h
= rb_entry(nd
, struct hist_entry
, rb_node
);
853 if (show_displacement
) {
855 displacement
= ((long)h
->pair
->position
-
861 ret
+= hist_entry__fprintf(h
, self
, pair
, show_displacement
,
862 displacement
, fp
, self
->stats
.total_period
);
864 if (symbol_conf
.use_callchain
)
865 ret
+= hist_entry__fprintf_callchain(h
, self
, fp
,
866 self
->stats
.total_period
);
867 if (h
->ms
.map
== NULL
&& verbose
> 1) {
868 __map_groups__fprintf_maps(&h
->thread
->mg
,
869 MAP__FUNCTION
, verbose
, fp
);
870 fprintf(fp
, "%.10s end\n", graph_dotted_line
);
874 free(rem_sq_bracket
);
880 * See hists__fprintf to match the column widths
882 unsigned int hists__sort_list_width(struct hists
*self
)
884 struct sort_entry
*se
;
885 int ret
= 9; /* total % */
887 if (symbol_conf
.show_cpu_utilization
) {
888 ret
+= 7; /* count_sys % */
889 ret
+= 6; /* count_us % */
891 ret
+= 13; /* count_guest_sys % */
892 ret
+= 12; /* count_guest_us % */
896 if (symbol_conf
.show_nr_samples
)
899 list_for_each_entry(se
, &hist_entry__sort_list
, list
)
901 ret
+= 2 + hists__col_len(self
, se
->se_width_idx
);
903 if (verbose
) /* Addr + origin */
904 ret
+= 3 + BITS_PER_LONG
/ 4;
909 static void hists__remove_entry_filter(struct hists
*self
, struct hist_entry
*h
,
910 enum hist_filter filter
)
912 h
->filtered
&= ~(1 << filter
);
918 self
->nr_entries
+= h
->nr_rows
;
920 self
->stats
.total_period
+= h
->period
;
921 self
->stats
.nr_events
[PERF_RECORD_SAMPLE
] += h
->nr_events
;
923 hists__calc_col_len(self
, h
);
926 void hists__filter_by_dso(struct hists
*self
, const struct dso
*dso
)
930 self
->nr_entries
= self
->stats
.total_period
= 0;
931 self
->stats
.nr_events
[PERF_RECORD_SAMPLE
] = 0;
932 hists__reset_col_len(self
);
934 for (nd
= rb_first(&self
->entries
); nd
; nd
= rb_next(nd
)) {
935 struct hist_entry
*h
= rb_entry(nd
, struct hist_entry
, rb_node
);
937 if (symbol_conf
.exclude_other
&& !h
->parent
)
940 if (dso
!= NULL
&& (h
->ms
.map
== NULL
|| h
->ms
.map
->dso
!= dso
)) {
941 h
->filtered
|= (1 << HIST_FILTER__DSO
);
945 hists__remove_entry_filter(self
, h
, HIST_FILTER__DSO
);
949 void hists__filter_by_thread(struct hists
*self
, const struct thread
*thread
)
953 self
->nr_entries
= self
->stats
.total_period
= 0;
954 self
->stats
.nr_events
[PERF_RECORD_SAMPLE
] = 0;
955 hists__reset_col_len(self
);
957 for (nd
= rb_first(&self
->entries
); nd
; nd
= rb_next(nd
)) {
958 struct hist_entry
*h
= rb_entry(nd
, struct hist_entry
, rb_node
);
960 if (thread
!= NULL
&& h
->thread
!= thread
) {
961 h
->filtered
|= (1 << HIST_FILTER__THREAD
);
965 hists__remove_entry_filter(self
, h
, HIST_FILTER__THREAD
);
969 int hist_entry__inc_addr_samples(struct hist_entry
*he
, int evidx
, u64 ip
)
971 return symbol__inc_addr_samples(he
->ms
.sym
, he
->ms
.map
, evidx
, ip
);
974 int hist_entry__annotate(struct hist_entry
*he
, size_t privsize
)
976 return symbol__annotate(he
->ms
.sym
, he
->ms
.map
, privsize
);
979 void hists__inc_nr_events(struct hists
*self
, u32 type
)
981 ++self
->stats
.nr_events
[0];
982 ++self
->stats
.nr_events
[type
];
985 size_t hists__fprintf_nr_events(struct hists
*self
, FILE *fp
)
990 for (i
= 0; i
< PERF_RECORD_HEADER_MAX
; ++i
) {
993 if (self
->stats
.nr_events
[i
] == 0)
996 name
= perf_event__name(i
);
997 if (!strcmp(name
, "UNKNOWN"))
1000 ret
+= fprintf(fp
, "%16s events: %10d\n", name
,
1001 self
->stats
.nr_events
[i
]);