[4/6] tools headers UAPI: Sync include/uapi/linux/perf_event.h header with the kernel
Commit Message
From: Kan Liang <kan.liang@linux.intel.com>
The branch event information and the corresponding event IDs can be
collected by kernel with the LBR event logging feature on Intel
platforms. Sync the new sample types and the new fields of
struct perf_branch_entry, so the perf tool can retrieve the occurrences
of events for each branch and the corresponding event IDs.
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
tools/include/uapi/linux/perf_event.h | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
@@ -162,8 +162,9 @@ enum perf_event_sample_format {
PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22,
PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,
PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24,
+ PERF_SAMPLE_BRANCH_EVENT_IDS = 1U << 25,
- PERF_SAMPLE_MAX = 1U << 25, /* non-ABI */
+ PERF_SAMPLE_MAX = 1U << 26, /* non-ABI */
};
#define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT)
@@ -204,6 +205,8 @@ enum perf_branch_sample_type_shift {
PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT = 18, /* save privilege mode */
+ PERF_SAMPLE_BRANCH_EVENT_SHIFT = 19, /* save occurrences of events */
+
PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */
};
@@ -235,6 +238,8 @@ enum perf_branch_sample_type {
PERF_SAMPLE_BRANCH_PRIV_SAVE = 1U << PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT,
+ PERF_SAMPLE_BRANCH_EVENT = 1U << PERF_SAMPLE_BRANCH_EVENT_SHIFT,
+
PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
};
@@ -1015,6 +1020,8 @@ enum perf_event_type {
* char data[size]; } && PERF_SAMPLE_AUX
* { u64 data_page_size;} && PERF_SAMPLE_DATA_PAGE_SIZE
* { u64 code_page_size;} && PERF_SAMPLE_CODE_PAGE_SIZE
+ * { u64 nr;
+ * u64 ids[nr];} && PERF_SAMPLE_BRANCH_EVENT_IDS
* };
*/
PERF_RECORD_SAMPLE = 9,
@@ -1391,6 +1398,12 @@ union perf_mem_data_src {
#define PERF_MEM_S(a, s) \
(((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)
+#define PERF_MAX_BRANCH_EVENTS 4
+#define PERF_BRANCH_EVENTS_MASK 0x3
+#define PERF_BRANCH_EVENTS_STEP 2
+
+#define perf_branch_event_by_idx(_events, _idx) \
+ (((_events) >> ((_idx) * PERF_BRANCH_EVENTS_STEP)) & PERF_BRANCH_EVENTS_MASK)
/*
* single taken branch record layout:
*
@@ -1407,6 +1420,10 @@ union perf_mem_data_src {
* cycles: cycles from last branch (or 0 if not supported)
* type: branch type
* spec: branch speculation info (or 0 if not supported)
+ * events: occurrences of events since the last branch entry.
+ * The fields can store up to 4 events with saturating
+ * at value 3.
+ * (or 0 if not supported)
*/
struct perf_branch_entry {
__u64 from;
@@ -1420,7 +1437,8 @@ struct perf_branch_entry {
spec:2, /* branch speculation info */
new_type:4, /* additional branch type */
priv:3, /* privilege level */
- reserved:31;
+ events:8, /* occurrences of events since the last branch entry */
+ reserved:23;
};
union perf_sample_weight {