perf: Add AUX record
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Wed, 14 Jan 2015 12:18:15 +0000 (14:18 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 2 Apr 2015 15:14:12 +0000 (17:14 +0200)
When there's new data in the AUX space, output a record indicating its
offset and size and a set of flags, such as PERF_AUX_FLAG_TRUNCATED, to
mean the described data was truncated to fit in the ring buffer.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
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: 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-7-git-send-email-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/uapi/linux/perf_event.h
kernel/events/core.c
kernel/events/internal.h

index 6c5013a717146216284a5b3d9b3d07edc56802e4..8904ad3a850b1368e52a8502a8b59d1a9e08791f 100644 (file)
@@ -768,6 +768,20 @@ enum perf_event_type {
         */
        PERF_RECORD_MMAP2                       = 10,
 
+       /*
+        * Records that new data landed in the AUX buffer part.
+        *
+        * struct {
+        *      struct perf_event_header        header;
+        *
+        *      u64                             aux_offset;
+        *      u64                             aux_size;
+        *      u64                             flags;
+        *      struct sample_id                sample_id;
+        * };
+        */
+       PERF_RECORD_AUX                         = 11,
+
        PERF_RECORD_MAX,                        /* non-ABI */
 };
 
@@ -785,6 +799,11 @@ enum perf_callchain_context {
        PERF_CONTEXT_MAX                = (__u64)-4095,
 };
 
+/**
+ * PERF_RECORD_AUX::flags bits
+ */
+#define PERF_AUX_FLAG_TRUNCATED                0x01    /* record was truncated to fit */
+
 #define PERF_FLAG_FD_NO_GROUP          (1UL << 0)
 #define PERF_FLAG_FD_OUTPUT            (1UL << 1)
 #define PERF_FLAG_PID_CGROUP           (1UL << 2) /* pid=cgroup id, per-cpu mode only */
index 6d9fdaef7b574a5e021e580416130f705746ae4d..dbc2eff3223026d90785d368d39d2c7f2d814ef5 100644 (file)
@@ -5916,6 +5916,40 @@ void perf_event_mmap(struct vm_area_struct *vma)
        perf_event_mmap_event(&mmap_event);
 }
 
+void perf_event_aux_event(struct perf_event *event, unsigned long head,
+                         unsigned long size, u64 flags)
+{
+       struct perf_output_handle handle;
+       struct perf_sample_data sample;
+       struct perf_aux_event {
+               struct perf_event_header        header;
+               u64                             offset;
+               u64                             size;
+               u64                             flags;
+       } rec = {
+               .header = {
+                       .type = PERF_RECORD_AUX,
+                       .misc = 0,
+                       .size = sizeof(rec),
+               },
+               .offset         = head,
+               .size           = size,
+               .flags          = flags,
+       };
+       int ret;
+
+       perf_event_header__init_id(&rec.header, &sample, event);
+       ret = perf_output_begin(&handle, event, rec.header.size);
+
+       if (ret)
+               return;
+
+       perf_output_put(&handle, rec);
+       perf_event__output_id_sample(event, &handle, &sample);
+
+       perf_output_end(&handle);
+}
+
 /*
  * IRQ throttle logging
  */
index 0f6d08015927dd150dd03e0c96670e68cce99dd9..4d117a981431ce1c161f7eae9fd02b0809d724c2 100644 (file)
@@ -62,6 +62,9 @@ static inline bool rb_has_aux(struct ring_buffer *rb)
        return !!rb->aux_nr_pages;
 }
 
+void perf_event_aux_event(struct perf_event *event, unsigned long head,
+                         unsigned long size, u64 flags);
+
 extern void
 perf_event_header__init_id(struct perf_event_header *header,
                           struct perf_sample_data *data,