Re: [tip:perf/core] tools/perf: Add required memory barriers

From: Peter Zijlstra
Date: Wed Nov 06 2013 - 10:24:22 EST


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.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/