[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <80736a2cc6d478c383ea565ba825eaf4d1abd876.1687523671.git.asml.silence@gmail.com>
Date: Fri, 23 Jun 2023 13:38:55 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: netdev@...r.kernel.org,
edumazet@...gle.com,
davem@...emloft.net,
dsahern@...nel.org,
pabeni@...hat.com,
kuba@...nel.org
Cc: Pavel Begunkov <asml.silence@...il.com>
Subject: [PATCH net-next v2] net/tcp: optimise locking for blocking splice
Even when tcp_splice_read() reads all it was asked for, for blocking
sockets it'll release and immediately regrab the socket lock, loop
around and break on the while check.
Check tss.len right after we adjust it, and return if we're done.
That saves us one release_sock(); lock_sock(); pair per successful
blocking splice read.
Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
---
v2: go with Paolo's suggestion
aggressively shrink the patch
net/ipv4/tcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 71b42eef9dbf..d56edc2c885f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -839,7 +839,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
tss.len -= ret;
spliced += ret;
- if (!timeo)
+ if (!tss.len || !timeo)
break;
release_sock(sk);
lock_sock(sk);
--
2.40.0
Powered by blists - more mailing lists