hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/include/uapi/linux/perf_event.h
....@@ -141,8 +141,10 @@
141141 PERF_SAMPLE_TRANSACTION = 1U << 17,
142142 PERF_SAMPLE_REGS_INTR = 1U << 18,
143143 PERF_SAMPLE_PHYS_ADDR = 1U << 19,
144
+ PERF_SAMPLE_AUX = 1U << 20,
145
+ PERF_SAMPLE_CGROUP = 1U << 21,
144146
145
- PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
147
+ PERF_SAMPLE_MAX = 1U << 22, /* non-ABI */
146148
147149 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */
148150 };
....@@ -180,6 +182,8 @@
180182
181183 PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 16, /* save branch type */
182184
185
+ PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17, /* save low level index of raw branch records */
186
+
183187 PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */
184188 };
185189
....@@ -206,6 +210,8 @@
206210
207211 PERF_SAMPLE_BRANCH_TYPE_SAVE =
208212 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT,
213
+
214
+ PERF_SAMPLE_BRANCH_HW_INDEX = 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT,
209215
210216 PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
211217 };
....@@ -300,6 +306,7 @@
300306 /* add: sample_stack_user */
301307 #define PERF_ATTR_SIZE_VER4 104 /* add: sample_regs_intr */
302308 #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
309
+#define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
303310
304311 /*
305312 * Hardware event_id to monitor via a performance monitoring event:
....@@ -372,7 +379,12 @@
372379 context_switch : 1, /* context switch data */
373380 write_backward : 1, /* Write ring buffer from end to beginning */
374381 namespaces : 1, /* include namespaces data */
375
- __reserved_1 : 35;
382
+ ksymbol : 1, /* include ksymbol events */
383
+ bpf_event : 1, /* include bpf events */
384
+ aux_output : 1, /* generate AUX records instead of events */
385
+ cgroup : 1, /* include cgroup events */
386
+ text_poke : 1, /* include text poke events */
387
+ __reserved_1 : 30;
376388
377389 union {
378390 __u32 wakeup_events; /* wakeup every n events */
....@@ -421,7 +433,9 @@
421433 */
422434 __u32 aux_watermark;
423435 __u16 sample_max_stack;
424
- __u16 __reserved_2; /* align to __u64 */
436
+ __u16 __reserved_2;
437
+ __u32 aux_sample_size;
438
+ __u32 __reserved_3;
425439 };
426440
427441 /*
....@@ -444,8 +458,6 @@
444458 */
445459 __u32 ids[0];
446460 };
447
-
448
-#define perf_flags(attr) (*(&(attr)->read_format + 1))
449461
450462 /*
451463 * Ioctls that can be done on a perf event fd:
....@@ -521,9 +533,10 @@
521533 cap_bit0_is_deprecated : 1, /* Always 1, signals that bit 0 is zero */
522534
523535 cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */
524
- cap_user_time : 1, /* The time_* fields are used */
536
+ cap_user_time : 1, /* The time_{shift,mult,offset} fields are used */
525537 cap_user_time_zero : 1, /* The time_zero field is used */
526
- cap_____res : 59;
538
+ cap_user_time_short : 1, /* the time_{cycle,mask} fields are used */
539
+ cap_____res : 58;
527540 };
528541 };
529542
....@@ -582,13 +595,29 @@
582595 * ((rem * time_mult) >> time_shift);
583596 */
584597 __u64 time_zero;
598
+
585599 __u32 size; /* Header size up to __reserved[] fields. */
600
+ __u32 __reserved_1;
601
+
602
+ /*
603
+ * If cap_usr_time_short, the hardware clock is less than 64bit wide
604
+ * and we must compute the 'cyc' value, as used by cap_usr_time, as:
605
+ *
606
+ * cyc = time_cycles + ((cyc - time_cycles) & time_mask)
607
+ *
608
+ * NOTE: this form is explicitly chosen such that cap_usr_time_short
609
+ * is a correction on top of cap_usr_time, and code that doesn't
610
+ * know about cap_usr_time_short still works under the assumption
611
+ * the counter doesn't wrap.
612
+ */
613
+ __u64 time_cycles;
614
+ __u64 time_mask;
586615
587616 /*
588617 * Hole for extension of the self monitor capabilities
589618 */
590619
591
- __u8 __reserved[118*8+4]; /* align to 1k. */
620
+ __u8 __reserved[116*8]; /* align to 1k. */
592621
593622 /*
594623 * Control data for the mmap() data buffer.
....@@ -646,10 +675,12 @@
646675 *
647676 * PERF_RECORD_MISC_MMAP_DATA - PERF_RECORD_MMAP* events
648677 * PERF_RECORD_MISC_COMM_EXEC - PERF_RECORD_COMM event
678
+ * PERF_RECORD_MISC_FORK_EXEC - PERF_RECORD_FORK event (perf internal)
649679 * PERF_RECORD_MISC_SWITCH_OUT - PERF_RECORD_SWITCH* events
650680 */
651681 #define PERF_RECORD_MISC_MMAP_DATA (1 << 13)
652682 #define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
683
+#define PERF_RECORD_MISC_FORK_EXEC (1 << 13)
653684 #define PERF_RECORD_MISC_SWITCH_OUT (1 << 13)
654685 /*
655686 * These PERF_RECORD_MISC_* flags below are safely reused
....@@ -846,7 +877,9 @@
846877 * char data[size];}&& PERF_SAMPLE_RAW
847878 *
848879 * { u64 nr;
849
- * { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK
880
+ * { u64 hw_idx; } && PERF_SAMPLE_BRANCH_HW_INDEX
881
+ * { u64 from, to, flags } lbr[nr];
882
+ * } && PERF_SAMPLE_BRANCH_STACK
850883 *
851884 * { u64 abi; # enum perf_sample_regs_abi
852885 * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER
....@@ -861,6 +894,8 @@
861894 * { u64 abi; # enum perf_sample_regs_abi
862895 * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
863896 * { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR
897
+ * { u64 size;
898
+ * char data[size]; } && PERF_SAMPLE_AUX
864899 * };
865900 */
866901 PERF_RECORD_SAMPLE = 9,
....@@ -963,7 +998,89 @@
963998 */
964999 PERF_RECORD_NAMESPACES = 16,
9651000
1001
+ /*
1002
+ * Record ksymbol register/unregister events:
1003
+ *
1004
+ * struct {
1005
+ * struct perf_event_header header;
1006
+ * u64 addr;
1007
+ * u32 len;
1008
+ * u16 ksym_type;
1009
+ * u16 flags;
1010
+ * char name[];
1011
+ * struct sample_id sample_id;
1012
+ * };
1013
+ */
1014
+ PERF_RECORD_KSYMBOL = 17,
1015
+
1016
+ /*
1017
+ * Record bpf events:
1018
+ * enum perf_bpf_event_type {
1019
+ * PERF_BPF_EVENT_UNKNOWN = 0,
1020
+ * PERF_BPF_EVENT_PROG_LOAD = 1,
1021
+ * PERF_BPF_EVENT_PROG_UNLOAD = 2,
1022
+ * };
1023
+ *
1024
+ * struct {
1025
+ * struct perf_event_header header;
1026
+ * u16 type;
1027
+ * u16 flags;
1028
+ * u32 id;
1029
+ * u8 tag[BPF_TAG_SIZE];
1030
+ * struct sample_id sample_id;
1031
+ * };
1032
+ */
1033
+ PERF_RECORD_BPF_EVENT = 18,
1034
+
1035
+ /*
1036
+ * struct {
1037
+ * struct perf_event_header header;
1038
+ * u64 id;
1039
+ * char path[];
1040
+ * struct sample_id sample_id;
1041
+ * };
1042
+ */
1043
+ PERF_RECORD_CGROUP = 19,
1044
+
1045
+ /*
1046
+ * Records changes to kernel text i.e. self-modified code. 'old_len' is
1047
+ * the number of old bytes, 'new_len' is the number of new bytes. Either
1048
+ * 'old_len' or 'new_len' may be zero to indicate, for example, the
1049
+ * addition or removal of a trampoline. 'bytes' contains the old bytes
1050
+ * followed immediately by the new bytes.
1051
+ *
1052
+ * struct {
1053
+ * struct perf_event_header header;
1054
+ * u64 addr;
1055
+ * u16 old_len;
1056
+ * u16 new_len;
1057
+ * u8 bytes[];
1058
+ * struct sample_id sample_id;
1059
+ * };
1060
+ */
1061
+ PERF_RECORD_TEXT_POKE = 20,
1062
+
9661063 PERF_RECORD_MAX, /* non-ABI */
1064
+};
1065
+
1066
+enum perf_record_ksymbol_type {
1067
+ PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0,
1068
+ PERF_RECORD_KSYMBOL_TYPE_BPF = 1,
1069
+ /*
1070
+ * Out of line code such as kprobe-replaced instructions or optimized
1071
+ * kprobes or ftrace trampolines.
1072
+ */
1073
+ PERF_RECORD_KSYMBOL_TYPE_OOL = 2,
1074
+ PERF_RECORD_KSYMBOL_TYPE_MAX /* non-ABI */
1075
+};
1076
+
1077
+#define PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER (1 << 0)
1078
+
1079
+enum perf_bpf_event_type {
1080
+ PERF_BPF_EVENT_UNKNOWN = 0,
1081
+ PERF_BPF_EVENT_PROG_LOAD = 1,
1082
+ PERF_BPF_EVENT_PROG_UNLOAD = 2,
1083
+ PERF_BPF_EVENT_MAX, /* non-ABI */
9671084 };
9681085
9691086 #define PERF_MAX_STACK_DEPTH 127
....@@ -984,10 +1101,15 @@
9841101 /**
9851102 * PERF_RECORD_AUX::flags bits
9861103 */
987
-#define PERF_AUX_FLAG_TRUNCATED 0x01 /* record was truncated to fit */
988
-#define PERF_AUX_FLAG_OVERWRITE 0x02 /* snapshot from overwrite mode */
989
-#define PERF_AUX_FLAG_PARTIAL 0x04 /* record contains gaps */
990
-#define PERF_AUX_FLAG_COLLISION 0x08 /* sample collided with another */
1104
+#define PERF_AUX_FLAG_TRUNCATED 0x01 /* record was truncated to fit */
1105
+#define PERF_AUX_FLAG_OVERWRITE 0x02 /* snapshot from overwrite mode */
1106
+#define PERF_AUX_FLAG_PARTIAL 0x04 /* record contains gaps */
1107
+#define PERF_AUX_FLAG_COLLISION 0x08 /* sample collided with another */
1108
+#define PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK 0xff00 /* PMU specific trace format type */
1109
+
1110
+/* CoreSight PMU AUX buffer formats */
1111
+#define PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT 0x0000 /* Default for backward compatibility */
1112
+#define PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW 0x0100 /* Raw format of the source */
9911113
9921114 #define PERF_FLAG_FD_NO_GROUP (1UL << 0)
9931115 #define PERF_FLAG_FD_OUTPUT (1UL << 1)