Skip to content

Commit cccd29b

Browse files
soheilhytorvalds
authored andcommitted
epoll: pull fatal signal checks into ep_send_events()
To simplify the code, pull in checking the fatal signals into ep_send_events(). ep_send_events() is called only from ep_poll(). Note that, previously, we were always checking fatal events, but it is checked only if eavail is true. This should be fine because the goal of that check is to quickly return from epoll_wait() when there is a pending fatal signal. Link: https://lkml.kernel.org/r/20201106231635.3528496-4-soheil.kdev@gmail.com Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com> Suggested-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Khazhismel Kumykov <khazhy@google.com> Cc: Guantao Liu <guantaol@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2efdaf7 commit cccd29b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fs/eventpoll.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,14 @@ static int ep_send_events(struct eventpoll *ep,
16251625
poll_table pt;
16261626
int res = 0;
16271627

1628+
/*
1629+
* Always short-circuit for fatal signals to allow threads to make a
1630+
* timely exit without the chance of finding more events available and
1631+
* fetching repeatedly.
1632+
*/
1633+
if (fatal_signal_pending(current))
1634+
return -EINTR;
1635+
16281636
init_poll_funcptr(&pt, NULL);
16291637

16301638
mutex_lock(&ep->mtx);
@@ -1846,15 +1854,6 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
18461854
}
18471855

18481856
send_events:
1849-
if (fatal_signal_pending(current)) {
1850-
/*
1851-
* Always short-circuit for fatal signals to allow
1852-
* threads to make a timely exit without the chance of
1853-
* finding more events available and fetching
1854-
* repeatedly.
1855-
*/
1856-
return -EINTR;
1857-
}
18581857
/*
18591858
* Try to transfer events to user space. In case we get 0 events and
18601859
* there's still timeout left over, we go trying again in search of

0 commit comments

Comments
 (0)