History

perf/aux: Allow using AUX data in perf samples

AUX data can be used to annotate perf events such as performance counters or tracepoints/breakpoints by including it in sample records when PERF_SAMPLE_AUX flag is set. Such samples would be instrumental in debugging and profiling by providing, for example, a history of instruction flow leading up to the event's overflow. The implementation makes use of grouping an AUX event with all the events that wish to take samples of the AUX data, such that the former is the group leader. The samplees should also specify the desired size of the AUX sample via attr.aux_sample_size. AUX capable PMUs need to explicitly add support for sampling, because it relies on a new callback to take a snapshot of the buffer without touching the event states.

Alexander Shishkin committed 7 years ago

Commit a4faf001 parent deb0c3c5 files · +234 −5Browse files

Showing the changes to include/uapi/linux (1 of 5 files). Show all

Unified · Split

include/uapi/linux/perf_event.h+8−2
@@ -141,8 +141,9 @@ enum perf_event_sample_format { · 140 unmodified lines
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,
144145
145− PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
146+ PERF_SAMPLE_MAX = 1U << 21, /* non-ABI */
146147
147148 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */
148149 };
@@ -300,6 +301,7 @@ enum perf_event_read_format { · 151 unmodified lines
300301 /* add: sample_stack_user */
301302 #define PERF_ATTR_SIZE_VER4 104 /* add: sample_regs_intr */
302303 #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
304+#define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
303305
304306 /*
305307 * Hardware event_id to monitor via a performance monitoring event:
@@ -424,7 +426,9 @@ struct perf_event_attr { · 118 unmodified lines
424426 */
425427 __u32 aux_watermark;
426428 __u16 sample_max_stack;
427− __u16 __reserved_2; /* align to __u64 */
429+ __u16 __reserved_2;
430+ __u32 aux_sample_size;
431+ __u32 __reserved_3;
428432 };
429433
430434 /*
@@ -864,6 +868,8 @@ enum perf_event_type { · 433 unmodified lines
864868 * { u64 abi; # enum perf_sample_regs_abi
865869 * u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
866870 * { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR
871+ * { u64 size;
872+ * char data[size]; } && PERF_SAMPLE_AUX
867873 * };
868874 */
869875 PERF_RECORD_SAMPLE = 9,