From 29fbc26e6dfc7be351c23261938de3f93f5cde57 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 15 Nov 2021 11:02:48 -0800 Subject: [PATCH] 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 --- net/ipv4/tcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7b1886103556..d1949fdb1462 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); }