From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net-next 3/3] tcp: implement head drops in backlog queue Date: Wed, 21 Nov 2018 09:52:40 -0800 Message-ID: <20181121175240.6075-4-edumazet@google.com> References: <20181121175240.6075-1-edumazet@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: netdev , Jean-Louis Dupond , Neal Cardwell , Yuchung Cheng , Eric Dumazet , Eric Dumazet To: "David S . Miller" Return-path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:44759 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731013AbeKVE2M (ORCPT ); Wed, 21 Nov 2018 23:28:12 -0500 Received: by mail-pl1-f195.google.com with SMTP id s5-v6so6525177plq.11 for ; Wed, 21 Nov 2018 09:52:50 -0800 (PST) In-Reply-To: <20181121175240.6075-1-edumazet@google.com> Sender: netdev-owner@vger.kernel.org List-ID: Under high stress, and if GRO or coalescing does not help, we better make room in backlog queue to be able to keep latest packet coming. This generally helps fast recovery, given that we often receive packets in order. Signed-off-by: Eric Dumazet Tested-by: Jean-Louis Dupond Cc: Neal Cardwell Cc: Yuchung Cheng --- net/ipv4/tcp_ipv4.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 401e1d1cb904a4c7963d8baa419cfbf178593344..36c9d715bf2aa7eb7bf58b045bfeb85a2ec1a696 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1693,6 +1693,20 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) __skb_push(skb, hdrlen); } + while (sk_rcvqueues_full(sk, limit)) { + struct sk_buff *head; + + head = sk->sk_backlog.head; + if (!head) + break; + sk->sk_backlog.head = head->next; + if (!head->next) + sk->sk_backlog.tail = NULL; + skb_mark_not_on_list(head); + sk->sk_backlog.len -= head->truesize; + kfree_skb(head); + __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP); + } /* Only socket owner can try to collapse/prune rx queues * to reduce memory overhead, so add a little headroom here. * Few sockets backlog are possibly concurrently non empty. -- 2.19.1.1215.g8438c0b245-goog