From: Eric Dumazet Date: Mon, 15 Nov 2021 19:02:40 +0000 (-0800) Subject: tcp: small optimization in tcp recvmsg() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=93afcfd1db35882921b2521a637c78755c27b02c;p=linux.git tcp: small optimization in tcp recvmsg() When reading large chunks of data, incoming packets might be added to the backlog from BH. tcp recvmsg() detects the backlog queue is not empty, and uses a release_sock()/lock_sock() pair to process this backlog. We now have __sk_flush_backlog() to perform this a bit faster. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 862e8cb8dda51..24d77a32c9cbc 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2409,8 +2409,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len, if (copied >= target) { /* Do not sleep, just process backlog. */ - release_sock(sk); - lock_sock(sk); + __sk_flush_backlog(sk); } else { sk_wait_data(sk, &timeo, last); }