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/linux (1 of 5 files). Show all

Unified · Split

include/linux/perf_event.h+19−0
@@ -249,6 +249,8 @@ struct perf_event; · 248 unmodified lines
249249 #define PERF_PMU_CAP_NO_EXCLUDE 0x80
250250 #define PERF_PMU_CAP_AUX_OUTPUT 0x100
251251
252+struct perf_output_handle;
253+
252254 /**
253255 * struct pmu - generic performance monitoring unit
254256 */
@@ -432,6 +434,19 @@ struct pmu { · 177 unmodified lines
432434 */
433435 void (*free_aux) (void *aux); /* optional */
434436
437+ /*
438+ * Take a snapshot of the AUX buffer without touching the event
439+ * state, so that preempting ->start()/->stop() callbacks does
440+ * not interfere with their logic. Called in PMI context.
441+ *
442+ * Returns the size of AUX data copied to the output handle.
443+ *
444+ * Optional.
445+ */
446+ long (*snapshot_aux) (struct perf_event *event,
447+ struct perf_output_handle *handle,
448+ unsigned long size);
449+
435450 /*
436451 * Validate address range filters: make sure the HW supports the
437452 * requested configuration and number of filters; return 0 if the
@@ -973,6 +988,7 @@ struct perf_sample_data { · 535 unmodified lines
973988 u32 reserved;
974989 } cpu_entry;
975990 struct perf_callchain_entry *callchain;
991+ u64 aux_size;
976992
977993 /*
978994 * regs_user may point to task_pt_regs or to regs_user_copy, depending
@@ -1362,6 +1378,9 @@ extern unsigned int perf_output_copy(struct perf_output_handle *handle, · 383 unmodified lines
13621378 const void *buf, unsigned int len);
13631379 extern unsigned int perf_output_skip(struct perf_output_handle *handle,
13641380 unsigned int len);
1381+extern long perf_output_copy_aux(struct perf_output_handle *aux_handle,
1382+ struct perf_output_handle *handle,
1383+ unsigned long from, unsigned long to);
13651384 extern int perf_swevent_get_recursion_context(void);
13661385 extern void perf_swevent_put_recursion_context(int rctx);
13671386 extern u64 perf_swevent_set_period(struct perf_event *event);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t