From patchwork Tue Aug 1 02:58:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 796057 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="WOeEZOVI"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xM1Gx4qzMz9tWd for ; Tue, 1 Aug 2017 12:58:33 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbdHAC6a (ORCPT ); Mon, 31 Jul 2017 22:58:30 -0400 Received: from mail-qk0-f181.google.com ([209.85.220.181]:37515 "EHLO mail-qk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751725AbdHAC63 (ORCPT ); Mon, 31 Jul 2017 22:58:29 -0400 Received: by mail-qk0-f181.google.com with SMTP id z18so2127171qka.4 for ; Mon, 31 Jul 2017 19:58:29 -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=1NJ95SbYCh/UHzZmusXb56wksuyjpm1vOAGkiBPkJAc=; b=WOeEZOVIL7GTjM7GQtNPlR1EfOSSwedPe/a6ishYTrAu9VFR2WaD/wFaSiCjAfR9HK YOA9pZNCn9+J7ErKUNEO4ctWg3MaR0zuEdg5IaOAC5slkA+JSPA/CuHK+CBR1DnIgwHv QV1PVXXLGzEVKkpLTUkf5NGh+EKNIA9nx0JLk+ApScPuvhbJCLjJiUIXV3pjPkuuuVAX faj/uZFBfvaXW+wu9MoCeIDNcd0GG6Wt2jBdZisIpt9PzZrdArnBXAvgzVeLHjJyA+xU lVSOmqGvPnN8oWDwLm8JEQ2/rJdmHxzAr7259LANUQLRC96KXwnJ3efz+g/PB9v6589m Vf5A== 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=1NJ95SbYCh/UHzZmusXb56wksuyjpm1vOAGkiBPkJAc=; b=jZbSL357TO0Tcm+pNMn27foUyUz/VE6tJEEw4XBb3txik54DCTRVcbr0Jy2cHKpygm z9WbygtLwMVtpfOXjTb9lP3F+9R5sc7pD3L1gys0zxYq0DHeVLZ1gfU1a+6P815Nh4WP l9mUbiuT3QVdsavrM9kEwwmdGMBJlIAppxl/Gio0sGay+kWxfG54TK6yKZnLwtSdE8ft DfHrgDCv7kxzwb6bP7YI/+j/IffW3HrIh1Y4EOpPEP3z3ftajCbReKu5RmUZHOUgL6dY HISZXHydWuTRw7jwnUC0bn9DtsUwY1q+sqwZKwp30IeVMFPNmn6wrY2p7RLWSbeTlB80 4FvA== X-Gm-Message-State: AIVw111wEYHMX1AZTnNjtDWpQzdfSxmoKMKX/7M1lkLal6n2UA8z/mzH va+Uq82H7OhPoFJV X-Received: by 10.55.170.205 with SMTP id t196mr22323672qke.106.1501556308528; Mon, 31 Jul 2017 19:58:28 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 19:58:27 -0700 (PDT) From: Neal Cardwell To: David Miller Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Nandita Dukkipati Subject: [PATCH net 1/3] tcp: introduce tcp_rto_delta_us() helper for xmit timer fix Date: Mon, 31 Jul 2017 22:58:12 -0400 Message-Id: <20170801025814.31206-2-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 Pure refactor. This helper will be required in the xmit timer fix later in the patch series. (Because the TLP logic will want to make this calculation.) 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 --- include/net/tcp.h | 10 ++++++++++ net/ipv4/tcp_input.c | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 70483296157f..ada65e767b28 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1916,6 +1916,16 @@ extern void tcp_rack_advance(struct tcp_sock *tp, u8 sacked, u32 end_seq, u64 xmit_time); extern void tcp_rack_reo_timeout(struct sock *sk); +/* At how many usecs into the future should the RTO fire? */ +static inline s64 tcp_rto_delta_us(const struct sock *sk) +{ + const struct sk_buff *skb = tcp_write_queue_head(sk); + u32 rto = inet_csk(sk)->icsk_rto; + u64 rto_time_stamp_us = skb->skb_mstamp + jiffies_to_usecs(rto); + + return rto_time_stamp_us - tcp_sk(sk)->tcp_mstamp; +} + /* * Save and compile IPv4 options, return a pointer to it */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2920e0cb09f8..345febf0a46e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3004,10 +3004,7 @@ void tcp_rearm_rto(struct sock *sk) /* Offset the time elapsed after installing regular RTO */ if (icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) { - struct sk_buff *skb = tcp_write_queue_head(sk); - u64 rto_time_stamp = skb->skb_mstamp + - jiffies_to_usecs(rto); - s64 delta_us = rto_time_stamp - tp->tcp_mstamp; + s64 delta_us = tcp_rto_delta_us(sk); /* delta_us may not be positive if the socket is locked * when the retrans timer fires and is rescheduled. */