From patchwork Thu Aug 3 13:19:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 797217 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="B3pCxzyn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xNVzS4Mx2z9s7v for ; Thu, 3 Aug 2017 23:20:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751815AbdHCNUT (ORCPT ); Thu, 3 Aug 2017 09:20:19 -0400 Received: from mail-qt0-f174.google.com ([209.85.216.174]:36089 "EHLO mail-qt0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751804AbdHCNUQ (ORCPT ); Thu, 3 Aug 2017 09:20:16 -0400 Received: by mail-qt0-f174.google.com with SMTP id v29so7292746qtv.3 for ; Thu, 03 Aug 2017 06:20:15 -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=dhfxIVBYDOxH8ChmFFlCJc2hVVYZe+t1IvijA9LqkIE=; b=B3pCxzynDn0EqI/94l3hXsipJAI3wPZReZ6HE6FM5jR4AdwhN87yAsy7+fCppzJRZd l/6TslLcjESbeCDL8+vK+HL53iaXhpjLYqDO9JC8HGSyMXZIKREDD2OOlMZbsTQE6zhI i8I2FHhFSOGtDmSD96bbmjReCfUaQRSCJBMpQCMWR+SLmUqzsq+7B0xLf5/swsqPtgcD M0uxBP6FQpzuBhmHOtEOa7S2vPY76TyZRiRaHYDkAjrqkVT1OFqnyP4xXrjjstaXp9Fr YE6wrpb0s+SJadg2wK5h6G4KM7iZXNho2j7vBw77C18wWWswS9Op1XP3w1CmsJyBSfqv oMIA== 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=dhfxIVBYDOxH8ChmFFlCJc2hVVYZe+t1IvijA9LqkIE=; b=IW0NkJFovKL8wEI8d6au87ReUSE4QPm+HQHnjqiXuryL1tWyrd4Cl1xW3nz/CLiChX sugUIWfeA1pRGDb6CAAa31oz847ZCd6iUFv475qi6Z5PZOaRf8CNqdj1fG2f9sSe3+CI JaRwcmnR9dz1uny2YLWFoSYoh7RR5XCcwqWF1aoWRU8xgo9oHi2uHkPLBETV8Qig4Tnh 3r6go21PGlc1SNN0OG//k3PkPK63O68q+EwVeN+nvwgbE8MGOFJTHX4jlm5Wl9IXcOaf r5uTrV37Qbuaw5SJr1QGZefHzbnbDO1SiG02GPR425EhsJcjn1pJE14E7kunNySfjmli J/Gg== X-Gm-Message-State: AHYfb5hYvOxmfekOA6b6HlZbgy4j224eJcphIomVjdnZdTY+TU4sf/X2 10dUO3ICIdX/vt2q X-Received: by 10.200.40.197 with SMTP id j5mr2049412qtj.100.1501766414699; Thu, 03 Aug 2017 06:20:14 -0700 (PDT) Received: from joy.nyc.corp.google.com ([100.101.212.71]) by smtp.gmail.com with ESMTPSA id 58sm27347471qtu.88.2017.08.03.06.20.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Aug 2017 06:20:14 -0700 (PDT) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Nandita Dukkipati Subject: [PATCH v2 net 2/3] tcp: enable xmit timer fix by having TLP use time when RTO should fire Date: Thu, 3 Aug 2017 09:19:53 -0400 Message-Id: <20170803131954.15441-3-ncardwell@google.com> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog In-Reply-To: <20170803131954.15441-1-ncardwell@google.com> References: <20170803131954.15441-1-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Have tcp_schedule_loss_probe() base the TLP scheduling decision based on when the RTO *should* fire. This is to enable the upcoming xmit timer fix in this series, where tcp_schedule_loss_probe() cannot assume that the last timer installed was an RTO timer (because we are no longer doing the "rearm RTO, rearm RTO, rearm TLP" dance on every ACK). So tcp_schedule_loss_probe() must independently figure out when an RTO would want to fire. In the new TLP implementation following in this series, we cannot assume that icsk_timeout was set based on an RTO; after processing a cumulative ACK the icsk_timeout we see can be from a previous TLP or RTO. So we need to independently recalculate the RTO time (instead of reading it out of icsk_timeout). Removing this dependency on the nature of icsk_timeout makes things a little easier to reason about anyway. Note that the old and new code should be equivalent, since they are both saying: "if the RTO is in the future, but at an earlier time than the normal TLP time, then set the TLP timer to fire when the RTO would have fired". Fixes: 6ba8a3b19e76 ("tcp: Tail loss probe (TLP)") Signed-off-by: Neal Cardwell Signed-off-by: Yuchung Cheng Signed-off-by: Nandita Dukkipati Acked-by: Eric Dumazet --- net/ipv4/tcp_output.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 2f1588bf73da..cd8e257492c4 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2377,8 +2377,8 @@ bool tcp_schedule_loss_probe(struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); - u32 timeout, tlp_time_stamp, rto_time_stamp; u32 rtt = usecs_to_jiffies(tp->srtt_us >> 3); + u32 timeout, rto_delta_us; /* No consecutive loss probes. */ if (WARN_ON(icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)) { @@ -2417,14 +2417,10 @@ bool tcp_schedule_loss_probe(struct sock *sk) (rtt + (rtt >> 1) + TCP_DELACK_MAX)); timeout = max_t(u32, timeout, msecs_to_jiffies(10)); - /* If RTO is shorter, just schedule TLP in its place. */ - tlp_time_stamp = tcp_jiffies32 + timeout; - rto_time_stamp = (u32)inet_csk(sk)->icsk_timeout; - if ((s32)(tlp_time_stamp - rto_time_stamp) > 0) { - s32 delta = rto_time_stamp - tcp_jiffies32; - if (delta > 0) - timeout = delta; - } + /* If the RTO formula yields an earlier time, then use that time. */ + rto_delta_us = tcp_rto_delta_us(sk); /* How far in future is RTO? */ + if (rto_delta_us > 0) + timeout = min_t(u32, timeout, usecs_to_jiffies(rto_delta_us)); inet_csk_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout, TCP_RTO_MAX);