Skip to content

Commit

Permalink
tcp: small optimization in tcp recvmsg()
Browse files Browse the repository at this point in the history
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 <edumazet@google.com>
  • Loading branch information
Eric Dumazet authored and xanmod committed Jan 12, 2022
1 parent 0509189 commit 06dcd20
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/ipv4/tcp.c
Expand Up @@ -2413,8 +2413,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);
}
Expand Down

0 comments on commit 06dcd20

Please sign in to comment.