Skip to content

Commit 38d2035

Browse files
axboebrauner
authored andcommitted
eventpoll: abstract out ep_try_send_events() helper
In preparation for reusing this helper in another epoll setup helper, abstract it out. Signed-off-by: Jens Axboe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 6b47d35 commit 38d2035

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

fs/eventpoll.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,22 @@ static int ep_autoremove_wake_function(struct wait_queue_entry *wq_entry,
19801980
return ret;
19811981
}
19821982

1983+
static int ep_try_send_events(struct eventpoll *ep,
1984+
struct epoll_event __user *events, int maxevents)
1985+
{
1986+
int res;
1987+
1988+
/*
1989+
* Try to transfer events to user space. In case we get 0 events and
1990+
* there's still timeout left over, we go trying again in search of
1991+
* more luck.
1992+
*/
1993+
res = ep_send_events(ep, events, maxevents);
1994+
if (res > 0)
1995+
ep_suspend_napi_irqs(ep);
1996+
return res;
1997+
}
1998+
19831999
/**
19842000
* ep_poll - Retrieves ready events, and delivers them to the caller-supplied
19852001
* event buffer.
@@ -2031,17 +2047,9 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
20312047

20322048
while (1) {
20332049
if (eavail) {
2034-
/*
2035-
* Try to transfer events to user space. In case we get
2036-
* 0 events and there's still timeout left over, we go
2037-
* trying again in search of more luck.
2038-
*/
2039-
res = ep_send_events(ep, events, maxevents);
2040-
if (res) {
2041-
if (res > 0)
2042-
ep_suspend_napi_irqs(ep);
2050+
res = ep_try_send_events(ep, events, maxevents);
2051+
if (res)
20432052
return res;
2044-
}
20452053
}
20462054

20472055
if (timed_out)

0 commit comments

Comments
 (0)