0001
0002 #ifndef __PERF_BLOCK_H
0003 #define __PERF_BLOCK_H
0004
0005 #include <linux/types.h>
0006 #include <linux/refcount.h>
0007 #include "hist.h"
0008 #include "symbol.h"
0009 #include "sort.h"
0010 #include "ui/ui.h"
0011
0012 struct block_info {
0013 struct symbol *sym;
0014 u64 start;
0015 u64 end;
0016 u64 cycles;
0017 u64 cycles_aggr;
0018 s64 cycles_spark[NUM_SPARKS];
0019 u64 total_cycles;
0020 int num;
0021 int num_aggr;
0022 refcount_t refcnt;
0023 };
0024
0025 struct block_fmt {
0026 struct perf_hpp_fmt fmt;
0027 int idx;
0028 int width;
0029 const char *header;
0030 u64 total_cycles;
0031 u64 block_cycles;
0032 };
0033
0034 enum {
0035 PERF_HPP_REPORT__BLOCK_TOTAL_CYCLES_PCT,
0036 PERF_HPP_REPORT__BLOCK_LBR_CYCLES,
0037 PERF_HPP_REPORT__BLOCK_CYCLES_PCT,
0038 PERF_HPP_REPORT__BLOCK_AVG_CYCLES,
0039 PERF_HPP_REPORT__BLOCK_RANGE,
0040 PERF_HPP_REPORT__BLOCK_DSO,
0041 PERF_HPP_REPORT__BLOCK_MAX_INDEX
0042 };
0043
0044 struct block_report {
0045 struct block_hist hist;
0046 u64 cycles;
0047 struct block_fmt fmts[PERF_HPP_REPORT__BLOCK_MAX_INDEX];
0048 int nr_fmts;
0049 };
0050
0051 struct block_hist;
0052
0053 struct block_info *block_info__new(void);
0054 struct block_info *block_info__get(struct block_info *bi);
0055 void block_info__put(struct block_info *bi);
0056
0057 static inline void __block_info__zput(struct block_info **bi)
0058 {
0059 block_info__put(*bi);
0060 *bi = NULL;
0061 }
0062
0063 #define block_info__zput(bi) __block_info__zput(&bi)
0064
0065 int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right);
0066
0067 int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
0068 struct hist_entry *left, struct hist_entry *right);
0069
0070 int block_info__process_sym(struct hist_entry *he, struct block_hist *bh,
0071 u64 *block_cycles_aggr, u64 total_cycles);
0072
0073 struct block_report *block_info__create_report(struct evlist *evlist,
0074 u64 total_cycles,
0075 int *block_hpps, int nr_hpps,
0076 int *nr_reps);
0077
0078 void block_info__free_report(struct block_report *reps, int nr_reps);
0079
0080 int report__browse_block_hists(struct block_hist *bh, float min_percent,
0081 struct evsel *evsel, struct perf_env *env,
0082 struct annotation_options *annotation_opts);
0083
0084 float block_info__total_cycles_percent(struct hist_entry *he);
0085
0086 #endif