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