[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190531165349.GF2606@hirez.programming.kicks-ass.net>
Date: Fri, 31 May 2019 18:53:49 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Roman Penyaev <rpenyaev@...e.de>
Cc: azat@...event.org, akpm@...ux-foundation.org,
viro@...iv.linux.org.uk, torvalds@...ux-foundation.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing
events to uring
On Fri, May 31, 2019 at 04:28:36PM +0200, Roman Penyaev wrote:
> On 2019-05-31 14:53, Peter Zijlstra wrote:
> > 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.
>
> Yes, that what I tried to avoid choosing c11 extension.
>
> >
> > 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().
>
> Since this path is lockless unfortunately that won't work. So seems
> the only way is to do one more cmpxchg (sigh) or give up and take a
> look (sad sigh).
Of course it works; most of the extant buffers already have a shadow
tail and do the update to userspace with a store-release.
Powered by blists - more mailing lists