From patchwork Wed May 16 23:40:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuchung Cheng X-Patchwork-Id: 915015 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="JL4W0A+C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40mWCg2rY7z9s1B for ; Thu, 17 May 2018 09:41:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149AbeEPXlA (ORCPT ); Wed, 16 May 2018 19:41:00 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37076 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752139AbeEPXk5 (ORCPT ); Wed, 16 May 2018 19:40:57 -0400 Received: by mail-wr0-f196.google.com with SMTP id h5-v6so3735119wrm.4 for ; Wed, 16 May 2018 16:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gBEgR3aDu1GRkmjhbtnIZy7WAT62VMlhyEPNn4jyr2w=; b=JL4W0A+CPE33da9C05gJXDhTuF82ua18na2LpMP4WM7FtyukNPcTXZxgxbDUgbnzqr KwHFgLaQH90yfSU18O+2uAwT7Hj6rSL/gS8qfj61R8KiY1kgxGD1yTrCTqmpFbPx/UGg ReMNbWUgFLjZrkaUQOkV5GFhkyWQESnxasN9YMGnTDsAHaWdbjrMunILHKLPLUIJvxQm 50okz1M5pLA/e7crfHUzV50jjeXdXuRqtyRjxI443ykOAnE9XEHSQ5irbyCHUShT1MjL kmxKIP3UgnJnR8IyfC3PEn7Xsof/NY8MmJ0KrwaGPXXxATvmfBWwWy953KuR/HmVqGd2 cMCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gBEgR3aDu1GRkmjhbtnIZy7WAT62VMlhyEPNn4jyr2w=; b=Hc9r9bSGpGKwpjuurK08S9AHiLinJSy32SsOGohtPjFcX0maLvoPK1GgvOoRXZ46X/ KUpD0jTk9so0M71V5K1I8kKtjVSYqQasSyNxBTEsHdf51aqxZgjckZASsCpIVTuOa0C9 M2l2/GC0/8dySpeFwjGaB5/+DlOLbw7eDGXy1rzJOlPoC6GfyJFiThVSrQAJzp0TvTcb GigMvKL+Y2t0MDoC8j8a8ouRnOcgQwAikLClEYgIPCxzVO+DIT4HZsrppXTXl1p66ItM nOy3UxOPZdjXdl+dj+mMKpLa26whEOOUHP9m3w5L9j55y8zLuSO82gJDUcV2mzJ49t5g wh8g== X-Gm-Message-State: ALKqPwd+ZgYWsqEUgtNYNYTxZ0gN9oei67rFr1bOBdRt78DTrAUHUpvU UPeaSL7h0o5jr2UUGbMuZRpQag== X-Google-Smtp-Source: AB8JxZqUsrou3bkJTz5eQbyBSsCJzQ29QwYkFlPiCF2M2FWy885wU0LhI1YUpLbhjhGSFq3pYwh9Ow== X-Received: by 2002:adf:a9e6:: with SMTP id b93-v6mr2598630wrd.234.1526514055431; Wed, 16 May 2018 16:40:55 -0700 (PDT) Received: from ycheng2.svl.corp.google.com ([2620:15c:2c4:201:d660:6c0b:8a4f:4c77]) by smtp.gmail.com with ESMTPSA id b11-v6sm4796488wrf.50.2018.05.16.16.40.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 16:40:54 -0700 (PDT) From: Yuchung Cheng To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, ncardwell@google.com, soheil@google.com, priyarjha@google.com, Yuchung Cheng Subject: [PATCH net-next 8/8] tcp: don't mark recently sent packets lost on RTO Date: Wed, 16 May 2018 16:40:17 -0700 Message-Id: <20180516234017.172775-9-ycheng@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180516234017.172775-1-ycheng@google.com> References: <20180516234017.172775-1-ycheng@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org An RTO event indicates the head has not been acked for a long time after its last (re)transmission. But the other packets are not necessarily lost if they have been only sent recently (for example due to application limit). This patch would prohibit marking packets sent within an RTT to be lost on RTO event, using similar logic in TCP RACK detection. Normally the head (SND.UNA) would be marked lost since RTO should fire strictly after the head was sent. An exception is when the most recent RACK RTT measurement is larger than the (previous) RTO. To address this exception the head is always marked lost. Congestion control interaction: since we may not mark every packet lost, the congestion window may be more than 1 (inflight plus 1). But only one packet will be retransmitted after RTO, since tcp_retransmit_timer() calls tcp_retransmit_skb(...,segs=1). The connection still performs slow start from one packet (with Cubic congestion control). This commit was tested in an A/B test with Google web servers, and showed a reduction of 2% in (spurious) retransmits post timeout (SlowStartRetrans), and correspondingly reduced DSACKs (DSACKIgnoredOld) by 7%. Signed-off-by: Yuchung Cheng Signed-off-by: Neal Cardwell Reviewed-by: Eric Dumazet Reviewed-by: Soheil Hassas Yeganeh Reviewed-by: Priyaranjan Jha --- net/ipv4/tcp_input.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index ba8a8e3464aa..0bf032839548 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1929,11 +1929,11 @@ static bool tcp_is_rack(const struct sock *sk) static void tcp_timeout_mark_lost(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); - struct sk_buff *skb; + struct sk_buff *skb, *head; bool is_reneg; /* is receiver reneging on SACKs? */ - skb = tcp_rtx_queue_head(sk); - is_reneg = skb && (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED); + head = tcp_rtx_queue_head(sk); + is_reneg = head && (TCP_SKB_CB(head)->sacked & TCPCB_SACKED_ACKED); if (is_reneg) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSACKRENEGING); tp->sacked_out = 0; @@ -1943,9 +1943,13 @@ static void tcp_timeout_mark_lost(struct sock *sk) tcp_reset_reno_sack(tp); } + skb = head; skb_rbtree_walk_from(skb) { if (is_reneg) TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_ACKED; + else if (tcp_is_rack(sk) && skb != head && + tcp_rack_skb_timeout(tp, skb, 0) > 0) + continue; /* Don't mark recently sent ones lost yet */ tcp_mark_skb_lost(sk, skb); } tcp_verify_left_out(tp); @@ -1972,7 +1976,7 @@ void tcp_enter_loss(struct sock *sk) tcp_ca_event(sk, CA_EVENT_LOSS); tcp_init_undo(tp); } - tp->snd_cwnd = 1; + tp->snd_cwnd = tcp_packets_in_flight(tp) + 1; tp->snd_cwnd_cnt = 0; tp->snd_cwnd_stamp = tcp_jiffies32;