This updates the perf tool with generic branch type classification with new
ABI extender place holder i.e PERF_BR_EXTEND_ABI, the new 4 bit branch type
field i.e perf_branch_entry.new_type, new generic page fault related branch
types and some arch specific branch types as added earlier in the kernel.
Committer note:
Add an extra entry to the branch_type_name array to cope with
PERF_BR_EXTEND_ABI, to address build warnings on some compiler/systems,
like:
75 8.89 ubuntu:20.04-x-powerpc64el : FAIL gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04)
inlined from 'branch_type_stat_display' at util/branch.c:152:4:
/usr/powerpc64le-linux-gnu/include/bits/stdio2.h:100:10: error: '%8s' directive argument is null [-Werror=format-overflow=]
100 | return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20220824044822.70230-7-anshuman.khandual@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
93 lines
2.2 KiB
C
93 lines
2.2 KiB
C
#ifndef _PERF_BRANCH_H
|
|
#define _PERF_BRANCH_H 1
|
|
/*
|
|
* The linux/stddef.h isn't need here, but is needed for __always_inline used
|
|
* in files included from uapi/linux/perf_event.h such as
|
|
* /usr/include/linux/swab.h and /usr/include/linux/byteorder/little_endian.h,
|
|
* detected in at least musl libc, used in Alpine Linux. -acme
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/stddef.h>
|
|
#include <linux/perf_event.h>
|
|
#include <linux/types.h>
|
|
#include "event.h"
|
|
|
|
struct branch_flags {
|
|
union {
|
|
u64 value;
|
|
struct {
|
|
u64 mispred:1;
|
|
u64 predicted:1;
|
|
u64 in_tx:1;
|
|
u64 abort:1;
|
|
u64 cycles:16;
|
|
u64 type:4;
|
|
u64 new_type:4;
|
|
u64 reserved:36;
|
|
};
|
|
};
|
|
};
|
|
|
|
struct branch_info {
|
|
struct addr_map_symbol from;
|
|
struct addr_map_symbol to;
|
|
struct branch_flags flags;
|
|
char *srcline_from;
|
|
char *srcline_to;
|
|
};
|
|
|
|
struct branch_entry {
|
|
u64 from;
|
|
u64 to;
|
|
struct branch_flags flags;
|
|
};
|
|
|
|
struct branch_stack {
|
|
u64 nr;
|
|
u64 hw_idx;
|
|
struct branch_entry entries[];
|
|
};
|
|
|
|
/*
|
|
* The hw_idx is only available when PERF_SAMPLE_BRANCH_HW_INDEX is applied.
|
|
* Otherwise, the output format of a sample with branch stack is
|
|
* struct branch_stack {
|
|
* u64 nr;
|
|
* struct branch_entry entries[0];
|
|
* }
|
|
* Check whether the hw_idx is available,
|
|
* and return the corresponding pointer of entries[0].
|
|
*/
|
|
static inline struct branch_entry *perf_sample__branch_entries(struct perf_sample *sample)
|
|
{
|
|
u64 *entry = (u64 *)sample->branch_stack;
|
|
|
|
entry++;
|
|
if (sample->no_hw_idx)
|
|
return (struct branch_entry *)entry;
|
|
return (struct branch_entry *)(++entry);
|
|
}
|
|
|
|
struct branch_type_stat {
|
|
bool branch_to;
|
|
u64 counts[PERF_BR_MAX];
|
|
u64 new_counts[PERF_BR_NEW_MAX];
|
|
u64 cond_fwd;
|
|
u64 cond_bwd;
|
|
u64 cross_4k;
|
|
u64 cross_2m;
|
|
};
|
|
|
|
void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
|
|
u64 from, u64 to);
|
|
|
|
const char *branch_type_name(int type);
|
|
const char *branch_new_type_name(int new_type);
|
|
const char *get_branch_type(struct branch_entry *e);
|
|
void branch_type_stat_display(FILE *fp, struct branch_type_stat *st);
|
|
int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize);
|
|
|
|
#endif /* _PERF_BRANCH_H */
|