Skip to content

Commit 2fe11c9

Browse files
isilencekuba-moo
authored andcommitted
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@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/80736a2cc6d478c383ea565ba825eaf4d1abd876.1687523671.git.asml.silence@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3f5f118 commit 2fe11c9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
839839
tss.len -= ret;
840840
spliced += ret;
841841

842-
if (!timeo)
842+
if (!tss.len || !timeo)
843843
break;
844844
release_sock(sk);
845845
lock_sock(sk);

0 commit comments

Comments
 (0)