Commit e59d3c6
epoll: eliminate unnecessary lock for zero timeout
We call ep_events_available() under lock when timeout is 0, and then call
it without locks in the loop for the other cases.
Instead, call ep_events_available() without lock for all cases. For
non-zero timeouts, we will recheck after adding the thread to the wait
queue. For zero timeout cases, by definition, user is opportunistically
polling and will have to call epoll_wait again in the future.
Note that this lock was kept in c5a282e because the whole loop was
historically under lock.
This patch results in a 1% CPU/RPC reduction in RPC benchmarks.
Link: https://lkml.kernel.org/r/20201106231635.3528496-9-soheil.kdev@gmail.com
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Suggested-by: Eric Dumazet <edumazet@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 00b2763 commit e59d3c6
1 file changed
+12
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1743 | 1743 | | |
1744 | 1744 | | |
1745 | 1745 | | |
1746 | | - | |
| 1746 | + | |
1747 | 1747 | | |
1748 | 1748 | | |
1749 | 1749 | | |
| |||
1759 | 1759 | | |
1760 | 1760 | | |
1761 | 1761 | | |
1762 | | - | |
1763 | | - | |
1764 | | - | |
1765 | | - | |
| 1762 | + | |
1766 | 1763 | | |
1767 | 1764 | | |
1768 | | - | |
1769 | | - | |
1770 | | - | |
1771 | | - | |
1772 | 1765 | | |
1773 | 1766 | | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
1774 | 1777 | | |
1775 | 1778 | | |
1776 | 1779 | | |
| |||
1786 | 1789 | | |
1787 | 1790 | | |
1788 | 1791 | | |
1789 | | - | |
1790 | | - | |
1791 | | - | |
1792 | | - | |
1793 | 1792 | | |
1794 | 1793 | | |
1795 | 1794 | | |
| |||
0 commit comments