mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
perf: Optimize perf_output_begin()
There's no point in re-doing the memory-barrier when we fail the cmpxchg(). Also placing it after the space reservation loop makes it clearer it only separates the userpage->tail read from the data stores. Signed-off-by: Peter Zijlstra <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michael Neuling <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: [email protected] Cc: Vince Weaver <[email protected]> Cc: Victor Kaplansky <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Anton Blanchard <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
c72b42a3dd
commit
85f59edf96
1 changed files with 9 additions and 8 deletions
|
|
@ -141,15 +141,7 @@ int perf_output_begin(struct perf_output_handle *handle,
|
|||
perf_output_get_handle(handle);
|
||||
|
||||
do {
|
||||
/*
|
||||
* Userspace could choose to issue a mb() before updating the
|
||||
* tail pointer. So that all reads will be completed before the
|
||||
* write is issued.
|
||||
*
|
||||
* See perf_output_put_handle().
|
||||
*/
|
||||
tail = ACCESS_ONCE(rb->user_page->data_tail);
|
||||
smp_mb();
|
||||
offset = head = local_read(&rb->head);
|
||||
if (!rb->overwrite &&
|
||||
unlikely(CIRC_SPACE(head, tail, perf_data_size(rb)) < size))
|
||||
|
|
@ -157,6 +149,15 @@ int perf_output_begin(struct perf_output_handle *handle,
|
|||
head += size;
|
||||
} while (local_cmpxchg(&rb->head, offset, head) != offset);
|
||||
|
||||
/*
|
||||
* Separate the userpage->tail read from the data stores below.
|
||||
* Matches the MB userspace SHOULD issue after reading the data
|
||||
* and before storing the new tail position.
|
||||
*
|
||||
* See perf_output_put_handle().
|
||||
*/
|
||||
smp_mb();
|
||||
|
||||
if (unlikely(head - local_read(&rb->wakeup) > rb->watermark))
|
||||
local_add(rb->watermark, &rb->wakeup);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue