Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <axboe@kernel.dk>
Link: https://lore.kernel.org/r/20250219172552.1565603-3-axboe@kernel.dk
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jens Axboe and committed by
Christian Brauner
38d20356 6b47d35d

+18 -10
+18 -10
fs/eventpoll.c
··· 1980 1980 return ret; 1981 1981 } 1982 1982 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 + 1983 1999 /** 1984 2000 * ep_poll - Retrieves ready events, and delivers them to the caller-supplied 1985 2001 * event buffer. ··· 2047 2031 2048 2032 while (1) { 2049 2033 if (eavail) { 2050 - /* 2051 - * Try to transfer events to user space. In case we get 2052 - * 0 events and there's still timeout left over, we go 2053 - * trying again in search of more luck. 2054 - */ 2055 - res = ep_send_events(ep, events, maxevents); 2056 - if (res) { 2057 - if (res > 0) 2058 - ep_suspend_napi_irqs(ep); 2034 + res = ep_try_send_events(ep, events, maxevents); 2035 + if (res) 2059 2036 return res; 2060 - } 2061 2037 } 2062 2038 2063 2039 if (timed_out)