diff mbox series

[6/6] fs/epoll: avoid barrier after an epoll_wait(2) timeout

Message ID 20181108051006.18751-7-dave@stgolabs.net (mailing list archive)
State New, archived
Headers show
Series epoll: some miscellaneous optimizations | expand

Commit Message

Davidlohr Bueso Nov. 8, 2018, 5:10 a.m. UTC
Upon timeout, we can just exit out of the loop, without
the cost of the changing the task's state smp_store_mb
call. Just exit out of the loop and be done - setting
the task state afterwards will be, of course, redundant.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 fs/eventpoll.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index f6c023f085f6..ec14e5bcdaa9 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1820,15 +1820,18 @@  static int ep_poll(struct eventpoll *ep, struct epoll_event __user *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);