Re: [PATCH v3 00/13] epoll: support pollable epoll from userspace

From: Peter Zijlstra
Date: Fri May 31 2019 - 05:59:26 EST


On Thu, May 16, 2019 at 10:57:57AM +0200, Roman Penyaev wrote:
> When new event comes for some epoll item kernel does the following:
>
> struct epoll_uitem *uitem;
>
> /* Each item has a bit (index in user items array), discussed later */
> uitem = user_header->items[epi->bit];
>
> if (!atomic_fetch_or(uitem->ready_events, pollflags)) {
> i = atomic_add(&ep->user_header->tail, 1);
>
> item_idx = &user_index[i & index_mask];
>
> /* Signal with a bit, user spins on index expecting value > 0 */
> *item_idx = idx + 1;
>
> /*
> * Want index update be flushed from CPU write buffer and
> * immediately visible on userspace side to avoid long busy
> * loops.
> */

That is garbage; smp_wmb() does no such thing.

> smp_wmb();
> }