@@ -509,6 +509,15 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)
perf_event_aux_event(handle->event, aux_head, size,
handle->aux_flags);
+ /*
+ * See perf_output_put_handle(), AUX ring buffer applies the same
+ * barrier pairing as the perf ring buffer; except for B, since
+ * AUX ring buffer is written by hardware trace, we cannot simply
+ * use the generic memory barrier (like smp_wmb()) prior to update
+ * user_page::aux_head, the hardware trace driver takes the
+ * responsibility to ensure the trace data has been flushed into
+ * the AUX buffer before calling perf_aux_output_end().
+ */
WRITE_ONCE(rb->user_page->aux_head, rb->aux_head);
if (rb_need_aux_wakeup(rb))
wakeup = true;