The patch titled Subject: epoll: pull all code between fetch_events and send_event into the loop has been added to the -mm tree. Its filename is epoll-pull-all-code-between-fetch_events-and-send_event-into-the-loop.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/epoll-pull-all-code-between-fetch_events-and-send_event-into-the-loop.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/epoll-pull-all-code-between-fetch_events-and-send_event-into-the-loop.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Soheil Hassas Yeganeh <soheil@xxxxxxxxxx> Subject: epoll: pull all code between fetch_events and send_event into the loop This is a no-op change which simplifies the follow up patches. Link: https://lkml.kernel.org/r/20201106231635.3528496-7-soheil.kdev@xxxxxxxxx Signed-off-by: Soheil Hassas Yeganeh <soheil@xxxxxxxxxx> Suggested-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx> Reviewed-by: Willem de Bruijn <willemb@xxxxxxxxxx> Reviewed-by: Khazhismel Kumykov <khazhy@xxxxxxxxxx> Cc: Guantao Liu <guantaol@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/eventpoll.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) --- a/fs/eventpoll.c~epoll-pull-all-code-between-fetch_events-and-send_event-into-the-loop +++ a/fs/eventpoll.c @@ -1861,14 +1861,14 @@ static int ep_poll(struct eventpoll *ep, } fetch_events: - eavail = ep_events_available(ep); - if (!eavail) - eavail = ep_busy_loop(ep, timed_out); + do { + eavail = ep_events_available(ep); + if (!eavail) + eavail = ep_busy_loop(ep, timed_out); - if (eavail) - goto send_events; + if (eavail) + goto send_events; - do { if (signal_pending(current)) return -EINTR; @@ -1917,21 +1917,22 @@ fetch_events: * carefully under lock, below. */ eavail = 1; - } while (0); - if (!list_empty_careful(&wait.entry)) { - write_lock_irq(&ep->lock); - /* - * If the thread timed out and is not on the wait queue, it - * means that the thread was woken up after its timeout expired - * before it could reacquire the lock. Thus, when wait.entry is - * empty, it needs to harvest events. - */ - if (timed_out) - eavail = list_empty(&wait.entry); - __remove_wait_queue(&ep->wq, &wait); - write_unlock_irq(&ep->lock); - } + if (!list_empty_careful(&wait.entry)) { + write_lock_irq(&ep->lock); + /* + * If the thread timed out and is not on the wait queue, + * it means that the thread was woken up after its + * timeout expired before it could reacquire the lock. + * Thus, when wait.entry is empty, it needs to harvest + * events. + */ + if (timed_out) + eavail = list_empty(&wait.entry); + __remove_wait_queue(&ep->wq, &wait); + write_unlock_irq(&ep->lock); + } + } while (0); send_events: /* _ Patches currently in -mm which might be from soheil@xxxxxxxxxx are epoll-check-for-events-when-removing-a-timed-out-thread-from-the-wait-queue.patch epoll-simplify-signal-handling.patch epoll-pull-fatal-signal-checks-into-ep_send_events.patch epoll-move-eavail-next-to-the-list_empty_careful-check.patch epoll-simplify-and-optimize-busy-loop-logic.patch epoll-pull-all-code-between-fetch_events-and-send_event-into-the-loop.patch epoll-replace-gotos-with-a-proper-loop.patch epoll-eliminate-unnecessary-lock-for-zero-timeout.patch