Messages in this thread | | | Date | Wed, 6 Nov 2013 16:23:46 +0100 | From | Peter Zijlstra <> | Subject | Re: [tip:perf/core] tools/perf: Add required memory barriers |
| |
On Wed, Nov 06, 2013 at 04:10:55PM +0100, Peter Zijlstra wrote: > On Wed, Nov 06, 2013 at 09:55:17AM -0500, Vince Weaver wrote: > > Having perf in the kernel tree really makes it hard for you guys to keep a > > clean API/ABI it seems. > > Lock free buffers are 'fun'.. The ABI can be described as: > > read pc->data_head > > // ensure no other reads get before this point and ->data_head > // doesn't get re-read hereafter.
FWIW; this is where barrier() and ACCESS_ONCE() differ afaict, barrier() only accomplishes that if the ->data_head read re-appears it must re-issue it; whereas ACCESS_ONCE(), by marking it volatile, completely avoids that read insertion from being possible.
Then again, the compiler should not lower the read over a compiler barrier anyway, so on that account the insertion of the second read would also be invalid.
So you're _probably_ good without the ACCESS_ONCE, but please ask a compiler person, not me.
| |