On Fri, May 31, 2019 at 01:15:21PM +0200, Roman Penyaev wrote:
On 2019-05-31 11:56, Peter Zijlstra wrote:
> On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote:
> > + i = __atomic_fetch_add(&ep->user_header->tail, 1,
> > + __ATOMIC_ACQUIRE);
> afaict __atomic_fetch_add() does not exist.
That is gcc extension. I did not find any API just to increment
the variable atomically without using/casting to atomic. What
is a proper way to achieve that?
That's C11 atomics, and those shall not be used in the kernel. For one
they're not available in the minimally required GCC version (4.6).
The proper and only way is to use atomic_t, but also you cannot share
atomic_t with userspace.
The normal way of doing something like this is to have a kernel private
atomic_t and copy the value out to userspace using smp_store_release().