From patchwork Tue Aug 1 02:58:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 796058 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="c3c+35ma"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xM1H80Vjfz9tWd for ; Tue, 1 Aug 2017 12:58:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751835AbdHAC6m (ORCPT ); Mon, 31 Jul 2017 22:58:42 -0400 Received: from mail-qt0-f180.google.com ([209.85.216.180]:35746 "EHLO mail-qt0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751725AbdHAC6l (ORCPT ); Mon, 31 Jul 2017 22:58:41 -0400 Received: by mail-qt0-f180.google.com with SMTP id p3so2154501qtg.2 for ; Mon, 31 Jul 2017 19:58:41 -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=hMQrCp9Mr4DPbbYIQv7dULeJwXhJ8Ygv11lEQPKUSc4=; b=c3c+35maI45LM90iQdgCKq26eD0oT2yIvouJskWk85Oxk/o5tQ4+CS+xs1DfkB5l1V w8i9hSN0Lp460q116gQyFfF3yotLXjIH5O2MnBFjioauMS1aPdZ39TSenicJY/o/Vhtl XYZAvrlbWgQnNPkIL0PifiZnoqqYEX91dljVSMikF0q3cJmupjEvK4HFPC7zEJ7VjFBV fmOSKOgZhU7aTkeNwe9wpwpq5EPodTfhhzQN9TsOR2VcwIjpo2f0E5Bj62m88FzXvMVb hZCBGWDY4eSFCUcxwtCrggreTgRAus5Ws149gFWq/NzYc6vrybREmL8m/9CAKTo/IGAt qNHw== 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=hMQrCp9Mr4DPbbYIQv7dULeJwXhJ8Ygv11lEQPKUSc4=; b=TqzOSRz68RJH1LUjPX6QrJrkcxhzEIOxnFjAKdz+d70ZJg+3fa3akm4zt3uIWQnFLn CqOF1vVT0AgQ5QW7GYC0Jqao7xo+Xci81hxgv3xlh1ukimgJ2zhfHwlISeSgKIqJqcNS QHjC9j1z/BjnAWphsGZwxiadDZ5C85eHvNO+ypFFol1/qBwVuJqTXm+GMy0Ox79TmmVG gicDY9/j3SZHhhy0KC08PGO5BPeEgqh282x4Uz3Zg/ORGbzCAlC8N3zrT5Cx3dohA31X gkJKUoIPa5rLmHmG1obueGDIHMPI3PW+ly78NMDKyredL2Yv1S44msrjjWK8tkXkRp9d 6Jyg== X-Gm-Message-State: AIVw112MIf17GKKa2OhOFGUUvyKAS58CD4eNJky4XZWImaxi4axj7VTW d5yu4nXruPzokgej X-Received: by 10.200.47.146 with SMTP id l18mr23804126qta.176.1501556320514; Mon, 31 Jul 2017 19:58:40 -0700 (PDT) Received: from joy.nyc.corp.google.com ([100.101.212.71]) by smtp.gmail.com with ESMTPSA id 94sm17134390qte.55.2017.07.31.19.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 19:58:39 -0700 (PDT) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Nandita Dukkipati Subject: [PATCH net 2/3] tcp: enable xmit timer fix by having TLP use time when RTO should fire Date: Mon, 31 Jul 2017 22:58:13 -0400 Message-Id: <20170801025814.31206-3-ncardwell@google.com> X-Mailer: git-send-email 2.14.0.rc0.400.g1c36432dff-goog In-Reply-To: <20170801025814.31206-1-ncardwell@google.com> References: <20170801025814.31206-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 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 2f1588bf73da..0ae6b5d176c0 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)) { @@ -2418,13 +2418,9 @@ bool tcp_schedule_loss_probe(struct sock *sk) 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; - } + 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);