On 2025-05-27, Nam Cao <namcao@xxxxxxxxxxxxx> wrote: > diff --git a/fs/eventpoll.c b/fs/eventpoll.c > index d4dbffdedd08e..a97a771a459c9 100644 > --- a/fs/eventpoll.c > +++ b/fs/eventpoll.c > @@ -137,13 +137,7 @@ struct epitem { > }; > > /* List header used to link this structure to the eventpoll ready list */ > - struct list_head rdllink; > - > - /* > - * Works together "struct eventpoll"->ovflist in keeping the > - * single linked chain of items. > - */ > - struct epitem *next; > + struct llist_node rdllink; > > /* The file descriptor information this item refers to */ > struct epoll_filefd ffd; > @@ -191,22 +185,15 @@ struct eventpoll { > /* Wait queue used by file->poll() */ > wait_queue_head_t poll_wait; > > - /* List of ready file descriptors */ > - struct list_head rdllist; > - > - /* Lock which protects rdllist and ovflist */ > - rwlock_t lock; > + /* > + * List of ready file descriptors. Adding to this list is lockless. Items can be removed > + * only with eventpoll::mtx > + */ > + struct llist_head rdllist; > > /* RB tree root used to store monitored fd structs */ > struct rb_root_cached rbr; > > - /* > - * This is a single linked list that chains all the "struct epitem" that > - * happened while transferring ready events to userspace w/out > - * holding ->lock. > - */ > - struct epitem *ovflist; > - > /* wakeup_source used when ep_send_events or __ep_eventpoll_poll is running */ > struct wakeup_source *ws; > > @@ -361,10 +348,14 @@ static inline int ep_cmp_ffd(struct epoll_filefd *p1, > (p1->file < p2->file ? -1 : p1->fd - p2->fd)); > } > > -/* Tells us if the item is currently linked */ > -static inline int ep_is_linked(struct epitem *epi) > +/* > + * Add the item to its container eventpoll's rdllist; do nothing if the item is already on rdllist. > + */ > +static void epitem_ready(struct epitem *epi) > { > - return !list_empty(&epi->rdllink); > + if (&epi->rdllink == cmpxchg(&epi->rdllink.next, &epi->rdllink, NULL)) Perhaps: if (try_cmpxchg(&epi->rdllink.next, &epi->rdllink, NULL)) > + llist_add(&epi->rdllink, &epi->ep->rdllist); > + > } > > static inline struct eppoll_entry *ep_pwq_from_wait(wait_queue_entry_t *p) John Ogness