This patch introduces "AUX space" in the perf mmap buffer, intended for exporting high bandwidth data streams to userspace, such as instruction flow traces. AUX space is a ring buffer, defined by aux_{offset,size} fields in the user_page structure, and read/write pointers aux_{head,tail}, which abide by the same rules as data_* counterparts of the main perf buffer. In order to allocate/mmap AUX, userspace needs to set up aux_offset to such an offset that will be greater than data_offset+data_size and aux_size to be the desired buffer size. Both need to be page aligned. Then, same aux_offset and aux_size should be passed to mmap() call and if everything adds up, you should have an AUX buffer as a result. Pages that are mapped into this buffer also come out of user's mlock rlimit plus perf_event_mlock_kb allowance.
Showing the changes to include/uapi (1 of 5 files). Show all
Unified · Split
| @@ -530,6 +530,22 @@ struct perf_event_mmap_page { · 529 unmodified lines | ||
| 530 | 530 | __u64 data_tail; /* user-space written tail */ |
| 531 | 531 | __u64 data_offset; /* where the buffer starts */ |
| 532 | 532 | __u64 data_size; /* data buffer size */ |
| 533 | + | |
| 534 | + /* | |
| 535 | + * AUX area is defined by aux_{offset,size} fields that should be set | |
| 536 | + * by the userspace, so that | |
| 537 | + * | |
| 538 | + * aux_offset >= data_offset + data_size | |
| 539 | + * | |
| 540 | + * prior to mmap()ing it. Size of the mmap()ed area should be aux_size. | |
| 541 | + * | |
| 542 | + * Ring buffer pointers aux_{head,tail} have the same semantics as | |
| 543 | + * data_{head,tail} and same ordering rules apply. | |
| 544 | + */ | |
| 545 | + __u64 aux_head; | |
| 546 | + __u64 aux_tail; | |
| 547 | + __u64 aux_offset; | |
| 548 | + __u64 aux_size; | |
| 533 | 549 | }; |
| 534 | 550 | |
| 535 | 551 | #define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0) |