The patch titled Subject: fs/epoll: avoid barrier after an epoll_wait(2) timeout has been added to the -mm tree. Its filename is fs-epoll-avoid-barrier-after-an-epoll_wait2-timeout.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/fs-epoll-avoid-barrier-after-an-epoll_wait2-timeout.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/fs-epoll-avoid-barrier-after-an-epoll_wait2-timeout.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: Davidlohr Bueso <dave@xxxxxxxxxxxx> Subject: fs/epoll: avoid barrier after an epoll_wait(2) timeout Upon timeout, we can just exit out of the loop, without the cost of the changing the task's state with an smp_store_mb call. Just exit out of the loop and be done - setting the task state afterwards will be, of course, redundant. Link: http://lkml.kernel.org/r/20181108051006.18751-7-dave@xxxxxxxxxxxx Signed-off-by: Davidlohr Bueso <dave@xxxxxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Davidlohr Bueso <dbueso@xxxxxxx> Cc: Jason Baron <jbaron@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/eventpoll.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/eventpoll.c~fs-epoll-avoid-barrier-after-an-epoll_wait2-timeout +++ a/fs/eventpoll.c @@ -1820,15 +1820,18 @@ fetch_events: res = -EINTR; break; } - if (ep_events_available(ep) || timed_out) + + if (ep_events_available(ep)) break; if (signal_pending(current)) { res = -EINTR; break; } - if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) + if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) { timed_out = 1; + break; + } } __set_current_state(TASK_RUNNING); _ Patches currently in -mm which might be from dave@xxxxxxxxxxxx are fs-epoll-remove-max_nests-argument-from-ep_call_nested.patch fs-epoll-simplify-ep_send_events_proc-ready-list-loop.patch fs-epoll-drop-ovflist-branch-prediction.patch fs-epoll-robustify-ep-mtx-held-checks.patch fs-epoll-reduce-the-scope-of-wq-lock-in-epoll_wait.patch fs-epoll-reduce-the-scope-of-wq-lock-in-epoll_wait-fix.patch fs-epoll-avoid-barrier-after-an-epoll_wait2-timeout.patch fs-epoll-avoid-barrier-after-an-epoll_wait2-timeout-fix.patch