From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933955AbdKAVWB (ORCPT ); Wed, 1 Nov 2017 17:22:01 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:35075 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933633AbdKAVVq (ORCPT ); Wed, 1 Nov 2017 17:21:46 -0400 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Neal Cardwell , Yuchung Cheng , Nandita Dukkipati , Willy Tarreau Subject: [PATCH 3.10 008/139] tcp: introduce tcp_rto_delta_us() helper for xmit timer fix Date: Wed, 1 Nov 2017 22:17:08 +0100 Message-Id: <1509571159-4405-9-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1509571159-4405-1-git-send-email-w@1wt.eu> References: <1509571159-4405-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Neal Cardwell commit e1a10ef7fa876f8510aaec36ea5c0cf34baba410 upstream. 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.) [This version of the commit was compiled and briefly tested based on top of v3.10.107.] Change-Id: I1ccfba0b00465454bf5ce22e6fef5f7b5dd94d15 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 Signed-off-by: Willy Tarreau --- include/net/tcp.h | 10 ++++++++++ net/ipv4/tcp_input.c | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 79cd118..c4db9ac 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1592,4 +1592,14 @@ struct tcp_request_sock_ops { extern void tcp_v4_init(void); extern void tcp_init(void); +/* At how many jiffies into the future should the RTO fire? */ +static inline s32 tcp_rto_delta(const struct sock *sk) +{ + const struct sk_buff *skb = tcp_write_queue_head(sk); + const u32 rto = inet_csk(sk)->icsk_rto; + const u32 rto_time_stamp = TCP_SKB_CB(skb)->when + rto; + + return (s32)(rto_time_stamp - tcp_time_stamp); +} + #endif /* _TCP_H */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 0680058..a36b7c5 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2972,9 +2972,7 @@ void tcp_rearm_rto(struct sock *sk) /* Offset the time elapsed after installing regular RTO */ if (icsk->icsk_pending == ICSK_TIME_EARLY_RETRANS || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) { - struct sk_buff *skb = tcp_write_queue_head(sk); - const u32 rto_time_stamp = TCP_SKB_CB(skb)->when + rto; - s32 delta = (s32)(rto_time_stamp - tcp_time_stamp); + s32 delta = tcp_rto_delta(sk); /* delta may not be positive if the socket is locked * when the retrans timer fires and is rescheduled. */ -- 2.8.0.rc2.1.gbe9624a