From: Eric Dumazet Date: Mon, 15 Nov 2021 19:02:48 +0000 (-0800) Subject: tcp: do not call tcp_cleanup_rbuf() if we have a backlog X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=29fbc26e6dfc7be351c23261938de3f93f5cde57;p=linux.git tcp: do not call tcp_cleanup_rbuf() if we have a backlog Under pressure, tcp recvmsg() has logic to process the socket backlog, but calls tcp_cleanup_rbuf() right before. Avoiding sending ACK right before processing new segments makes a lot of sense, as this decrease the number of ACK packets, with no impact on effective ACK clocking. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7b1886103556e..d1949fdb1462b 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2436,12 +2436,11 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len, } } - tcp_cleanup_rbuf(sk, copied); - if (copied >= target) { /* Do not sleep, just process backlog. */ __sk_flush_backlog(sk); } else { + tcp_cleanup_rbuf(sk, copied); sk_defer_free_flush(sk); sk_wait_data(sk, &timeo, last); }