summaryrefslogtreecommitdiff
path: root/drivers/oprofile/cpu_buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/oprofile/cpu_buffer.h')
-rw-r--r--drivers/oprofile/cpu_buffer.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 08706991fdd2..e6089768ae66 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -59,6 +59,23 @@ struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf)
}
static inline
+void cpu_buffer_write_commit(struct oprofile_cpu_buffer *b)
+{
+ unsigned long new_head = b->head_pos + 1;
+
+ /*
+ * Ensure anything written to the slot before we increment is
+ * visible
+ */
+ wmb();
+
+ if (new_head < b->buffer_size)
+ b->head_pos = new_head;
+ else
+ b->head_pos = 0;
+}
+
+static inline
struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf)
{
return &cpu_buf->buffer[cpu_buf->tail_pos];