blob: be32b5152c463f1b42fa81a3be297c9601beff71 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_LINUX_PERF_EVENT_H
20#define _UAPI_LINUX_PERF_EVENT_H
21#include <linux/types.h>
22#include <linux/ioctl.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070023#include <asm/byteorder.h>
24enum perf_type_id {
Tao Baod7db5942015-01-28 10:07:51 -080025 PERF_TYPE_HARDWARE = 0,
26 PERF_TYPE_SOFTWARE = 1,
Tao Baod7db5942015-01-28 10:07:51 -080027 PERF_TYPE_TRACEPOINT = 2,
28 PERF_TYPE_HW_CACHE = 3,
29 PERF_TYPE_RAW = 4,
30 PERF_TYPE_BREAKPOINT = 5,
Tao Baod7db5942015-01-28 10:07:51 -080031 PERF_TYPE_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070032};
33enum perf_hw_id {
Tao Baod7db5942015-01-28 10:07:51 -080034 PERF_COUNT_HW_CPU_CYCLES = 0,
Tao Baod7db5942015-01-28 10:07:51 -080035 PERF_COUNT_HW_INSTRUCTIONS = 1,
36 PERF_COUNT_HW_CACHE_REFERENCES = 2,
37 PERF_COUNT_HW_CACHE_MISSES = 3,
38 PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4,
Tao Baod7db5942015-01-28 10:07:51 -080039 PERF_COUNT_HW_BRANCH_MISSES = 5,
40 PERF_COUNT_HW_BUS_CYCLES = 6,
41 PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
42 PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
Tao Baod7db5942015-01-28 10:07:51 -080043 PERF_COUNT_HW_REF_CPU_CYCLES = 9,
44 PERF_COUNT_HW_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070045};
46enum perf_hw_cache_id {
Tao Baod7db5942015-01-28 10:07:51 -080047 PERF_COUNT_HW_CACHE_L1D = 0,
48 PERF_COUNT_HW_CACHE_L1I = 1,
49 PERF_COUNT_HW_CACHE_LL = 2,
50 PERF_COUNT_HW_CACHE_DTLB = 3,
Tao Baod7db5942015-01-28 10:07:51 -080051 PERF_COUNT_HW_CACHE_ITLB = 4,
52 PERF_COUNT_HW_CACHE_BPU = 5,
53 PERF_COUNT_HW_CACHE_NODE = 6,
54 PERF_COUNT_HW_CACHE_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070055};
56enum perf_hw_cache_op_id {
Tao Baod7db5942015-01-28 10:07:51 -080057 PERF_COUNT_HW_CACHE_OP_READ = 0,
58 PERF_COUNT_HW_CACHE_OP_WRITE = 1,
Tao Baod7db5942015-01-28 10:07:51 -080059 PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
60 PERF_COUNT_HW_CACHE_OP_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070061};
62enum perf_hw_cache_op_result_id {
Tao Baod7db5942015-01-28 10:07:51 -080063 PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
64 PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
65 PERF_COUNT_HW_CACHE_RESULT_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070066};
Ben Cheng655a7c02013-10-16 16:09:24 -070067enum perf_sw_ids {
Tao Baod7db5942015-01-28 10:07:51 -080068 PERF_COUNT_SW_CPU_CLOCK = 0,
69 PERF_COUNT_SW_TASK_CLOCK = 1,
70 PERF_COUNT_SW_PAGE_FAULTS = 2,
Tao Baod7db5942015-01-28 10:07:51 -080071 PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
72 PERF_COUNT_SW_CPU_MIGRATIONS = 4,
73 PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
74 PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
Tao Baod7db5942015-01-28 10:07:51 -080075 PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
76 PERF_COUNT_SW_EMULATION_FAULTS = 8,
77 PERF_COUNT_SW_DUMMY = 9,
Christopher Ferris05d08e92016-02-04 13:16:38 -080078 PERF_COUNT_SW_BPF_OUTPUT = 10,
Christopher Ferris05d08e92016-02-04 13:16:38 -080079 PERF_COUNT_SW_MAX,
Christopher Ferris38062f92014-07-09 15:33:25 -070080};
Ben Cheng655a7c02013-10-16 16:09:24 -070081enum perf_event_sample_format {
Tao Baod7db5942015-01-28 10:07:51 -080082 PERF_SAMPLE_IP = 1U << 0,
Christopher Ferris05d08e92016-02-04 13:16:38 -080083 PERF_SAMPLE_TID = 1U << 1,
Tao Baod7db5942015-01-28 10:07:51 -080084 PERF_SAMPLE_TIME = 1U << 2,
85 PERF_SAMPLE_ADDR = 1U << 3,
86 PERF_SAMPLE_READ = 1U << 4,
Christopher Ferris05d08e92016-02-04 13:16:38 -080087 PERF_SAMPLE_CALLCHAIN = 1U << 5,
Tao Baod7db5942015-01-28 10:07:51 -080088 PERF_SAMPLE_ID = 1U << 6,
89 PERF_SAMPLE_CPU = 1U << 7,
90 PERF_SAMPLE_PERIOD = 1U << 8,
Christopher Ferris05d08e92016-02-04 13:16:38 -080091 PERF_SAMPLE_STREAM_ID = 1U << 9,
Tao Baod7db5942015-01-28 10:07:51 -080092 PERF_SAMPLE_RAW = 1U << 10,
93 PERF_SAMPLE_BRANCH_STACK = 1U << 11,
94 PERF_SAMPLE_REGS_USER = 1U << 12,
Christopher Ferris05d08e92016-02-04 13:16:38 -080095 PERF_SAMPLE_STACK_USER = 1U << 13,
Tao Baod7db5942015-01-28 10:07:51 -080096 PERF_SAMPLE_WEIGHT = 1U << 14,
97 PERF_SAMPLE_DATA_SRC = 1U << 15,
98 PERF_SAMPLE_IDENTIFIER = 1U << 16,
Christopher Ferris05d08e92016-02-04 13:16:38 -080099 PERF_SAMPLE_TRANSACTION = 1U << 17,
100 PERF_SAMPLE_REGS_INTR = 1U << 18,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800101 PERF_SAMPLE_PHYS_ADDR = 1U << 19,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800102 PERF_SAMPLE_AUX = 1U << 20,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700103 PERF_SAMPLE_CGROUP = 1U << 21,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800104 PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22,
105 PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,
106 PERF_SAMPLE_MAX = 1U << 24,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700107 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800108};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800109enum perf_branch_sample_type_shift {
110 PERF_SAMPLE_BRANCH_USER_SHIFT = 0,
111 PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 1,
112 PERF_SAMPLE_BRANCH_HV_SHIFT = 2,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800113 PERF_SAMPLE_BRANCH_ANY_SHIFT = 3,
114 PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT = 4,
115 PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT = 5,
116 PERF_SAMPLE_BRANCH_IND_CALL_SHIFT = 6,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800117 PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT = 7,
118 PERF_SAMPLE_BRANCH_IN_TX_SHIFT = 8,
119 PERF_SAMPLE_BRANCH_NO_TX_SHIFT = 9,
120 PERF_SAMPLE_BRANCH_COND_SHIFT = 10,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121 PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11,
122 PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12,
123 PERF_SAMPLE_BRANCH_CALL_SHIFT = 13,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700124 PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700125 PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800126 PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700127 PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700128 PERF_SAMPLE_BRANCH_MAX_SHIFT
Ben Cheng655a7c02013-10-16 16:09:24 -0700129};
130enum perf_branch_sample_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800131 PERF_SAMPLE_BRANCH_USER = 1U << PERF_SAMPLE_BRANCH_USER_SHIFT,
132 PERF_SAMPLE_BRANCH_KERNEL = 1U << PERF_SAMPLE_BRANCH_KERNEL_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800133 PERF_SAMPLE_BRANCH_HV = 1U << PERF_SAMPLE_BRANCH_HV_SHIFT,
134 PERF_SAMPLE_BRANCH_ANY = 1U << PERF_SAMPLE_BRANCH_ANY_SHIFT,
135 PERF_SAMPLE_BRANCH_ANY_CALL = 1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT,
136 PERF_SAMPLE_BRANCH_ANY_RETURN = 1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800137 PERF_SAMPLE_BRANCH_IND_CALL = 1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT,
138 PERF_SAMPLE_BRANCH_ABORT_TX = 1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT,
139 PERF_SAMPLE_BRANCH_IN_TX = 1U << PERF_SAMPLE_BRANCH_IN_TX_SHIFT,
140 PERF_SAMPLE_BRANCH_NO_TX = 1U << PERF_SAMPLE_BRANCH_NO_TX_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800141 PERF_SAMPLE_BRANCH_COND = 1U << PERF_SAMPLE_BRANCH_COND_SHIFT,
142 PERF_SAMPLE_BRANCH_CALL_STACK = 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT,
143 PERF_SAMPLE_BRANCH_IND_JUMP = 1U << PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT,
144 PERF_SAMPLE_BRANCH_CALL = 1U << PERF_SAMPLE_BRANCH_CALL_SHIFT,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700145 PERF_SAMPLE_BRANCH_NO_FLAGS = 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT,
146 PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800147 PERF_SAMPLE_BRANCH_TYPE_SAVE = 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700148 PERF_SAMPLE_BRANCH_HW_INDEX = 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800149 PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
Ben Cheng655a7c02013-10-16 16:09:24 -0700150};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800151enum {
152 PERF_BR_UNKNOWN = 0,
153 PERF_BR_COND = 1,
154 PERF_BR_UNCOND = 2,
155 PERF_BR_IND = 3,
156 PERF_BR_CALL = 4,
157 PERF_BR_IND_CALL = 5,
158 PERF_BR_RET = 6,
159 PERF_BR_SYSCALL = 7,
160 PERF_BR_SYSRET = 8,
161 PERF_BR_COND_CALL = 9,
162 PERF_BR_COND_RET = 10,
163 PERF_BR_MAX,
164};
Tao Baod7db5942015-01-28 10:07:51 -0800165#define PERF_SAMPLE_BRANCH_PLM_ALL (PERF_SAMPLE_BRANCH_USER | PERF_SAMPLE_BRANCH_KERNEL | PERF_SAMPLE_BRANCH_HV)
Ben Cheng655a7c02013-10-16 16:09:24 -0700166enum perf_sample_regs_abi {
Tao Baod7db5942015-01-28 10:07:51 -0800167 PERF_SAMPLE_REGS_ABI_NONE = 0,
168 PERF_SAMPLE_REGS_ABI_32 = 1,
Tao Baod7db5942015-01-28 10:07:51 -0800169 PERF_SAMPLE_REGS_ABI_64 = 2,
Christopher Ferris38062f92014-07-09 15:33:25 -0700170};
171enum {
Tao Baod7db5942015-01-28 10:07:51 -0800172 PERF_TXN_ELISION = (1 << 0),
Tao Baod7db5942015-01-28 10:07:51 -0800173 PERF_TXN_TRANSACTION = (1 << 1),
174 PERF_TXN_SYNC = (1 << 2),
175 PERF_TXN_ASYNC = (1 << 3),
176 PERF_TXN_RETRY = (1 << 4),
Tao Baod7db5942015-01-28 10:07:51 -0800177 PERF_TXN_CONFLICT = (1 << 5),
178 PERF_TXN_CAPACITY_WRITE = (1 << 6),
179 PERF_TXN_CAPACITY_READ = (1 << 7),
180 PERF_TXN_MAX = (1 << 8),
Tao Baod7db5942015-01-28 10:07:51 -0800181 PERF_TXN_ABORT_MASK = (0xffffffffULL << 32),
182 PERF_TXN_ABORT_SHIFT = 32,
Ben Cheng655a7c02013-10-16 16:09:24 -0700183};
184enum perf_event_read_format {
Tao Baod7db5942015-01-28 10:07:51 -0800185 PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
186 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
187 PERF_FORMAT_ID = 1U << 2,
188 PERF_FORMAT_GROUP = 1U << 3,
Tao Baod7db5942015-01-28 10:07:51 -0800189 PERF_FORMAT_MAX = 1U << 4,
Ben Cheng655a7c02013-10-16 16:09:24 -0700190};
191#define PERF_ATTR_SIZE_VER0 64
192#define PERF_ATTR_SIZE_VER1 72
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700193#define PERF_ATTR_SIZE_VER2 80
Ben Cheng655a7c02013-10-16 16:09:24 -0700194#define PERF_ATTR_SIZE_VER3 96
Christopher Ferris05d08e92016-02-04 13:16:38 -0800195#define PERF_ATTR_SIZE_VER4 104
196#define PERF_ATTR_SIZE_VER5 112
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800197#define PERF_ATTR_SIZE_VER6 120
Ben Cheng655a7c02013-10-16 16:09:24 -0700198struct perf_event_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800199 __u32 type;
Tao Baod7db5942015-01-28 10:07:51 -0800200 __u32 size;
201 __u64 config;
202 union {
203 __u64 sample_period;
Tao Baod7db5942015-01-28 10:07:51 -0800204 __u64 sample_freq;
205 };
206 __u64 sample_type;
207 __u64 read_format;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700208 __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, write_backward : 1, namespaces : 1, ksymbol : 1, bpf_event : 1, aux_output : 1, cgroup : 1, text_poke : 1, __reserved_1 : 30;
Tao Baod7db5942015-01-28 10:07:51 -0800209 union {
210 __u32 wakeup_events;
211 __u32 wakeup_watermark;
Tao Baod7db5942015-01-28 10:07:51 -0800212 };
213 __u32 bp_type;
214 union {
215 __u64 bp_addr;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700216 __u64 kprobe_func;
217 __u64 uprobe_path;
Tao Baod7db5942015-01-28 10:07:51 -0800218 __u64 config1;
219 };
220 union {
221 __u64 bp_len;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700222 __u64 kprobe_addr;
223 __u64 probe_offset;
Tao Baod7db5942015-01-28 10:07:51 -0800224 __u64 config2;
225 };
226 __u64 branch_sample_type;
227 __u64 sample_regs_user;
Tao Baod7db5942015-01-28 10:07:51 -0800228 __u32 sample_stack_user;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800229 __s32 clockid;
230 __u64 sample_regs_intr;
231 __u32 aux_watermark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800232 __u16 sample_max_stack;
233 __u16 __reserved_2;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800234 __u32 aux_sample_size;
235 __u32 __reserved_3;
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800236};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700237struct perf_event_query_bpf {
238 __u32 ids_len;
239 __u32 prog_cnt;
240 __u32 ids[0];
241};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800242#define PERF_EVENT_IOC_ENABLE _IO('$', 0)
Tao Baod7db5942015-01-28 10:07:51 -0800243#define PERF_EVENT_IOC_DISABLE _IO('$', 1)
244#define PERF_EVENT_IOC_REFRESH _IO('$', 2)
245#define PERF_EVENT_IOC_RESET _IO('$', 3)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800246#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
Tao Baod7db5942015-01-28 10:07:51 -0800247#define PERF_EVENT_IOC_SET_OUTPUT _IO('$', 5)
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800248#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
Christopher Ferris38062f92014-07-09 15:33:25 -0700249#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800250#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700251#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700252#define PERF_EVENT_IOC_QUERY_BPF _IOWR('$', 10, struct perf_event_query_bpf *)
253#define PERF_EVENT_IOC_MODIFY_ATTRIBUTES _IOW('$', 11, struct perf_event_attr *)
Ben Cheng655a7c02013-10-16 16:09:24 -0700254enum perf_event_ioc_flags {
Tao Baod7db5942015-01-28 10:07:51 -0800255 PERF_IOC_FLAG_GROUP = 1U << 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800256};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700257struct perf_event_mmap_page {
Tao Baod7db5942015-01-28 10:07:51 -0800258 __u32 version;
259 __u32 compat_version;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800260 __u32 lock;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700261 __u32 index;
Tao Baod7db5942015-01-28 10:07:51 -0800262 __s64 offset;
263 __u64 time_enabled;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800264 __u64 time_running;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700265 union {
Tao Baod7db5942015-01-28 10:07:51 -0800266 __u64 capabilities;
267 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700268 __u64 cap_bit0 : 1, cap_bit0_is_deprecated : 1, cap_user_rdpmc : 1, cap_user_time : 1, cap_user_time_zero : 1, cap_user_time_short : 1, cap_____res : 58;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700269 };
Tao Baod7db5942015-01-28 10:07:51 -0800270 };
271 __u16 pmc_width;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800272 __u16 time_shift;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700273 __u32 time_mult;
Tao Baod7db5942015-01-28 10:07:51 -0800274 __u64 time_offset;
275 __u64 time_zero;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800276 __u32 size;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700277 __u32 __reserved_1;
278 __u64 time_cycles;
279 __u64 time_mask;
280 __u8 __reserved[116 * 8];
Tao Baod7db5942015-01-28 10:07:51 -0800281 __u64 data_head;
282 __u64 data_tail;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800283 __u64 data_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700284 __u64 data_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800285 __u64 aux_head;
286 __u64 aux_tail;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800287 __u64 aux_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700288 __u64 aux_size;
Ben Cheng655a7c02013-10-16 16:09:24 -0700289};
290#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800291#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700292#define PERF_RECORD_MISC_KERNEL (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700293#define PERF_RECORD_MISC_USER (2 << 0)
294#define PERF_RECORD_MISC_HYPERVISOR (3 << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800295#define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700296#define PERF_RECORD_MISC_GUEST_USER (5 << 0)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800297#define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12)
Ben Cheng655a7c02013-10-16 16:09:24 -0700298#define PERF_RECORD_MISC_MMAP_DATA (1 << 13)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800299#define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
Christopher Ferris86a48372019-01-10 14:14:59 -0800300#define PERF_RECORD_MISC_FORK_EXEC (1 << 13)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700301#define PERF_RECORD_MISC_SWITCH_OUT (1 << 13)
Ben Cheng655a7c02013-10-16 16:09:24 -0700302#define PERF_RECORD_MISC_EXACT_IP (1 << 14)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700303#define PERF_RECORD_MISC_SWITCH_OUT_PREEMPT (1 << 14)
Ben Cheng655a7c02013-10-16 16:09:24 -0700304#define PERF_RECORD_MISC_EXT_RESERVED (1 << 15)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800305struct perf_event_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700306 __u32 type;
Tao Baod7db5942015-01-28 10:07:51 -0800307 __u16 misc;
308 __u16 size;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800309};
Christopher Ferris525ce912017-07-26 13:12:53 -0700310struct perf_ns_link_info {
311 __u64 dev;
312 __u64 ino;
313};
314enum {
315 NET_NS_INDEX = 0,
316 UTS_NS_INDEX = 1,
317 IPC_NS_INDEX = 2,
318 PID_NS_INDEX = 3,
319 USER_NS_INDEX = 4,
320 MNT_NS_INDEX = 5,
321 CGROUP_NS_INDEX = 6,
322 NR_NAMESPACES,
323};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700324enum perf_event_type {
Tao Baod7db5942015-01-28 10:07:51 -0800325 PERF_RECORD_MMAP = 1,
326 PERF_RECORD_LOST = 2,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800327 PERF_RECORD_COMM = 3,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700328 PERF_RECORD_EXIT = 4,
Tao Baod7db5942015-01-28 10:07:51 -0800329 PERF_RECORD_THROTTLE = 5,
330 PERF_RECORD_UNTHROTTLE = 6,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800331 PERF_RECORD_FORK = 7,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700332 PERF_RECORD_READ = 8,
Tao Baod7db5942015-01-28 10:07:51 -0800333 PERF_RECORD_SAMPLE = 9,
334 PERF_RECORD_MMAP2 = 10,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800335 PERF_RECORD_AUX = 11,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700336 PERF_RECORD_ITRACE_START = 12,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800337 PERF_RECORD_LOST_SAMPLES = 13,
338 PERF_RECORD_SWITCH = 14,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800339 PERF_RECORD_SWITCH_CPU_WIDE = 15,
Christopher Ferris525ce912017-07-26 13:12:53 -0700340 PERF_RECORD_NAMESPACES = 16,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700341 PERF_RECORD_KSYMBOL = 17,
342 PERF_RECORD_BPF_EVENT = 18,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700343 PERF_RECORD_CGROUP = 19,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700344 PERF_RECORD_TEXT_POKE = 20,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700345 PERF_RECORD_MAX,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800346};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700347enum perf_record_ksymbol_type {
348 PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0,
349 PERF_RECORD_KSYMBOL_TYPE_BPF = 1,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700350 PERF_RECORD_KSYMBOL_TYPE_OOL = 2,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700351 PERF_RECORD_KSYMBOL_TYPE_MAX
352};
353#define PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER (1 << 0)
354enum perf_bpf_event_type {
355 PERF_BPF_EVENT_UNKNOWN = 0,
356 PERF_BPF_EVENT_PROG_LOAD = 1,
357 PERF_BPF_EVENT_PROG_UNLOAD = 2,
358 PERF_BPF_EVENT_MAX,
359};
Ben Cheng655a7c02013-10-16 16:09:24 -0700360#define PERF_MAX_STACK_DEPTH 127
Christopher Ferris49f525c2016-12-12 14:55:36 -0800361#define PERF_MAX_CONTEXTS_PER_STACK 8
Ben Cheng655a7c02013-10-16 16:09:24 -0700362enum perf_callchain_context {
Tao Baod7db5942015-01-28 10:07:51 -0800363 PERF_CONTEXT_HV = (__u64) - 32,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800364 PERF_CONTEXT_KERNEL = (__u64) - 128,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800365 PERF_CONTEXT_USER = (__u64) - 512,
Tao Baod7db5942015-01-28 10:07:51 -0800366 PERF_CONTEXT_GUEST = (__u64) - 2048,
367 PERF_CONTEXT_GUEST_KERNEL = (__u64) - 2176,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800368 PERF_CONTEXT_GUEST_USER = (__u64) - 2560,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800369 PERF_CONTEXT_MAX = (__u64) - 4095,
Ben Cheng655a7c02013-10-16 16:09:24 -0700370};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800371#define PERF_AUX_FLAG_TRUNCATED 0x01
Christopher Ferris05d08e92016-02-04 13:16:38 -0800372#define PERF_AUX_FLAG_OVERWRITE 0x02
Christopher Ferris525ce912017-07-26 13:12:53 -0700373#define PERF_AUX_FLAG_PARTIAL 0x04
Christopher Ferris934ec942018-01-31 15:29:16 -0800374#define PERF_AUX_FLAG_COLLISION 0x08
Christopher Ferris49f525c2016-12-12 14:55:36 -0800375#define PERF_FLAG_FD_NO_GROUP (1UL << 0)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700376#define PERF_FLAG_FD_OUTPUT (1UL << 1)
377#define PERF_FLAG_PID_CGROUP (1UL << 2)
378#define PERF_FLAG_FD_CLOEXEC (1UL << 3)
Christopher Ferris525ce912017-07-26 13:12:53 -0700379#ifdef __LITTLE_ENDIAN_BITFIELD
Christopher Ferris49f525c2016-12-12 14:55:36 -0800380union perf_mem_data_src {
Tao Baod7db5942015-01-28 10:07:51 -0800381 __u64 val;
Tao Baod7db5942015-01-28 10:07:51 -0800382 struct {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800383 __u64 mem_op : 5, mem_lvl : 14, mem_snoop : 5, mem_lock : 2, mem_dtlb : 7, mem_lvl_num : 4, mem_remote : 1, mem_snoopx : 2, mem_rsvd : 24;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800384 };
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800385};
Christopher Ferris525ce912017-07-26 13:12:53 -0700386#elif defined(__BIG_ENDIAN_BITFIELD)
387union perf_mem_data_src {
388 __u64 val;
389 struct {
Christopher Ferris1308ad32017-11-14 17:32:13 -0800390 __u64 mem_rsvd : 24, mem_snoopx : 2, mem_remote : 1, mem_lvl_num : 4, mem_dtlb : 7, mem_lock : 2, mem_snoop : 5, mem_lvl : 14, mem_op : 5;
Christopher Ferris525ce912017-07-26 13:12:53 -0700391 };
392};
393#else
394#error "Unknown endianness"
395#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700396#define PERF_MEM_OP_NA 0x01
397#define PERF_MEM_OP_LOAD 0x02
Christopher Ferris49f525c2016-12-12 14:55:36 -0800398#define PERF_MEM_OP_STORE 0x04
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800399#define PERF_MEM_OP_PFETCH 0x08
Ben Cheng655a7c02013-10-16 16:09:24 -0700400#define PERF_MEM_OP_EXEC 0x10
401#define PERF_MEM_OP_SHIFT 0
Christopher Ferris49f525c2016-12-12 14:55:36 -0800402#define PERF_MEM_LVL_NA 0x01
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800403#define PERF_MEM_LVL_HIT 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -0700404#define PERF_MEM_LVL_MISS 0x04
405#define PERF_MEM_LVL_L1 0x08
Christopher Ferris49f525c2016-12-12 14:55:36 -0800406#define PERF_MEM_LVL_LFB 0x10
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800407#define PERF_MEM_LVL_L2 0x20
Ben Cheng655a7c02013-10-16 16:09:24 -0700408#define PERF_MEM_LVL_L3 0x40
409#define PERF_MEM_LVL_LOC_RAM 0x80
Christopher Ferris49f525c2016-12-12 14:55:36 -0800410#define PERF_MEM_LVL_REM_RAM1 0x100
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800411#define PERF_MEM_LVL_REM_RAM2 0x200
Ben Cheng655a7c02013-10-16 16:09:24 -0700412#define PERF_MEM_LVL_REM_CCE1 0x400
413#define PERF_MEM_LVL_REM_CCE2 0x800
Christopher Ferris49f525c2016-12-12 14:55:36 -0800414#define PERF_MEM_LVL_IO 0x1000
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800415#define PERF_MEM_LVL_UNC 0x2000
Ben Cheng655a7c02013-10-16 16:09:24 -0700416#define PERF_MEM_LVL_SHIFT 5
Christopher Ferris1308ad32017-11-14 17:32:13 -0800417#define PERF_MEM_REMOTE_REMOTE 0x01
418#define PERF_MEM_REMOTE_SHIFT 37
419#define PERF_MEM_LVLNUM_L1 0x01
420#define PERF_MEM_LVLNUM_L2 0x02
421#define PERF_MEM_LVLNUM_L3 0x03
422#define PERF_MEM_LVLNUM_L4 0x04
423#define PERF_MEM_LVLNUM_ANY_CACHE 0x0b
424#define PERF_MEM_LVLNUM_LFB 0x0c
425#define PERF_MEM_LVLNUM_RAM 0x0d
426#define PERF_MEM_LVLNUM_PMEM 0x0e
427#define PERF_MEM_LVLNUM_NA 0x0f
428#define PERF_MEM_LVLNUM_SHIFT 33
Ben Cheng655a7c02013-10-16 16:09:24 -0700429#define PERF_MEM_SNOOP_NA 0x01
Christopher Ferris49f525c2016-12-12 14:55:36 -0800430#define PERF_MEM_SNOOP_NONE 0x02
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800431#define PERF_MEM_SNOOP_HIT 0x04
Ben Cheng655a7c02013-10-16 16:09:24 -0700432#define PERF_MEM_SNOOP_MISS 0x08
433#define PERF_MEM_SNOOP_HITM 0x10
Christopher Ferris49f525c2016-12-12 14:55:36 -0800434#define PERF_MEM_SNOOP_SHIFT 19
Christopher Ferris1308ad32017-11-14 17:32:13 -0800435#define PERF_MEM_SNOOPX_FWD 0x01
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800436#define PERF_MEM_SNOOPX_SHIFT 38
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800437#define PERF_MEM_LOCK_NA 0x01
Ben Cheng655a7c02013-10-16 16:09:24 -0700438#define PERF_MEM_LOCK_LOCKED 0x02
439#define PERF_MEM_LOCK_SHIFT 24
Christopher Ferris49f525c2016-12-12 14:55:36 -0800440#define PERF_MEM_TLB_NA 0x01
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800441#define PERF_MEM_TLB_HIT 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -0700442#define PERF_MEM_TLB_MISS 0x04
443#define PERF_MEM_TLB_L1 0x08
Christopher Ferris49f525c2016-12-12 14:55:36 -0800444#define PERF_MEM_TLB_L2 0x10
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800445#define PERF_MEM_TLB_WK 0x20
Ben Cheng655a7c02013-10-16 16:09:24 -0700446#define PERF_MEM_TLB_OS 0x40
Christopher Ferris38062f92014-07-09 15:33:25 -0700447#define PERF_MEM_TLB_SHIFT 26
Christopher Ferris49f525c2016-12-12 14:55:36 -0800448#define PERF_MEM_S(a,s) (((__u64) PERF_MEM_ ##a ##_ ##s) << PERF_MEM_ ##a ##_SHIFT)
Christopher Ferris38062f92014-07-09 15:33:25 -0700449struct perf_branch_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800450 __u64 from;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800451 __u64 to;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800452 __u64 mispred : 1, predicted : 1, in_tx : 1, abort : 1, cycles : 16, type : 4, reserved : 40;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800453};
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800454#endif