--- prebuilts/other/perf_event.h 2023-01-16 15:50:19.155934716 +0800 +++ third_party/perf_include/linux/perf_event.h 2023-01-16 15:52:07.091731926 +0800 @@ -1,4 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Performance events: * @@ -12,12 +11,9 @@ * * For licencing details see kernel-base/COPYING */ -#ifndef _UAPI_LINUX_PERF_EVENT_H -#define _UAPI_LINUX_PERF_EVENT_H - -#include -#include -#include +#ifndef _TS_PERF_EVENT_H +#define _TS_PERF_EVENT_H +#include "types.h" /* * User-space ABI bits: @@ -38,21 +34,6 @@ enum perf_type_id { }; /* - * attr.config layout for type PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE - * PERF_TYPE_HARDWARE: 0xEEEEEEEE000000AA - * AA: hardware event ID - * EEEEEEEE: PMU type ID - * PERF_TYPE_HW_CACHE: 0xEEEEEEEE00DDCCBB - * BB: hardware cache ID - * CC: hardware cache op ID - * DD: hardware cache op result ID - * EEEEEEEE: PMU type ID - * If the PMU type ID is 0, the PERF_TYPE_RAW will be applied. - */ -#define PERF_PMU_TYPE_SHIFT 32 -#define PERF_HW_EVENT_MASK 0xffffffff - -/* * Generalized performance event event_id types, used by the * attr.event_id parameter of the sys_perf_event_open() * syscall: @@ -127,7 +108,6 @@ enum perf_sw_ids { PERF_COUNT_SW_EMULATION_FAULTS = 8, PERF_COUNT_SW_DUMMY = 9, PERF_COUNT_SW_BPF_OUTPUT = 10, - PERF_COUNT_SW_CGROUP_SWITCHES = 11, PERF_COUNT_SW_MAX, /* non-ABI */ }; @@ -157,18 +137,10 @@ enum perf_event_sample_format { PERF_SAMPLE_TRANSACTION = 1U << 17, PERF_SAMPLE_REGS_INTR = 1U << 18, PERF_SAMPLE_PHYS_ADDR = 1U << 19, - PERF_SAMPLE_AUX = 1U << 20, - PERF_SAMPLE_CGROUP = 1U << 21, - PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22, - PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23, - PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24, - PERF_SAMPLE_MAX = 1U << 25, /* non-ABI */ - - __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */ + PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */ }; -#define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT) /* * values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set * @@ -202,8 +174,6 @@ enum perf_branch_sample_type_shift { PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16, /* save branch type */ - PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17, /* save low level index of raw branch records */ - PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */ }; @@ -231,8 +201,6 @@ enum perf_branch_sample_type { PERF_SAMPLE_BRANCH_TYPE_SAVE = 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT, - PERF_SAMPLE_BRANCH_HW_INDEX = 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT, - PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT, }; @@ -326,8 +294,6 @@ enum perf_event_read_format { /* add: sample_stack_user */ #define PERF_ATTR_SIZE_VER4 104 /* add: sample_regs_intr */ #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */ -#define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */ -#define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */ /* * Hardware event_id to monitor via a performance monitoring event: @@ -400,16 +366,7 @@ struct perf_event_attr { context_switch : 1, /* context switch data */ write_backward : 1, /* Write ring buffer from end to beginning */ namespaces : 1, /* include namespaces data */ - ksymbol : 1, /* include ksymbol events */ - bpf_event : 1, /* include bpf events */ - aux_output : 1, /* generate AUX records instead of events */ - cgroup : 1, /* include cgroup events */ - text_poke : 1, /* include text poke events */ - build_id : 1, /* use build id in mmap2 events */ - inherit_thread : 1, /* children only inherit if cloned with CLONE_THREAD */ - remove_on_exec : 1, /* event is removed from task on exec */ - sigtrap : 1, /* send synchronous SIGTRAP on event */ - __reserved_1 : 26; + __reserved_1 : 35; union { __u32 wakeup_events; /* wakeup every n events */ @@ -419,14 +376,10 @@ struct perf_event_attr { __u32 bp_type; union { __u64 bp_addr; - __u64 kprobe_func; /* for perf_kprobe */ - __u64 uprobe_path; /* for perf_uprobe */ __u64 config1; /* extension of config */ }; union { __u64 bp_len; - __u64 kprobe_addr; /* when kprobe_func == NULL */ - __u64 probe_offset; /* for perf_[k,u]probe */ __u64 config2; /* extension of config1 */ }; __u64 branch_sample_type; /* enum perf_branch_sample_type */ @@ -458,53 +411,24 @@ struct perf_event_attr { */ __u32 aux_watermark; __u16 sample_max_stack; - __u16 __reserved_2; - __u32 aux_sample_size; - __u32 __reserved_3; - - /* - * User provided data if sigtrap=1, passed back to user via - * siginfo_t::si_perf_data, e.g. to permit user to identify the event. - */ - __u64 sig_data; + __u16 __reserved_2; /* align to __u64 */ }; -/* - * Structure used by below PERF_EVENT_IOC_QUERY_BPF command - * to query bpf programs attached to the same perf tracepoint - * as the given perf event. - */ -struct perf_event_query_bpf { - /* - * The below ids array length - */ - __u32 ids_len; - /* - * Set by the kernel to indicate the number of - * available programs - */ - __u32 prog_cnt; - /* - * User provided buffer to store program ids - */ - __u32 ids[0]; -}; +#define perf_flags(attr) (*(&(attr)->read_format + 1)) /* * Ioctls that can be done on a perf event fd: */ -#define PERF_EVENT_IOC_ENABLE _IO ('$', 0) -#define PERF_EVENT_IOC_DISABLE _IO ('$', 1) -#define PERF_EVENT_IOC_REFRESH _IO ('$', 2) -#define PERF_EVENT_IOC_RESET _IO ('$', 3) -#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64) -#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5) -#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *) -#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *) -#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32) -#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32) -#define PERF_EVENT_IOC_QUERY_BPF _IOWR('$', 10, struct perf_event_query_bpf *) -#define PERF_EVENT_IOC_MODIFY_ATTRIBUTES _IOW('$', 11, struct perf_event_attr *) +#define PERF_EVENT_IOC_ENABLE _IO ('$', 0) +#define PERF_EVENT_IOC_DISABLE _IO ('$', 1) +#define PERF_EVENT_IOC_REFRESH _IO ('$', 2) +#define PERF_EVENT_IOC_RESET _IO ('$', 3) +#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64) +#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5) +#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *) +#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *) +#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32) +#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32) enum perf_event_ioc_flags { PERF_IOC_FLAG_GROUP = 1U << 0, @@ -564,10 +488,9 @@ struct perf_event_mmap_page { cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */ cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */ - cap_user_time : 1, /* The time_{shift,mult,offset} fields are used */ + cap_user_time : 1, /* The time_* fields are used */ cap_user_time_zero : 1, /* The time_zero field is used */ - cap_user_time_short : 1, /* the time_{cycle,mask} fields are used */ - cap_____res : 58; + cap_____res : 59; }; }; @@ -626,29 +549,13 @@ struct perf_event_mmap_page { * ((rem * time_mult) >> time_shift); */ __u64 time_zero; - __u32 size; /* Header size up to __reserved[] fields. */ - __u32 __reserved_1; - - /* - * If cap_usr_time_short, the hardware clock is less than 64bit wide - * and we must compute the 'cyc' value, as used by cap_usr_time, as: - * - * cyc = time_cycles + ((cyc - time_cycles) & time_mask) - * - * NOTE: this form is explicitly chosen such that cap_usr_time_short - * is a correction on top of cap_usr_time, and code that doesn't - * know about cap_usr_time_short still works under the assumption - * the counter doesn't wrap. - */ - __u64 time_cycles; - __u64 time_mask; /* * Hole for extension of the self monitor capabilities */ - __u8 __reserved[116*8]; /* align to 1k. */ + __u8 __reserved[118*8+4]; /* align to 1k. */ /* * Control data for the mmap() data buffer. @@ -688,22 +595,6 @@ struct perf_event_mmap_page { __u64 aux_size; }; -/* - * The current state of perf_event_header::misc bits usage: - * ('|' used bit, '-' unused bit) - * - * 012 CDEF - * |||---------|||| - * - * Where: - * 0-2 CPUMODE_MASK - * - * C PROC_MAP_PARSE_TIMEOUT - * D MMAP_DATA / COMM_EXEC / FORK_EXEC / SWITCH_OUT - * E MMAP_BUILD_ID / EXACT_IP / SCHED_OUT_PREEMPT - * F (reserved) - */ - #define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0) #define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0) #define PERF_RECORD_MISC_KERNEL (1 << 0) @@ -717,41 +608,19 @@ struct perf_event_mmap_page { */ #define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12) /* - * Following PERF_RECORD_MISC_* are used on different - * events, so can reuse the same bit position: - * - * PERF_RECORD_MISC_MMAP_DATA - PERF_RECORD_MMAP* events - * PERF_RECORD_MISC_COMM_EXEC - PERF_RECORD_COMM event - * PERF_RECORD_MISC_FORK_EXEC - PERF_RECORD_FORK event (perf internal) - * PERF_RECORD_MISC_SWITCH_OUT - PERF_RECORD_SWITCH* events + * PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on + * different events so can reuse the same bit position. + * Ditto PERF_RECORD_MISC_SWITCH_OUT. */ #define PERF_RECORD_MISC_MMAP_DATA (1 << 13) #define PERF_RECORD_MISC_COMM_EXEC (1 << 13) -#define PERF_RECORD_MISC_FORK_EXEC (1 << 13) #define PERF_RECORD_MISC_SWITCH_OUT (1 << 13) /* - * These PERF_RECORD_MISC_* flags below are safely reused - * for the following events: - * - * PERF_RECORD_MISC_EXACT_IP - PERF_RECORD_SAMPLE of precise events - * PERF_RECORD_MISC_SWITCH_OUT_PREEMPT - PERF_RECORD_SWITCH* events - * PERF_RECORD_MISC_MMAP_BUILD_ID - PERF_RECORD_MMAP2 event - * - * - * PERF_RECORD_MISC_EXACT_IP: - * Indicates that the content of PERF_SAMPLE_IP points to - * the actual instruction that triggered the event. See also - * perf_event_attr::precise_ip. - * - * PERF_RECORD_MISC_SWITCH_OUT_PREEMPT: - * Indicates that thread was preempted in TASK_RUNNING state. - * - * PERF_RECORD_MISC_MMAP_BUILD_ID: - * Indicates that mmap2 event carries build id data. + * Indicates that the content of PERF_SAMPLE_IP points to + * the actual instruction that triggered the event. See also + * perf_event_attr::precise_ip. */ #define PERF_RECORD_MISC_EXACT_IP (1 << 14) -#define PERF_RECORD_MISC_SWITCH_OUT_PREEMPT (1 << 14) -#define PERF_RECORD_MISC_MMAP_BUILD_ID (1 << 14) /* * Reserve the last bit to indicate some extended misc field */ @@ -929,9 +798,7 @@ enum perf_event_type { * char data[size];}&& PERF_SAMPLE_RAW * * { u64 nr; - * { u64 hw_idx; } && PERF_SAMPLE_BRANCH_HW_INDEX - * { u64 from, to, flags } lbr[nr]; - * } && PERF_SAMPLE_BRANCH_STACK + * { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK * * { u64 abi; # enum perf_sample_regs_abi * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER @@ -940,33 +807,12 @@ enum perf_event_type { * char data[size]; * u64 dyn_size; } && PERF_SAMPLE_STACK_USER * - * { union perf_sample_weight - * { - * u64 full; && PERF_SAMPLE_WEIGHT - * #if defined(__LITTLE_ENDIAN_BITFIELD) - * struct { - * u32 var1_dw; - * u16 var2_w; - * u16 var3_w; - * } && PERF_SAMPLE_WEIGHT_STRUCT - * #elif defined(__BIG_ENDIAN_BITFIELD) - * struct { - * u16 var3_w; - * u16 var2_w; - * u32 var1_dw; - * } && PERF_SAMPLE_WEIGHT_STRUCT - * #endif - * } - * } + * { u64 weight; } && PERF_SAMPLE_WEIGHT * { u64 data_src; } && PERF_SAMPLE_DATA_SRC * { u64 transaction; } && PERF_SAMPLE_TRANSACTION * { u64 abi; # enum perf_sample_regs_abi * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR * { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR - * { u64 size; - * char data[size]; } && PERF_SAMPLE_AUX - * { u64 data_page_size;} && PERF_SAMPLE_DATA_PAGE_SIZE - * { u64 code_page_size;} && PERF_SAMPLE_CODE_PAGE_SIZE * }; */ PERF_RECORD_SAMPLE = 9, @@ -982,20 +828,10 @@ enum perf_event_type { * u64 addr; * u64 len; * u64 pgoff; - * union { - * struct { - * u32 maj; - * u32 min; - * u64 ino; - * u64 ino_generation; - * }; - * struct { - * u8 build_id_size; - * u8 __reserved_1; - * u16 __reserved_2; - * u8 build_id[20]; - * }; - * }; + * u32 maj; + * u32 min; + * u64 ino; + * u64 ino_generation; * u32 prot, flags; * char filename[]; * struct sample_id sample_id; @@ -1024,7 +860,6 @@ enum perf_event_type { * struct perf_event_header header; * u32 pid; * u32 tid; - * struct sample_id sample_id; * }; */ PERF_RECORD_ITRACE_START = 12, @@ -1079,106 +914,9 @@ enum perf_event_type { */ PERF_RECORD_NAMESPACES = 16, - /* - * Record ksymbol register/unregister events: - * - * struct { - * struct perf_event_header header; - * u64 addr; - * u32 len; - * u16 ksym_type; - * u16 flags; - * char name[]; - * struct sample_id sample_id; - * }; - */ - PERF_RECORD_KSYMBOL = 17, - - /* - * Record bpf events: - * enum perf_bpf_event_type { - * PERF_BPF_EVENT_UNKNOWN = 0, - * PERF_BPF_EVENT_PROG_LOAD = 1, - * PERF_BPF_EVENT_PROG_UNLOAD = 2, - * }; - * - * struct { - * struct perf_event_header header; - * u16 type; - * u16 flags; - * u32 id; - * u8 tag[BPF_TAG_SIZE]; - * struct sample_id sample_id; - * }; - */ - PERF_RECORD_BPF_EVENT = 18, - - /* - * struct { - * struct perf_event_header header; - * u64 id; - * char path[]; - * struct sample_id sample_id; - * }; - */ - PERF_RECORD_CGROUP = 19, - - /* - * Records changes to kernel text i.e. self-modified code. 'old_len' is - * the number of old bytes, 'new_len' is the number of new bytes. Either - * 'old_len' or 'new_len' may be zero to indicate, for example, the - * addition or removal of a trampoline. 'bytes' contains the old bytes - * followed immediately by the new bytes. - * - * struct { - * struct perf_event_header header; - * u64 addr; - * u16 old_len; - * u16 new_len; - * u8 bytes[]; - * struct sample_id sample_id; - * }; - */ - PERF_RECORD_TEXT_POKE = 20, - - /* - * Data written to the AUX area by hardware due to aux_output, may need - * to be matched to the event by an architecture-specific hardware ID. - * This records the hardware ID, but requires sample_id to provide the - * event ID. e.g. Intel PT uses this record to disambiguate PEBS-via-PT - * records from multiple events. - * - * struct { - * struct perf_event_header header; - * u64 hw_id; - * struct sample_id sample_id; - * }; - */ - PERF_RECORD_AUX_OUTPUT_HW_ID = 21, - PERF_RECORD_MAX, /* non-ABI */ }; -enum perf_record_ksymbol_type { - PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0, - PERF_RECORD_KSYMBOL_TYPE_BPF = 1, - /* - * Out of line code such as kprobe-replaced instructions or optimized - * kprobes or ftrace trampolines. - */ - PERF_RECORD_KSYMBOL_TYPE_OOL = 2, - PERF_RECORD_KSYMBOL_TYPE_MAX /* non-ABI */ -}; - -#define PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER (1 << 0) - -enum perf_bpf_event_type { - PERF_BPF_EVENT_UNKNOWN = 0, - PERF_BPF_EVENT_PROG_LOAD = 1, - PERF_BPF_EVENT_PROG_UNLOAD = 2, - PERF_BPF_EVENT_MAX, /* non-ABI */ -}; - #define PERF_MAX_STACK_DEPTH 127 #define PERF_MAX_CONTEXTS_PER_STACK 8 @@ -1197,15 +935,10 @@ enum perf_callchain_context { /** * PERF_RECORD_AUX::flags bits */ -#define PERF_AUX_FLAG_TRUNCATED 0x01 /* record was truncated to fit */ -#define PERF_AUX_FLAG_OVERWRITE 0x02 /* snapshot from overwrite mode */ -#define PERF_AUX_FLAG_PARTIAL 0x04 /* record contains gaps */ -#define PERF_AUX_FLAG_COLLISION 0x08 /* sample collided with another */ -#define PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK 0xff00 /* PMU specific trace format type */ - -/* CoreSight PMU AUX buffer formats */ -#define PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT 0x0000 /* Default for backward compatibility */ -#define PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW 0x0100 /* Raw format of the source */ +#define PERF_AUX_FLAG_TRUNCATED 0x01 /* record was truncated to fit */ +#define PERF_AUX_FLAG_OVERWRITE 0x02 /* snapshot from overwrite mode */ +#define PERF_AUX_FLAG_PARTIAL 0x04 /* record contains gaps */ +#define PERF_AUX_FLAG_COLLISION 0x08 /* sample collided with another */ #define PERF_FLAG_FD_NO_GROUP (1UL << 0) #define PERF_FLAG_FD_OUTPUT (1UL << 1) @@ -1224,18 +957,14 @@ union perf_mem_data_src { mem_lvl_num:4, /* memory hierarchy level number */ mem_remote:1, /* remote */ mem_snoopx:2, /* snoop mode, ext */ - mem_blk:3, /* access blocked */ - mem_hops:3, /* hop level */ - mem_rsvd:18; + mem_rsvd:24; }; }; #elif defined(__BIG_ENDIAN_BITFIELD) union perf_mem_data_src { __u64 val; struct { - __u64 mem_rsvd:18, - mem_hops:3, /* hop level */ - mem_blk:3, /* access blocked */ + __u64 mem_rsvd:24, mem_snoopx:2, /* snoop mode, ext */ mem_remote:1, /* remote */ mem_lvl_num:4, /* memory hierarchy level number */ @@ -1247,7 +976,7 @@ union perf_mem_data_src { }; }; #else -#error "Unknown endianness" +// #error "Unknown endianness" #endif /* type of opcode (load/store/prefetch,code) */ @@ -1258,13 +987,7 @@ union perf_mem_data_src { #define PERF_MEM_OP_EXEC 0x10 /* code (execution) */ #define PERF_MEM_OP_SHIFT 0 -/* - * PERF_MEM_LVL_* namespace being depricated to some extent in the - * favour of newer composite PERF_MEM_{LVLNUM_,REMOTE_,SNOOPX_} fields. - * Supporting this namespace inorder to not break defined ABIs. - * - * memory hierarchy (memory level, hit or miss) - */ +/* memory hierarchy (memory level, hit or miss) */ #define PERF_MEM_LVL_NA 0x01 /* not available */ #define PERF_MEM_LVL_HIT 0x02 /* hit level */ #define PERF_MEM_LVL_MISS 0x04 /* miss level */ @@ -1324,20 +1047,6 @@ union perf_mem_data_src { #define PERF_MEM_TLB_OS 0x40 /* OS fault handler */ #define PERF_MEM_TLB_SHIFT 26 -/* Access blocked */ -#define PERF_MEM_BLK_NA 0x01 /* not available */ -#define PERF_MEM_BLK_DATA 0x02 /* data could not be forwarded */ -#define PERF_MEM_BLK_ADDR 0x04 /* address conflict */ -#define PERF_MEM_BLK_SHIFT 40 - -/* hop level */ -#define PERF_MEM_HOPS_0 0x01 /* remote core, same node */ -#define PERF_MEM_HOPS_1 0x02 /* remote node, same socket */ -#define PERF_MEM_HOPS_2 0x03 /* remote socket, same board */ -#define PERF_MEM_HOPS_3 0x04 /* remote board */ -/* 5-7 available */ -#define PERF_MEM_HOPS_SHIFT 43 - #define PERF_MEM_S(a, s) \ (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT) @@ -1369,23 +1078,4 @@ struct perf_branch_entry { reserved:40; }; -union perf_sample_weight { - __u64 full; -#if defined(__LITTLE_ENDIAN_BITFIELD) - struct { - __u32 var1_dw; - __u16 var2_w; - __u16 var3_w; - }; -#elif defined(__BIG_ENDIAN_BITFIELD) - struct { - __u16 var3_w; - __u16 var2_w; - __u32 var1_dw; - }; -#else -#error "Unknown endianness" -#endif -}; - -#endif /* _UAPI_LINUX_PERF_EVENT_H */ +#endif /* _TS_PERF_EVENT_H */