aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2015-01-14 07:18:11 -0500
committerIngo Molnar <mingo@kernel.org>2015-04-02 11:13:46 -0400
commit45bfb2e50471abbbfd83d40d28c986078b0d24ff (patch)
treef06f2176a2ef51315387f492a3f1b85efe91f2bb /include
parente8c6deac69629c0cb97c3d3272f8631ef17f8f0f (diff)
perf: Add AUX area to ring buffer for raw data streams
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. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Kaixu Xia <kaixu.xia@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Robert Richter <rric@kernel.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: acme@infradead.org Cc: adrian.hunter@intel.com Cc: kan.liang@intel.com Cc: markus.t.metzger@intel.com Cc: mathieu.poirier@linaro.org Link: http://lkml.kernel.org/r/1421237903-181015-3-git-send-email-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/perf_event.h17
-rw-r--r--include/uapi/linux/perf_event.h16
2 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 401554074de9..5a94f6d6fa91 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -284,6 +284,18 @@ struct pmu {
284 * Return the count value for a counter. 284 * Return the count value for a counter.
285 */ 285 */
286 u64 (*count) (struct perf_event *event); /*optional*/ 286 u64 (*count) (struct perf_event *event); /*optional*/
287
288 /*
289 * Set up pmu-private data structures for an AUX area
290 */
291 void *(*setup_aux) (int cpu, void **pages,
292 int nr_pages, bool overwrite);
293 /* optional */
294
295 /*
296 * Free pmu-private AUX data structures
297 */
298 void (*free_aux) (void *aux); /* optional */
287}; 299};
288 300
289/** 301/**
@@ -862,6 +874,11 @@ static inline bool needs_branch_stack(struct perf_event *event)
862 return event->attr.branch_sample_type != 0; 874 return event->attr.branch_sample_type != 0;
863} 875}
864 876
877static inline bool has_aux(struct perf_event *event)
878{
879 return event->pmu->setup_aux;
880}
881
865extern int perf_output_begin(struct perf_output_handle *handle, 882extern int perf_output_begin(struct perf_output_handle *handle,
866 struct perf_event *event, unsigned int size); 883 struct perf_event *event, unsigned int size);
867extern void perf_output_end(struct perf_output_handle *handle); 884extern void perf_output_end(struct perf_output_handle *handle);
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 86c44ae66d43..6c5013a71714 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -530,6 +530,22 @@ struct perf_event_mmap_page {
530 __u64 data_tail; /* user-space written tail */ 530 __u64 data_tail; /* user-space written tail */
531 __u64 data_offset; /* where the buffer starts */ 531 __u64 data_offset; /* where the buffer starts */
532 __u64 data_size; /* data buffer size */ 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#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0) 551#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)