epoll: optimize setting task running after blocking
authorDavidlohr Bueso <dave@stgolabs.net>
Fri, 13 Feb 2015 22:39:08 +0000 (14:39 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Feb 2015 05:21:40 +0000 (21:21 -0800)
After waking up a task waiting for an event, we explicitly mark it as
TASK_RUNNING (which is necessary as we do the checks for wakeups as
TASK_INTERRUPTIBLE).  Once running and dealing with actually delivering
the events, we're obviously not planning on calling schedule, thus we can
relax the implied barrier and simply update the state with
__set_current_state().

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/eventpoll.c

index d77f94491352f7d7decb81de214696eb53b2d30e..1e009cad8d5cac61832ebb3916033780f2fec1a6 100644 (file)
@@ -1639,9 +1639,9 @@ fetch_events:
 
                        spin_lock_irqsave(&ep->lock, flags);
                }
-               __remove_wait_queue(&ep->wq, &wait);
 
-               set_current_state(TASK_RUNNING);
+               __remove_wait_queue(&ep->wq, &wait);
+               __set_current_state(TASK_RUNNING);
        }
 check_events:
        /* Is it worth to try to dig for events ? */