提交 3fb0e584 编写于 作者: D Davide Libenzi 提交者: Linus Torvalds

epoll: move ready event check into proper inline

Move the event readiness check into a proper inline, and use it uniformly
inside ep_poll() code.  Events in the ->ovflist are no less ready than the
ones in ->rdllist.
Signed-off-by: NDavide Libenzi <davidel@xmailserver.org>
Cc: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d03e1617
...@@ -315,6 +315,19 @@ static void ep_nested_calls_init(struct nested_calls *ncalls) ...@@ -315,6 +315,19 @@ static void ep_nested_calls_init(struct nested_calls *ncalls)
spin_lock_init(&ncalls->lock); spin_lock_init(&ncalls->lock);
} }
/**
* ep_events_available - Checks if ready events might be available.
*
* @ep: Pointer to the eventpoll context.
*
* Returns: Returns a value different than zero if ready events are available,
* or zero otherwise.
*/
static inline int ep_events_available(struct eventpoll *ep)
{
return !list_empty(&ep->rdllist) || ep->ovflist != EP_UNACTIVE_PTR;
}
/** /**
* ep_call_nested - Perform a bound (possibly) nested call, by checking * ep_call_nested - Perform a bound (possibly) nested call, by checking
* that the recursion limit is not exceeded, and that * that the recursion limit is not exceeded, and that
...@@ -1158,7 +1171,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, ...@@ -1158,7 +1171,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
spin_lock_irqsave(&ep->lock, flags); spin_lock_irqsave(&ep->lock, flags);
res = 0; res = 0;
if (list_empty(&ep->rdllist)) { if (!ep_events_available(ep)) {
/* /*
* We don't have any available event to return to the caller. * We don't have any available event to return to the caller.
* We need to sleep here, and we will be wake up by * We need to sleep here, and we will be wake up by
...@@ -1174,7 +1187,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, ...@@ -1174,7 +1187,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
* to TASK_INTERRUPTIBLE before doing the checks. * to TASK_INTERRUPTIBLE before doing the checks.
*/ */
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (!list_empty(&ep->rdllist) || timed_out) if (ep_events_available(ep) || timed_out)
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
res = -EINTR; res = -EINTR;
...@@ -1192,7 +1205,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, ...@@ -1192,7 +1205,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
} }
/* Is it worth to try to dig for events ? */ /* Is it worth to try to dig for events ? */
eavail = !list_empty(&ep->rdllist) || ep->ovflist != EP_UNACTIVE_PTR; eavail = ep_events_available(ep);
spin_unlock_irqrestore(&ep->lock, flags); spin_unlock_irqrestore(&ep->lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册