AMD Last Branch Record Extension Version 2 (LbrExtV2) provides branch
speculation information and the perf UAPI is extended to provide this in
a generic way. Update the tools headers and perf tool to be able to show
this additional information.
The LbrExtV2 enablement and UAPI changes can be found at:
https://lore.kernel.org/all/[email protected]/
Previous versions can be found at:
v1: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Drop msr-index.h related changes for now.
- Rebase on top of latest perf/core.
- Fix UAPI breakage introduced by the ARM64 BRBE changes to perf branch
entry.
Sandipan Das (3):
tools headers uapi: Sync perf_event.h with kernel sources
perf script: Show branch speculation info
perf session: Show branch speculation info in raw dump
tools/include/uapi/linux/perf_event.h | 15 ++++++++++++++-
tools/perf/builtin-script.c | 5 +++--
tools/perf/util/branch.c | 15 +++++++++++++++
tools/perf/util/branch.h | 5 ++++-
tools/perf/util/evsel.c | 15 ++++++++++++---
tools/perf/util/session.c | 5 +++--
6 files changed, 51 insertions(+), 9 deletions(-)
--
2.34.1
Sync perf_event.h with the kernel sources by adding the new "spec" bitfield
to branch entries.
Signed-off-by: Sandipan Das <[email protected]>
---
tools/include/uapi/linux/perf_event.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 49cb2355efc0..9e1ae54b48a2 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -263,6 +263,17 @@ enum {
PERF_BR_MAX,
};
+/*
+ * Common branch speculation outcome classification
+ */
+enum {
+ PERF_BR_SPEC_NA = 0, /* Not available */
+ PERF_BR_SPEC_WRONG_PATH = 1, /* Speculative but on wrong path */
+ PERF_BR_NON_SPEC_CORRECT_PATH = 2, /* Non-speculative but on correct path */
+ PERF_BR_SPEC_CORRECT_PATH = 3, /* Speculative and on correct path */
+ PERF_BR_SPEC_MAX,
+};
+
enum {
PERF_BR_NEW_FAULT_ALGN = 0, /* Alignment fault */
PERF_BR_NEW_FAULT_DATA = 1, /* Data fault */
@@ -1395,6 +1406,7 @@ union perf_mem_data_src {
* abort: aborting a hardware transaction
* cycles: cycles from last branch (or 0 if not supported)
* type: branch type
+ * spec: branch speculation info (or 0 if not supported)
*/
struct perf_branch_entry {
__u64 from;
@@ -1405,9 +1417,10 @@ struct perf_branch_entry {
abort:1, /* transaction abort */
cycles:16, /* cycle count to last branch */
type:4, /* branch type */
+ spec:2, /* branch speculation info */
new_type:4, /* additional branch type */
priv:3, /* privilege level */
- reserved:33;
+ reserved:31;
};
union perf_sample_weight {
--
2.34.1