20d6f55528
Reusing the existing --total-cycles option to display the branch counters. Add a new PERF_HPP_REPORT__BLOCK_BRANCH_COUNTER to display the logged branch counter events. They are shown right after all the cycle-related annotations. Extend the 'struct block_info' to store and pass the branch counter related information. The annotation_br_cntr_entry() is to print the histogram of each branch counter event. If the number of logged events is less than 4, the exact number of the abbr name is printed. Otherwise, using '+' to stands for more than 3 events. Assume the number of logged events is less than 4. The annotation_br_cntr_abbr_list() prints the branch counter's abbreviation list. Press 'B' to display the list in the TUI mode. $ perf record -e "{branch-instructions:ppp,branch-misses}:S" -j any,counter $ perf report --total-cycles --stdio # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 1M of events 'anon group { branch-instructions:ppp, branch-misses }' # Event count (approx.): 1610046 # # Branch counter abbr list: # branch-instructions:ppp = A # branch-misses = B # '-' No event occurs # '+' Event occurrences may be lost due to branch counter saturated # # Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles Branch Counter [Program Block Range] # ............... .............. ........... .......... .............. .................. # 57.55% 2.5M 0.00% 3 |A |- | ... 25.27% 1.1M 0.00% 2 |AA |- | ... 15.61% 667.2K 0.00% 1 |A |- | ... 0.16% 6.9K 0.81% 575 |A |- | ... 0.16% 6.8K 1.38% 977 |AA |- | ... 0.16% 6.8K 0.04% 28 |AA |B | ... 0.15% 6.6K 1.33% 946 |A |- | ... 0.11% 4.5K 0.06% 46 |AAA+|- | ... 0.10% 4.4K 0.88% 624 |A |- | ... 0.09% 3.7K 0.74% 524 |AAA+|B | ... With -v applied, # Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles Branch Counter [Program Block Range] # ............... .............. ........... .......... .............. .................. # 57.55% 2.5M 0.00% 3 A=1 ,B=- ... 25.27% 1.1M 0.00% 2 A=2 ,B=- ... 15.61% 667.2K 0.00% 1 A=1 ,B=- ... 0.16% 6.9K 0.81% 575 A=1 ,B=- ... 0.16% 6.8K 1.38% 977 A=2 ,B=- ... 0.16% 6.8K 0.04% 28 A=2 ,B=1 ... 0.15% 6.6K 1.33% 946 A=1 ,B=- ... 0.11% 4.5K 0.06% 46 A=3+,B=- ... 0.10% 4.4K 0.88% 624 A=1 ,B=- ... 0.09% 3.7K 0.74% 524 A=3+,B=1 ... Reviewed-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: https://lore.kernel.org/r/20240813160208.2493643-7-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __PERF_BLOCK_H
|
|
#define __PERF_BLOCK_H
|
|
|
|
#include <linux/types.h>
|
|
#include "hist.h"
|
|
#include "symbol.h"
|
|
#include "sort.h"
|
|
#include "ui/ui.h"
|
|
|
|
struct block_info {
|
|
struct symbol *sym;
|
|
u64 start;
|
|
u64 end;
|
|
u64 cycles;
|
|
u64 cycles_aggr;
|
|
s64 cycles_spark[NUM_SPARKS];
|
|
u64 total_cycles;
|
|
int num;
|
|
int num_aggr;
|
|
int br_cntr_nr;
|
|
u64 *br_cntr;
|
|
struct evsel *evsel;
|
|
};
|
|
|
|
struct block_fmt {
|
|
struct perf_hpp_fmt fmt;
|
|
int idx;
|
|
int width;
|
|
const char *header;
|
|
u64 total_cycles;
|
|
u64 block_cycles;
|
|
};
|
|
|
|
enum {
|
|
PERF_HPP_REPORT__BLOCK_TOTAL_CYCLES_PCT,
|
|
PERF_HPP_REPORT__BLOCK_LBR_CYCLES,
|
|
PERF_HPP_REPORT__BLOCK_CYCLES_PCT,
|
|
PERF_HPP_REPORT__BLOCK_AVG_CYCLES,
|
|
PERF_HPP_REPORT__BLOCK_RANGE,
|
|
PERF_HPP_REPORT__BLOCK_DSO,
|
|
PERF_HPP_REPORT__BLOCK_BRANCH_COUNTER,
|
|
PERF_HPP_REPORT__BLOCK_MAX_INDEX
|
|
};
|
|
|
|
struct block_report {
|
|
struct block_hist hist;
|
|
u64 cycles;
|
|
struct block_fmt fmts[PERF_HPP_REPORT__BLOCK_MAX_INDEX];
|
|
int nr_fmts;
|
|
};
|
|
|
|
void block_info__delete(struct block_info *bi);
|
|
|
|
int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right);
|
|
|
|
int64_t block_info__cmp(struct perf_hpp_fmt *fmt __maybe_unused,
|
|
struct hist_entry *left, struct hist_entry *right);
|
|
|
|
int block_info__process_sym(struct hist_entry *he, struct block_hist *bh,
|
|
u64 *block_cycles_aggr, u64 total_cycles,
|
|
unsigned int br_cntr_nr);
|
|
|
|
struct block_report *block_info__create_report(struct evlist *evlist,
|
|
u64 total_cycles,
|
|
int *block_hpps, int nr_hpps,
|
|
int *nr_reps);
|
|
|
|
void block_info__free_report(struct block_report *reps, int nr_reps);
|
|
|
|
int report__browse_block_hists(struct block_hist *bh, float min_percent,
|
|
struct evsel *evsel, struct perf_env *env);
|
|
|
|
float block_info__total_cycles_percent(struct hist_entry *he);
|
|
|
|
#endif /* __PERF_BLOCK_H */
|