0001 #ifndef _PERF_BRANCH_H
0002 #define _PERF_BRANCH_H 1
0003
0004
0005
0006
0007
0008
0009 #include <stdio.h>
0010 #include <stdint.h>
0011 #include <linux/compiler.h>
0012 #include <linux/stddef.h>
0013 #include <linux/perf_event.h>
0014 #include <linux/types.h>
0015 #include "event.h"
0016
0017 struct branch_flags {
0018 union {
0019 u64 value;
0020 struct {
0021 u64 mispred:1;
0022 u64 predicted:1;
0023 u64 in_tx:1;
0024 u64 abort:1;
0025 u64 cycles:16;
0026 u64 type:4;
0027 u64 reserved:40;
0028 };
0029 };
0030 };
0031
0032 struct branch_info {
0033 struct addr_map_symbol from;
0034 struct addr_map_symbol to;
0035 struct branch_flags flags;
0036 char *srcline_from;
0037 char *srcline_to;
0038 };
0039
0040 struct branch_entry {
0041 u64 from;
0042 u64 to;
0043 struct branch_flags flags;
0044 };
0045
0046 struct branch_stack {
0047 u64 nr;
0048 u64 hw_idx;
0049 struct branch_entry entries[];
0050 };
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 static inline struct branch_entry *perf_sample__branch_entries(struct perf_sample *sample)
0063 {
0064 u64 *entry = (u64 *)sample->branch_stack;
0065
0066 entry++;
0067 if (sample->no_hw_idx)
0068 return (struct branch_entry *)entry;
0069 return (struct branch_entry *)(++entry);
0070 }
0071
0072 struct branch_type_stat {
0073 bool branch_to;
0074 u64 counts[PERF_BR_MAX];
0075 u64 cond_fwd;
0076 u64 cond_bwd;
0077 u64 cross_4k;
0078 u64 cross_2m;
0079 };
0080
0081 void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
0082 u64 from, u64 to);
0083
0084 const char *branch_type_name(int type);
0085 void branch_type_stat_display(FILE *fp, struct branch_type_stat *st);
0086 int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize);
0087
0088 #endif