blob: 16a1a2e3d6e49fdddb231d5fad988637fdfc0a4a [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef _UAPI_LINUX_PERF_EVENT_H
8#define _UAPI_LINUX_PERF_EVENT_H
9#include <linux/types.h>
10#include <linux/ioctl.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070011#include <asm/byteorder.h>
12enum perf_type_id {
Tao Baod7db5942015-01-28 10:07:51 -080013 PERF_TYPE_HARDWARE = 0,
14 PERF_TYPE_SOFTWARE = 1,
Tao Baod7db5942015-01-28 10:07:51 -080015 PERF_TYPE_TRACEPOINT = 2,
16 PERF_TYPE_HW_CACHE = 3,
17 PERF_TYPE_RAW = 4,
18 PERF_TYPE_BREAKPOINT = 5,
Tao Baod7db5942015-01-28 10:07:51 -080019 PERF_TYPE_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070020};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +000021#define PERF_PMU_TYPE_SHIFT 32
22#define PERF_HW_EVENT_MASK 0xffffffff
Ben Cheng655a7c02013-10-16 16:09:24 -070023enum perf_hw_id {
Tao Baod7db5942015-01-28 10:07:51 -080024 PERF_COUNT_HW_CPU_CYCLES = 0,
Tao Baod7db5942015-01-28 10:07:51 -080025 PERF_COUNT_HW_INSTRUCTIONS = 1,
26 PERF_COUNT_HW_CACHE_REFERENCES = 2,
27 PERF_COUNT_HW_CACHE_MISSES = 3,
28 PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4,
Tao Baod7db5942015-01-28 10:07:51 -080029 PERF_COUNT_HW_BRANCH_MISSES = 5,
30 PERF_COUNT_HW_BUS_CYCLES = 6,
31 PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
32 PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
Tao Baod7db5942015-01-28 10:07:51 -080033 PERF_COUNT_HW_REF_CPU_CYCLES = 9,
34 PERF_COUNT_HW_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070035};
36enum perf_hw_cache_id {
Tao Baod7db5942015-01-28 10:07:51 -080037 PERF_COUNT_HW_CACHE_L1D = 0,
38 PERF_COUNT_HW_CACHE_L1I = 1,
39 PERF_COUNT_HW_CACHE_LL = 2,
40 PERF_COUNT_HW_CACHE_DTLB = 3,
Tao Baod7db5942015-01-28 10:07:51 -080041 PERF_COUNT_HW_CACHE_ITLB = 4,
42 PERF_COUNT_HW_CACHE_BPU = 5,
43 PERF_COUNT_HW_CACHE_NODE = 6,
44 PERF_COUNT_HW_CACHE_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070045};
46enum perf_hw_cache_op_id {
Tao Baod7db5942015-01-28 10:07:51 -080047 PERF_COUNT_HW_CACHE_OP_READ = 0,
48 PERF_COUNT_HW_CACHE_OP_WRITE = 1,
Tao Baod7db5942015-01-28 10:07:51 -080049 PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
50 PERF_COUNT_HW_CACHE_OP_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070051};
52enum perf_hw_cache_op_result_id {
Tao Baod7db5942015-01-28 10:07:51 -080053 PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
54 PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
55 PERF_COUNT_HW_CACHE_RESULT_MAX,
Ben Cheng655a7c02013-10-16 16:09:24 -070056};
Ben Cheng655a7c02013-10-16 16:09:24 -070057enum perf_sw_ids {
Tao Baod7db5942015-01-28 10:07:51 -080058 PERF_COUNT_SW_CPU_CLOCK = 0,
59 PERF_COUNT_SW_TASK_CLOCK = 1,
60 PERF_COUNT_SW_PAGE_FAULTS = 2,
Tao Baod7db5942015-01-28 10:07:51 -080061 PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
62 PERF_COUNT_SW_CPU_MIGRATIONS = 4,
63 PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
64 PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
Tao Baod7db5942015-01-28 10:07:51 -080065 PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
66 PERF_COUNT_SW_EMULATION_FAULTS = 8,
67 PERF_COUNT_SW_DUMMY = 9,
Christopher Ferris05d08e92016-02-04 13:16:38 -080068 PERF_COUNT_SW_BPF_OUTPUT = 10,
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +000069 PERF_COUNT_SW_CGROUP_SWITCHES = 11,
Christopher Ferris05d08e92016-02-04 13:16:38 -080070 PERF_COUNT_SW_MAX,
Christopher Ferris38062f92014-07-09 15:33:25 -070071};
Ben Cheng655a7c02013-10-16 16:09:24 -070072enum perf_event_sample_format {
Tao Baod7db5942015-01-28 10:07:51 -080073 PERF_SAMPLE_IP = 1U << 0,
Christopher Ferris05d08e92016-02-04 13:16:38 -080074 PERF_SAMPLE_TID = 1U << 1,
Tao Baod7db5942015-01-28 10:07:51 -080075 PERF_SAMPLE_TIME = 1U << 2,
76 PERF_SAMPLE_ADDR = 1U << 3,
77 PERF_SAMPLE_READ = 1U << 4,
Christopher Ferris05d08e92016-02-04 13:16:38 -080078 PERF_SAMPLE_CALLCHAIN = 1U << 5,
Tao Baod7db5942015-01-28 10:07:51 -080079 PERF_SAMPLE_ID = 1U << 6,
80 PERF_SAMPLE_CPU = 1U << 7,
81 PERF_SAMPLE_PERIOD = 1U << 8,
Christopher Ferris05d08e92016-02-04 13:16:38 -080082 PERF_SAMPLE_STREAM_ID = 1U << 9,
Tao Baod7db5942015-01-28 10:07:51 -080083 PERF_SAMPLE_RAW = 1U << 10,
84 PERF_SAMPLE_BRANCH_STACK = 1U << 11,
85 PERF_SAMPLE_REGS_USER = 1U << 12,
Christopher Ferris05d08e92016-02-04 13:16:38 -080086 PERF_SAMPLE_STACK_USER = 1U << 13,
Tao Baod7db5942015-01-28 10:07:51 -080087 PERF_SAMPLE_WEIGHT = 1U << 14,
88 PERF_SAMPLE_DATA_SRC = 1U << 15,
89 PERF_SAMPLE_IDENTIFIER = 1U << 16,
Christopher Ferris05d08e92016-02-04 13:16:38 -080090 PERF_SAMPLE_TRANSACTION = 1U << 17,
91 PERF_SAMPLE_REGS_INTR = 1U << 18,
Christopher Ferris1308ad32017-11-14 17:32:13 -080092 PERF_SAMPLE_PHYS_ADDR = 1U << 19,
Christopher Ferrisd32ca142020-02-04 16:16:51 -080093 PERF_SAMPLE_AUX = 1U << 20,
Christopher Ferrisaf09c702020-06-01 20:29:29 -070094 PERF_SAMPLE_CGROUP = 1U << 21,
Christopher Ferris05667cd2021-02-16 16:01:34 -080095 PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22,
96 PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070097 PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24,
98 PERF_SAMPLE_MAX = 1U << 25,
Christopher Ferris05d08e92016-02-04 13:16:38 -080099};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700100#define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800101enum perf_branch_sample_type_shift {
102 PERF_SAMPLE_BRANCH_USER_SHIFT = 0,
103 PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 1,
104 PERF_SAMPLE_BRANCH_HV_SHIFT = 2,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800105 PERF_SAMPLE_BRANCH_ANY_SHIFT = 3,
106 PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT = 4,
107 PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT = 5,
108 PERF_SAMPLE_BRANCH_IND_CALL_SHIFT = 6,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800109 PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT = 7,
110 PERF_SAMPLE_BRANCH_IN_TX_SHIFT = 8,
111 PERF_SAMPLE_BRANCH_NO_TX_SHIFT = 9,
112 PERF_SAMPLE_BRANCH_COND_SHIFT = 10,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800113 PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11,
114 PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12,
115 PERF_SAMPLE_BRANCH_CALL_SHIFT = 13,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700116 PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700117 PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800118 PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700119 PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000120 PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT = 18,
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700121 PERF_SAMPLE_BRANCH_COUNTERS_SHIFT = 19,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700122 PERF_SAMPLE_BRANCH_MAX_SHIFT
Ben Cheng655a7c02013-10-16 16:09:24 -0700123};
124enum perf_branch_sample_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800125 PERF_SAMPLE_BRANCH_USER = 1U << PERF_SAMPLE_BRANCH_USER_SHIFT,
126 PERF_SAMPLE_BRANCH_KERNEL = 1U << PERF_SAMPLE_BRANCH_KERNEL_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800127 PERF_SAMPLE_BRANCH_HV = 1U << PERF_SAMPLE_BRANCH_HV_SHIFT,
128 PERF_SAMPLE_BRANCH_ANY = 1U << PERF_SAMPLE_BRANCH_ANY_SHIFT,
129 PERF_SAMPLE_BRANCH_ANY_CALL = 1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT,
130 PERF_SAMPLE_BRANCH_ANY_RETURN = 1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800131 PERF_SAMPLE_BRANCH_IND_CALL = 1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT,
132 PERF_SAMPLE_BRANCH_ABORT_TX = 1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT,
133 PERF_SAMPLE_BRANCH_IN_TX = 1U << PERF_SAMPLE_BRANCH_IN_TX_SHIFT,
134 PERF_SAMPLE_BRANCH_NO_TX = 1U << PERF_SAMPLE_BRANCH_NO_TX_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800135 PERF_SAMPLE_BRANCH_COND = 1U << PERF_SAMPLE_BRANCH_COND_SHIFT,
136 PERF_SAMPLE_BRANCH_CALL_STACK = 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT,
137 PERF_SAMPLE_BRANCH_IND_JUMP = 1U << PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT,
138 PERF_SAMPLE_BRANCH_CALL = 1U << PERF_SAMPLE_BRANCH_CALL_SHIFT,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700139 PERF_SAMPLE_BRANCH_NO_FLAGS = 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT,
140 PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800141 PERF_SAMPLE_BRANCH_TYPE_SAVE = 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700142 PERF_SAMPLE_BRANCH_HW_INDEX = 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000143 PERF_SAMPLE_BRANCH_PRIV_SAVE = 1U << PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT,
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700144 PERF_SAMPLE_BRANCH_COUNTERS = 1U << PERF_SAMPLE_BRANCH_COUNTERS_SHIFT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800145 PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
Ben Cheng655a7c02013-10-16 16:09:24 -0700146};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800147enum {
148 PERF_BR_UNKNOWN = 0,
149 PERF_BR_COND = 1,
150 PERF_BR_UNCOND = 2,
151 PERF_BR_IND = 3,
152 PERF_BR_CALL = 4,
153 PERF_BR_IND_CALL = 5,
154 PERF_BR_RET = 6,
155 PERF_BR_SYSCALL = 7,
156 PERF_BR_SYSRET = 8,
157 PERF_BR_COND_CALL = 9,
158 PERF_BR_COND_RET = 10,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700159 PERF_BR_ERET = 11,
160 PERF_BR_IRQ = 12,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000161 PERF_BR_SERROR = 13,
162 PERF_BR_NO_TX = 14,
163 PERF_BR_EXTEND_ABI = 15,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800164 PERF_BR_MAX,
165};
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000166enum {
167 PERF_BR_SPEC_NA = 0,
168 PERF_BR_SPEC_WRONG_PATH = 1,
169 PERF_BR_NON_SPEC_CORRECT_PATH = 2,
170 PERF_BR_SPEC_CORRECT_PATH = 3,
171 PERF_BR_SPEC_MAX,
172};
173enum {
174 PERF_BR_NEW_FAULT_ALGN = 0,
175 PERF_BR_NEW_FAULT_DATA = 1,
176 PERF_BR_NEW_FAULT_INST = 2,
177 PERF_BR_NEW_ARCH_1 = 3,
178 PERF_BR_NEW_ARCH_2 = 4,
179 PERF_BR_NEW_ARCH_3 = 5,
180 PERF_BR_NEW_ARCH_4 = 6,
181 PERF_BR_NEW_ARCH_5 = 7,
182 PERF_BR_NEW_MAX,
183};
184enum {
185 PERF_BR_PRIV_UNKNOWN = 0,
186 PERF_BR_PRIV_USER = 1,
187 PERF_BR_PRIV_KERNEL = 2,
188 PERF_BR_PRIV_HV = 3,
189};
190#define PERF_BR_ARM64_FIQ PERF_BR_NEW_ARCH_1
191#define PERF_BR_ARM64_DEBUG_HALT PERF_BR_NEW_ARCH_2
192#define PERF_BR_ARM64_DEBUG_EXIT PERF_BR_NEW_ARCH_3
193#define PERF_BR_ARM64_DEBUG_INST PERF_BR_NEW_ARCH_4
194#define PERF_BR_ARM64_DEBUG_DATA PERF_BR_NEW_ARCH_5
Tao Baod7db5942015-01-28 10:07:51 -0800195#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 -0700196enum perf_sample_regs_abi {
Tao Baod7db5942015-01-28 10:07:51 -0800197 PERF_SAMPLE_REGS_ABI_NONE = 0,
198 PERF_SAMPLE_REGS_ABI_32 = 1,
Tao Baod7db5942015-01-28 10:07:51 -0800199 PERF_SAMPLE_REGS_ABI_64 = 2,
Christopher Ferris38062f92014-07-09 15:33:25 -0700200};
201enum {
Tao Baod7db5942015-01-28 10:07:51 -0800202 PERF_TXN_ELISION = (1 << 0),
Tao Baod7db5942015-01-28 10:07:51 -0800203 PERF_TXN_TRANSACTION = (1 << 1),
204 PERF_TXN_SYNC = (1 << 2),
205 PERF_TXN_ASYNC = (1 << 3),
206 PERF_TXN_RETRY = (1 << 4),
Tao Baod7db5942015-01-28 10:07:51 -0800207 PERF_TXN_CONFLICT = (1 << 5),
208 PERF_TXN_CAPACITY_WRITE = (1 << 6),
209 PERF_TXN_CAPACITY_READ = (1 << 7),
210 PERF_TXN_MAX = (1 << 8),
Tao Baod7db5942015-01-28 10:07:51 -0800211 PERF_TXN_ABORT_MASK = (0xffffffffULL << 32),
212 PERF_TXN_ABORT_SHIFT = 32,
Ben Cheng655a7c02013-10-16 16:09:24 -0700213};
214enum perf_event_read_format {
Tao Baod7db5942015-01-28 10:07:51 -0800215 PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
216 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
217 PERF_FORMAT_ID = 1U << 2,
218 PERF_FORMAT_GROUP = 1U << 3,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700219 PERF_FORMAT_LOST = 1U << 4,
220 PERF_FORMAT_MAX = 1U << 5,
Ben Cheng655a7c02013-10-16 16:09:24 -0700221};
222#define PERF_ATTR_SIZE_VER0 64
223#define PERF_ATTR_SIZE_VER1 72
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700224#define PERF_ATTR_SIZE_VER2 80
Ben Cheng655a7c02013-10-16 16:09:24 -0700225#define PERF_ATTR_SIZE_VER3 96
Christopher Ferris05d08e92016-02-04 13:16:38 -0800226#define PERF_ATTR_SIZE_VER4 104
227#define PERF_ATTR_SIZE_VER5 112
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800228#define PERF_ATTR_SIZE_VER6 120
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000229#define PERF_ATTR_SIZE_VER7 128
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000230#define PERF_ATTR_SIZE_VER8 136
Ben Cheng655a7c02013-10-16 16:09:24 -0700231struct perf_event_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800232 __u32 type;
Tao Baod7db5942015-01-28 10:07:51 -0800233 __u32 size;
234 __u64 config;
235 union {
236 __u64 sample_period;
Tao Baod7db5942015-01-28 10:07:51 -0800237 __u64 sample_freq;
238 };
239 __u64 sample_type;
240 __u64 read_format;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000241 __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, build_id : 1, inherit_thread : 1, remove_on_exec : 1, sigtrap : 1, __reserved_1 : 26;
Tao Baod7db5942015-01-28 10:07:51 -0800242 union {
243 __u32 wakeup_events;
244 __u32 wakeup_watermark;
Tao Baod7db5942015-01-28 10:07:51 -0800245 };
246 __u32 bp_type;
247 union {
248 __u64 bp_addr;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700249 __u64 kprobe_func;
250 __u64 uprobe_path;
Tao Baod7db5942015-01-28 10:07:51 -0800251 __u64 config1;
252 };
253 union {
254 __u64 bp_len;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700255 __u64 kprobe_addr;
256 __u64 probe_offset;
Tao Baod7db5942015-01-28 10:07:51 -0800257 __u64 config2;
258 };
259 __u64 branch_sample_type;
260 __u64 sample_regs_user;
Tao Baod7db5942015-01-28 10:07:51 -0800261 __u32 sample_stack_user;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800262 __s32 clockid;
263 __u64 sample_regs_intr;
264 __u32 aux_watermark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800265 __u16 sample_max_stack;
266 __u16 __reserved_2;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800267 __u32 aux_sample_size;
268 __u32 __reserved_3;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000269 __u64 sig_data;
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000270 __u64 config3;
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800271};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700272struct perf_event_query_bpf {
273 __u32 ids_len;
274 __u32 prog_cnt;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700275 __u32 ids[];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700276};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800277#define PERF_EVENT_IOC_ENABLE _IO('$', 0)
Tao Baod7db5942015-01-28 10:07:51 -0800278#define PERF_EVENT_IOC_DISABLE _IO('$', 1)
279#define PERF_EVENT_IOC_REFRESH _IO('$', 2)
280#define PERF_EVENT_IOC_RESET _IO('$', 3)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800281#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
Tao Baod7db5942015-01-28 10:07:51 -0800282#define PERF_EVENT_IOC_SET_OUTPUT _IO('$', 5)
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800283#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
Christopher Ferris38062f92014-07-09 15:33:25 -0700284#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800285#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700286#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700287#define PERF_EVENT_IOC_QUERY_BPF _IOWR('$', 10, struct perf_event_query_bpf *)
288#define PERF_EVENT_IOC_MODIFY_ATTRIBUTES _IOW('$', 11, struct perf_event_attr *)
Ben Cheng655a7c02013-10-16 16:09:24 -0700289enum perf_event_ioc_flags {
Tao Baod7db5942015-01-28 10:07:51 -0800290 PERF_IOC_FLAG_GROUP = 1U << 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800291};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700292struct perf_event_mmap_page {
Tao Baod7db5942015-01-28 10:07:51 -0800293 __u32 version;
294 __u32 compat_version;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800295 __u32 lock;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700296 __u32 index;
Tao Baod7db5942015-01-28 10:07:51 -0800297 __s64 offset;
298 __u64 time_enabled;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800299 __u64 time_running;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700300 union {
Tao Baod7db5942015-01-28 10:07:51 -0800301 __u64 capabilities;
302 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700303 __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 -0700304 };
Tao Baod7db5942015-01-28 10:07:51 -0800305 };
306 __u16 pmc_width;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800307 __u16 time_shift;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700308 __u32 time_mult;
Tao Baod7db5942015-01-28 10:07:51 -0800309 __u64 time_offset;
310 __u64 time_zero;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800311 __u32 size;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700312 __u32 __reserved_1;
313 __u64 time_cycles;
314 __u64 time_mask;
315 __u8 __reserved[116 * 8];
Tao Baod7db5942015-01-28 10:07:51 -0800316 __u64 data_head;
317 __u64 data_tail;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800318 __u64 data_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700319 __u64 data_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800320 __u64 aux_head;
321 __u64 aux_tail;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800322 __u64 aux_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700323 __u64 aux_size;
Ben Cheng655a7c02013-10-16 16:09:24 -0700324};
325#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800326#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700327#define PERF_RECORD_MISC_KERNEL (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700328#define PERF_RECORD_MISC_USER (2 << 0)
329#define PERF_RECORD_MISC_HYPERVISOR (3 << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800330#define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700331#define PERF_RECORD_MISC_GUEST_USER (5 << 0)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800332#define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12)
Ben Cheng655a7c02013-10-16 16:09:24 -0700333#define PERF_RECORD_MISC_MMAP_DATA (1 << 13)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800334#define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
Christopher Ferris86a48372019-01-10 14:14:59 -0800335#define PERF_RECORD_MISC_FORK_EXEC (1 << 13)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700336#define PERF_RECORD_MISC_SWITCH_OUT (1 << 13)
Ben Cheng655a7c02013-10-16 16:09:24 -0700337#define PERF_RECORD_MISC_EXACT_IP (1 << 14)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700338#define PERF_RECORD_MISC_SWITCH_OUT_PREEMPT (1 << 14)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700339#define PERF_RECORD_MISC_MMAP_BUILD_ID (1 << 14)
Ben Cheng655a7c02013-10-16 16:09:24 -0700340#define PERF_RECORD_MISC_EXT_RESERVED (1 << 15)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800341struct perf_event_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700342 __u32 type;
Tao Baod7db5942015-01-28 10:07:51 -0800343 __u16 misc;
344 __u16 size;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800345};
Christopher Ferris525ce912017-07-26 13:12:53 -0700346struct perf_ns_link_info {
347 __u64 dev;
348 __u64 ino;
349};
350enum {
351 NET_NS_INDEX = 0,
352 UTS_NS_INDEX = 1,
353 IPC_NS_INDEX = 2,
354 PID_NS_INDEX = 3,
355 USER_NS_INDEX = 4,
356 MNT_NS_INDEX = 5,
357 CGROUP_NS_INDEX = 6,
358 NR_NAMESPACES,
359};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700360enum perf_event_type {
Tao Baod7db5942015-01-28 10:07:51 -0800361 PERF_RECORD_MMAP = 1,
362 PERF_RECORD_LOST = 2,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800363 PERF_RECORD_COMM = 3,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700364 PERF_RECORD_EXIT = 4,
Tao Baod7db5942015-01-28 10:07:51 -0800365 PERF_RECORD_THROTTLE = 5,
366 PERF_RECORD_UNTHROTTLE = 6,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800367 PERF_RECORD_FORK = 7,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700368 PERF_RECORD_READ = 8,
Tao Baod7db5942015-01-28 10:07:51 -0800369 PERF_RECORD_SAMPLE = 9,
370 PERF_RECORD_MMAP2 = 10,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800371 PERF_RECORD_AUX = 11,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700372 PERF_RECORD_ITRACE_START = 12,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800373 PERF_RECORD_LOST_SAMPLES = 13,
374 PERF_RECORD_SWITCH = 14,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800375 PERF_RECORD_SWITCH_CPU_WIDE = 15,
Christopher Ferris525ce912017-07-26 13:12:53 -0700376 PERF_RECORD_NAMESPACES = 16,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700377 PERF_RECORD_KSYMBOL = 17,
378 PERF_RECORD_BPF_EVENT = 18,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700379 PERF_RECORD_CGROUP = 19,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700380 PERF_RECORD_TEXT_POKE = 20,
Christopher Ferrisa4792612022-01-10 13:51:15 -0800381 PERF_RECORD_AUX_OUTPUT_HW_ID = 21,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700382 PERF_RECORD_MAX,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800383};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700384enum perf_record_ksymbol_type {
385 PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0,
386 PERF_RECORD_KSYMBOL_TYPE_BPF = 1,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700387 PERF_RECORD_KSYMBOL_TYPE_OOL = 2,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700388 PERF_RECORD_KSYMBOL_TYPE_MAX
389};
390#define PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER (1 << 0)
391enum perf_bpf_event_type {
392 PERF_BPF_EVENT_UNKNOWN = 0,
393 PERF_BPF_EVENT_PROG_LOAD = 1,
394 PERF_BPF_EVENT_PROG_UNLOAD = 2,
395 PERF_BPF_EVENT_MAX,
396};
Ben Cheng655a7c02013-10-16 16:09:24 -0700397#define PERF_MAX_STACK_DEPTH 127
Christopher Ferris49f525c2016-12-12 14:55:36 -0800398#define PERF_MAX_CONTEXTS_PER_STACK 8
Ben Cheng655a7c02013-10-16 16:09:24 -0700399enum perf_callchain_context {
Tao Baod7db5942015-01-28 10:07:51 -0800400 PERF_CONTEXT_HV = (__u64) - 32,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800401 PERF_CONTEXT_KERNEL = (__u64) - 128,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800402 PERF_CONTEXT_USER = (__u64) - 512,
Tao Baod7db5942015-01-28 10:07:51 -0800403 PERF_CONTEXT_GUEST = (__u64) - 2048,
404 PERF_CONTEXT_GUEST_KERNEL = (__u64) - 2176,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800405 PERF_CONTEXT_GUEST_USER = (__u64) - 2560,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800406 PERF_CONTEXT_MAX = (__u64) - 4095,
Ben Cheng655a7c02013-10-16 16:09:24 -0700407};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800408#define PERF_AUX_FLAG_TRUNCATED 0x01
Christopher Ferris05d08e92016-02-04 13:16:38 -0800409#define PERF_AUX_FLAG_OVERWRITE 0x02
Christopher Ferris525ce912017-07-26 13:12:53 -0700410#define PERF_AUX_FLAG_PARTIAL 0x04
Christopher Ferris934ec942018-01-31 15:29:16 -0800411#define PERF_AUX_FLAG_COLLISION 0x08
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000412#define PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK 0xff00
413#define PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT 0x0000
414#define PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW 0x0100
Christopher Ferris49f525c2016-12-12 14:55:36 -0800415#define PERF_FLAG_FD_NO_GROUP (1UL << 0)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700416#define PERF_FLAG_FD_OUTPUT (1UL << 1)
417#define PERF_FLAG_PID_CGROUP (1UL << 2)
418#define PERF_FLAG_FD_CLOEXEC (1UL << 3)
Christopher Ferris525ce912017-07-26 13:12:53 -0700419#ifdef __LITTLE_ENDIAN_BITFIELD
Christopher Ferris49f525c2016-12-12 14:55:36 -0800420union perf_mem_data_src {
Tao Baod7db5942015-01-28 10:07:51 -0800421 __u64 val;
Tao Baod7db5942015-01-28 10:07:51 -0800422 struct {
Christopher Ferrisa4792612022-01-10 13:51:15 -0800423 __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_blk : 3, mem_hops : 3, mem_rsvd : 18;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800424 };
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800425};
Christopher Ferris525ce912017-07-26 13:12:53 -0700426#elif defined(__BIG_ENDIAN_BITFIELD)
427union perf_mem_data_src {
428 __u64 val;
429 struct {
Christopher Ferrisa4792612022-01-10 13:51:15 -0800430 __u64 mem_rsvd : 18, mem_hops : 3, mem_blk : 3, 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 -0700431 };
432};
433#else
434#error "Unknown endianness"
435#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700436#define PERF_MEM_OP_NA 0x01
437#define PERF_MEM_OP_LOAD 0x02
Christopher Ferris49f525c2016-12-12 14:55:36 -0800438#define PERF_MEM_OP_STORE 0x04
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800439#define PERF_MEM_OP_PFETCH 0x08
Ben Cheng655a7c02013-10-16 16:09:24 -0700440#define PERF_MEM_OP_EXEC 0x10
441#define PERF_MEM_OP_SHIFT 0
Christopher Ferris49f525c2016-12-12 14:55:36 -0800442#define PERF_MEM_LVL_NA 0x01
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800443#define PERF_MEM_LVL_HIT 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -0700444#define PERF_MEM_LVL_MISS 0x04
445#define PERF_MEM_LVL_L1 0x08
Christopher Ferris49f525c2016-12-12 14:55:36 -0800446#define PERF_MEM_LVL_LFB 0x10
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800447#define PERF_MEM_LVL_L2 0x20
Ben Cheng655a7c02013-10-16 16:09:24 -0700448#define PERF_MEM_LVL_L3 0x40
449#define PERF_MEM_LVL_LOC_RAM 0x80
Christopher Ferris49f525c2016-12-12 14:55:36 -0800450#define PERF_MEM_LVL_REM_RAM1 0x100
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800451#define PERF_MEM_LVL_REM_RAM2 0x200
Ben Cheng655a7c02013-10-16 16:09:24 -0700452#define PERF_MEM_LVL_REM_CCE1 0x400
453#define PERF_MEM_LVL_REM_CCE2 0x800
Christopher Ferris49f525c2016-12-12 14:55:36 -0800454#define PERF_MEM_LVL_IO 0x1000
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800455#define PERF_MEM_LVL_UNC 0x2000
Ben Cheng655a7c02013-10-16 16:09:24 -0700456#define PERF_MEM_LVL_SHIFT 5
Christopher Ferris1308ad32017-11-14 17:32:13 -0800457#define PERF_MEM_REMOTE_REMOTE 0x01
458#define PERF_MEM_REMOTE_SHIFT 37
459#define PERF_MEM_LVLNUM_L1 0x01
460#define PERF_MEM_LVLNUM_L2 0x02
461#define PERF_MEM_LVLNUM_L3 0x03
462#define PERF_MEM_LVLNUM_L4 0x04
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700463#define PERF_MEM_LVLNUM_UNC 0x08
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000464#define PERF_MEM_LVLNUM_CXL 0x09
465#define PERF_MEM_LVLNUM_IO 0x0a
Christopher Ferris1308ad32017-11-14 17:32:13 -0800466#define PERF_MEM_LVLNUM_ANY_CACHE 0x0b
467#define PERF_MEM_LVLNUM_LFB 0x0c
468#define PERF_MEM_LVLNUM_RAM 0x0d
469#define PERF_MEM_LVLNUM_PMEM 0x0e
470#define PERF_MEM_LVLNUM_NA 0x0f
471#define PERF_MEM_LVLNUM_SHIFT 33
Ben Cheng655a7c02013-10-16 16:09:24 -0700472#define PERF_MEM_SNOOP_NA 0x01
Christopher Ferris49f525c2016-12-12 14:55:36 -0800473#define PERF_MEM_SNOOP_NONE 0x02
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800474#define PERF_MEM_SNOOP_HIT 0x04
Ben Cheng655a7c02013-10-16 16:09:24 -0700475#define PERF_MEM_SNOOP_MISS 0x08
476#define PERF_MEM_SNOOP_HITM 0x10
Christopher Ferris49f525c2016-12-12 14:55:36 -0800477#define PERF_MEM_SNOOP_SHIFT 19
Christopher Ferris1308ad32017-11-14 17:32:13 -0800478#define PERF_MEM_SNOOPX_FWD 0x01
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000479#define PERF_MEM_SNOOPX_PEER 0x02
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800480#define PERF_MEM_SNOOPX_SHIFT 38
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800481#define PERF_MEM_LOCK_NA 0x01
Ben Cheng655a7c02013-10-16 16:09:24 -0700482#define PERF_MEM_LOCK_LOCKED 0x02
483#define PERF_MEM_LOCK_SHIFT 24
Christopher Ferris49f525c2016-12-12 14:55:36 -0800484#define PERF_MEM_TLB_NA 0x01
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800485#define PERF_MEM_TLB_HIT 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -0700486#define PERF_MEM_TLB_MISS 0x04
487#define PERF_MEM_TLB_L1 0x08
Christopher Ferris49f525c2016-12-12 14:55:36 -0800488#define PERF_MEM_TLB_L2 0x10
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800489#define PERF_MEM_TLB_WK 0x20
Ben Cheng655a7c02013-10-16 16:09:24 -0700490#define PERF_MEM_TLB_OS 0x40
Christopher Ferris38062f92014-07-09 15:33:25 -0700491#define PERF_MEM_TLB_SHIFT 26
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700492#define PERF_MEM_BLK_NA 0x01
493#define PERF_MEM_BLK_DATA 0x02
494#define PERF_MEM_BLK_ADDR 0x04
495#define PERF_MEM_BLK_SHIFT 40
Christopher Ferrisa4792612022-01-10 13:51:15 -0800496#define PERF_MEM_HOPS_0 0x01
Christopher Ferris1ed55342022-03-22 16:06:25 -0700497#define PERF_MEM_HOPS_1 0x02
498#define PERF_MEM_HOPS_2 0x03
499#define PERF_MEM_HOPS_3 0x04
Christopher Ferrisa4792612022-01-10 13:51:15 -0800500#define PERF_MEM_HOPS_SHIFT 43
Christopher Ferris49f525c2016-12-12 14:55:36 -0800501#define PERF_MEM_S(a,s) (((__u64) PERF_MEM_ ##a ##_ ##s) << PERF_MEM_ ##a ##_SHIFT)
Christopher Ferris38062f92014-07-09 15:33:25 -0700502struct perf_branch_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800503 __u64 from;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800504 __u64 to;
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000505 __u64 mispred : 1, predicted : 1, in_tx : 1, abort : 1, cycles : 16, type : 4, spec : 2, new_type : 4, priv : 3, reserved : 31;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800506};
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700507#define PERF_BRANCH_ENTRY_INFO_BITS_MAX 33
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700508union perf_sample_weight {
509 __u64 full;
510#ifdef __LITTLE_ENDIAN_BITFIELD
511 struct {
512 __u32 var1_dw;
513 __u16 var2_w;
514 __u16 var3_w;
515 };
516#elif defined(__BIG_ENDIAN_BITFIELD)
517 struct {
518 __u16 var3_w;
519 __u16 var2_w;
520 __u32 var1_dw;
521 };
522#else
523#error "Unknown endianness"
524#endif
525};
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800526#endif