]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.175/fs-epoll-drop-ovflist-branch-prediction.patch
Linux 4.14.121
[thirdparty/kernel/stable-queue.git] / releases / 4.4.175 / fs-epoll-drop-ovflist-branch-prediction.patch
CommitLineData
809ae055
SL
1From c4d4bea2c452e16e0ff6efe8b3d148ac188f3e8a Mon Sep 17 00:00:00 2001
2From: Davidlohr Bueso <dave@stgolabs.net>
3Date: Thu, 3 Jan 2019 15:27:09 -0800
4Subject: fs/epoll: drop ovflist branch prediction
5
6[ Upstream commit 76699a67f3041ff4c7af6d6ee9be2bfbf1ffb671 ]
7
8The ep->ovflist is a secondary ready-list to temporarily store events
9that might occur when doing sproc without holding the ep->wq.lock. This
10accounts for every time we check for ready events and also send events
11back to userspace; both callbacks, particularly the latter because of
12copy_to_user, can account for a non-trivial time.
13
14As such, the unlikely() check to see if the pointer is being used, seems
15both misleading and sub-optimal. In fact, we go to an awful lot of
16trouble to sync both lists, and populating the ovflist is far from an
17uncommon scenario.
18
19For example, profiling a concurrent epoll_wait(2) benchmark, with
20CONFIG_PROFILE_ANNOTATED_BRANCHES shows that for a two threads a 33%
21incorrect rate was seen; and when incrementally increasing the number of
22epoll instances (which is used, for example for multiple queuing load
23balancing models), up to a 90% incorrect rate was seen.
24
25Similarly, by deleting the prediction, 3% throughput boost was seen
26across incremental threads.
27
28Link: http://lkml.kernel.org/r/20181108051006.18751-4-dave@stgolabs.net
29Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
30Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
31Cc: Al Viro <viro@zeniv.linux.org.uk>
32Cc: Jason Baron <jbaron@akamai.com>
33Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
34Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
35Signed-off-by: Sasha Levin <sashal@kernel.org>
36---
37 fs/eventpoll.c | 2 +-
38 1 file changed, 1 insertion(+), 1 deletion(-)
39
40diff --git a/fs/eventpoll.c b/fs/eventpoll.c
41index 1b08556776ce..240d9ceb8d0c 100644
42--- a/fs/eventpoll.c
43+++ b/fs/eventpoll.c
44@@ -1034,7 +1034,7 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
45 * semantics). All the events that happen during that period of time are
46 * chained in ep->ovflist and requeued later on.
47 */
48- if (unlikely(ep->ovflist != EP_UNACTIVE_PTR)) {
49+ if (ep->ovflist != EP_UNACTIVE_PTR) {
50 if (epi->next == EP_UNACTIVE_PTR) {
51 epi->next = ep->ovflist;
52 ep->ovflist = epi;
53--
542.19.1
55