Skip to content

Commit e8c8532

Browse files
soheilhytorvalds
authored andcommitted
epoll: pull all code between fetch_events and send_event into the loop
This is a no-op change which simplifies the follow up patches. Link: https://lkml.kernel.org/r/20201106231635.3528496-7-soheil.kdev@gmail.com Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> 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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1493c47 commit e8c8532

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

fs/eventpoll.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,14 +1774,14 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
17741774
}
17751775

17761776
fetch_events:
1777-
eavail = ep_events_available(ep);
1778-
if (!eavail)
1779-
eavail = ep_busy_loop(ep, timed_out);
1777+
do {
1778+
eavail = ep_events_available(ep);
1779+
if (!eavail)
1780+
eavail = ep_busy_loop(ep, timed_out);
17801781

1781-
if (eavail)
1782-
goto send_events;
1782+
if (eavail)
1783+
goto send_events;
17831784

1784-
do {
17851785
if (signal_pending(current))
17861786
return -EINTR;
17871787

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

1835-
if (!list_empty_careful(&wait.entry)) {
1836-
write_lock_irq(&ep->lock);
1837-
/*
1838-
* If the thread timed out and is not on the wait queue, it
1839-
* means that the thread was woken up after its timeout expired
1840-
* before it could reacquire the lock. Thus, when wait.entry is
1841-
* empty, it needs to harvest events.
1842-
*/
1843-
if (timed_out)
1844-
eavail = list_empty(&wait.entry);
1845-
__remove_wait_queue(&ep->wq, &wait);
1846-
write_unlock_irq(&ep->lock);
1847-
}
1834+
if (!list_empty_careful(&wait.entry)) {
1835+
write_lock_irq(&ep->lock);
1836+
/*
1837+
* If the thread timed out and is not on the wait queue,
1838+
* it means that the thread was woken up after its
1839+
* timeout expired before it could reacquire the lock.
1840+
* Thus, when wait.entry is empty, it needs to harvest
1841+
* events.
1842+
*/
1843+
if (timed_out)
1844+
eavail = list_empty(&wait.entry);
1845+
__remove_wait_queue(&ep->wq, &wait);
1846+
write_unlock_irq(&ep->lock);
1847+
}
1848+
} while (0);
18481849

18491850
send_events:
18501851
/*

0 commit comments

Comments
 (0)