aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events/ring_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/events/ring_buffer.c')
-rw-r--r--kernel/events/ring_buffer.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 383cde476176..6ed16ecfd0a3 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -141,15 +141,7 @@ int perf_output_begin(struct perf_output_handle *handle,
141 perf_output_get_handle(handle); 141 perf_output_get_handle(handle);
142 142
143 do { 143 do {
144 /*
145 * Userspace could choose to issue a mb() before updating the
146 * tail pointer. So that all reads will be completed before the
147 * write is issued.
148 *
149 * See perf_output_put_handle().
150 */
151 tail = ACCESS_ONCE(rb->user_page->data_tail); 144 tail = ACCESS_ONCE(rb->user_page->data_tail);
152 smp_mb();
153 offset = head = local_read(&rb->head); 145 offset = head = local_read(&rb->head);
154 if (!rb->overwrite && 146 if (!rb->overwrite &&
155 unlikely(CIRC_SPACE(head, tail, perf_data_size(rb)) < size)) 147 unlikely(CIRC_SPACE(head, tail, perf_data_size(rb)) < size))
@@ -157,6 +149,15 @@ int perf_output_begin(struct perf_output_handle *handle,
157 head += size; 149 head += size;
158 } while (local_cmpxchg(&rb->head, offset, head) != offset); 150 } while (local_cmpxchg(&rb->head, offset, head) != offset);
159 151
152 /*
153 * Separate the userpage->tail read from the data stores below.
154 * Matches the MB userspace SHOULD issue after reading the data
155 * and before storing the new tail position.
156 *
157 * See perf_output_put_handle().
158 */
159 smp_mb();
160
160 if (unlikely(head - local_read(&rb->wakeup) > rb->watermark)) 161 if (unlikely(head - local_read(&rb->wakeup) > rb->watermark))
161 local_add(rb->watermark, &rb->wakeup); 162 local_add(rb->watermark, &rb->wakeup);
162 163