]> Git Repo - linux.git/commitdiff
perf/ring-buffer: Always use {READ,WRITE}_ONCE() for rb->user_page data
authorPeter Zijlstra <[email protected]>
Fri, 17 May 2019 11:52:33 +0000 (13:52 +0200)
committerIngo Molnar <[email protected]>
Fri, 24 May 2019 07:00:11 +0000 (09:00 +0200)
We must use {READ,WRITE}_ONCE() on rb->user_page data such that
concurrent usage will see whole values. A few key sites were missing
this.

Suggested-by: Yabin Cui <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Fixes: 7b732a750477 ("perf_counter: new output ABI - part 1")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
kernel/events/ring_buffer.c

index 4b5f8d932400c1c46a0e8bd98c4b446a39857ec2..7a0c73e4b3eb4095b295608aa22343983ea13dd3 100644 (file)
@@ -100,7 +100,7 @@ again:
         * See perf_output_begin().
         */
        smp_wmb(); /* B, matches C */
-       rb->user_page->data_head = head;
+       WRITE_ONCE(rb->user_page->data_head, head);
 
        /*
         * We must publish the head before decrementing the nest count,
@@ -496,7 +496,7 @@ 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);
 
-       rb->user_page->aux_head = rb->aux_head;
+       WRITE_ONCE(rb->user_page->aux_head, rb->aux_head);
        if (rb_need_aux_wakeup(rb))
                wakeup = true;
 
@@ -528,7 +528,7 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size)
 
        rb->aux_head += size;
 
-       rb->user_page->aux_head = rb->aux_head;
+       WRITE_ONCE(rb->user_page->aux_head, rb->aux_head);
        if (rb_need_aux_wakeup(rb)) {
                perf_output_wakeup(handle);
                handle->wakeup = rb->aux_wakeup + rb->aux_watermark;
This page took 0.059888 seconds and 4 git commands to generate.