xref: /linux/tools/perf/util/block-info.h (revision 9a6b55ac)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_BLOCK_H
3 #define __PERF_BLOCK_H
4 
5 #include <linux/types.h>
6 #include <linux/refcount.h>
7 #include "hist.h"
8 #include "symbol.h"
9 #include "sort.h"
10 #include "ui/ui.h"
11 
12 struct block_info {
13 	struct symbol		*sym;
14 	u64			start;
15 	u64			end;
16 	u64			cycles;
17 	u64			cycles_aggr;
18 	s64			cycles_spark[NUM_SPARKS];
19 	u64			total_cycles;
20 	int			num;
21 	int			num_aggr;
22 	refcount_t		refcnt;
23 };
24 
25 struct block_fmt {
26 	struct perf_hpp_fmt	fmt;
27 	int			idx;
28 	int			width;
29 	const char		*header;
30 	u64			total_cycles;
31 	u64			block_cycles;
32 };
33 
34 enum {
35 	PERF_HPP_REPORT__BLOCK_TOTAL_CYCLES_PCT,
36 	PERF_HPP_REPORT__BLOCK_LBR_CYCLES,
37 	PERF_HPP_REPORT__BLOCK_CYCLES_PCT,
38 	PERF_HPP_REPORT__BLOCK_AVG_CYCLES,
39 	PERF_HPP_REPORT__BLOCK_RANGE,
40 	PERF_HPP_REPORT__BLOCK_DSO,
41 	PERF_HPP_REPORT__BLOCK_MAX_INDEX
42 };
43 
44 struct block_report {
45 	struct block_hist	hist;
46 	u64			cycles;
47 	struct block_fmt	fmts[PERF_HPP_REPORT__BLOCK_MAX_INDEX];
48 };
49 
50 struct block_hist;
51 
52 struct block_info *block_info__new(void);
53 struct block_info *block_info__get(struct block_info *bi);
54 void   block_info__put(struct block_info *bi);
55 
56 static inline void __block_info__zput(struct block_info **bi)
57 {
58 	block_info__put(*bi);
59 	*bi = NULL;
60 }
61 
62 #define block_info__zput(bi) __block_info__zput(&bi)
63 
64 int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
65 			struct hist_entry *left, struct hist_entry *right);
66 
67 int block_info__process_sym(struct hist_entry *he, struct block_hist *bh,
68 			    u64 *block_cycles_aggr, u64 total_cycles);
69 
70 struct block_report *block_info__create_report(struct evlist *evlist,
71 					       u64 total_cycles);
72 
73 int report__browse_block_hists(struct block_hist *bh, float min_percent,
74 			       struct evsel *evsel, struct perf_env *env,
75 			       struct annotation_options *annotation_opts);
76 
77 float block_info__total_cycles_percent(struct hist_entry *he);
78 
79 #endif /* __PERF_BLOCK_H */
80