Skip to content

Commit

Permalink
epoll: pull all code between fetch_events and send_event into the loop
Browse files Browse the repository at this point in the history
This is a no-op change which simplifies the follow up patches.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Soheil Hassas Yeganeh <[email protected]>
Suggested-by: Linus Torvalds <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Reviewed-by: Willem de Bruijn <[email protected]>
Reviewed-by: Khazhismel Kumykov <[email protected]>
Cc: Guantao Liu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
soheilhy authored and torvalds committed Dec 19, 2020
1 parent 1493c47 commit e8c8532
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -1774,14 +1774,14 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
}

fetch_events:
eavail = ep_events_available(ep);
if (!eavail)
eavail = ep_busy_loop(ep, timed_out);
do {
eavail = ep_events_available(ep);
if (!eavail)
eavail = ep_busy_loop(ep, timed_out);

if (eavail)
goto send_events;
if (eavail)
goto send_events;

do {
if (signal_pending(current))
return -EINTR;

Expand Down Expand Up @@ -1830,21 +1830,22 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
* carefully under lock, below.
*/
eavail = 1;
} while (0);

if (!list_empty_careful(&wait.entry)) {
write_lock_irq(&ep->lock);
/*
* If the thread timed out and is not on the wait queue, it
* means that the thread was woken up after its timeout expired
* before it could reacquire the lock. Thus, when wait.entry is
* empty, it needs to harvest events.
*/
if (timed_out)
eavail = list_empty(&wait.entry);
__remove_wait_queue(&ep->wq, &wait);
write_unlock_irq(&ep->lock);
}
if (!list_empty_careful(&wait.entry)) {
write_lock_irq(&ep->lock);
/*
* If the thread timed out and is not on the wait queue,
* it means that the thread was woken up after its
* timeout expired before it could reacquire the lock.
* Thus, when wait.entry is empty, it needs to harvest
* events.
*/
if (timed_out)
eavail = list_empty(&wait.entry);
__remove_wait_queue(&ep->wq, &wait);
write_unlock_irq(&ep->lock);
}
} while (0);

send_events:
/*
Expand Down

0 comments on commit e8c8532

Please sign in to comment.