tcp: convert icsk_user_timeout from jiffies to msecs
Subsystems (3)
PATCH 3/3 tcp: convert icsk_user_timeout from jiffies to msecs
The final patch in this series. Create the tcp_clamp_rto_to_user_timeout() helper routine. To calculate the correct rto, so that the TCP_USER_TIMEOUT socket option is more accurate. Taking suggestions and feedback into account from Eric Dumazet, Neal Cardwell and David Laight. Due to the 1st commit we can avoid the msecs_to_jiffies() and jiffies_to_msecs() dance.
--- net/ipv4/tcp_timer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
net/ipv4/tcp_timer.c +18 -1
@@ -36,6 +36,22 @@ u32 tcp_retransmit_stamp(const struct sock *sk)return start_ts; } +static u32 tcp_clamp_rto_to_user_timeout (const struct sock *sk) +{ +struct inet_connection_sock *icsk =inet_csk (sk); +u32 elapsed, start_ts; + + start_ts =tcp_retransmit_stamp (sk); +if (!icsk->icsk_user_timeout || !start_ts) +return icsk->icsk_rto; + elapsed =tcp_time_stamp (tcp_sk (sk)) - start_ts; +if (elapsed >= icsk->icsk_user_timeout) +return 1 ;/* user timeout has passed; fire ASAP */ +else +return min_t (u32, icsk->icsk_rto,msecs_to_jiffies (icsk->icsk_user_timeout - + elapsed)); +} +/** * tcp_write_err() - close socket and save error info * @sk: The socket the error has appeared on.
@@ -544,7 +560,8 @@ void tcp_retransmit_timer(struct sock *sk)/* Use normal (exponential) backoff */ icsk->icsk_rto =min (icsk->icsk_rto <<1 ,TCP_RTO_MAX ); } -inet_csk_reset_xmit_timer (sk,ICSK_TIME_RETRANS , icsk->icsk_rto,TCP_RTO_MAX ); +inet_csk_reset_xmit_timer (sk,ICSK_TIME_RETRANS , +tcp_clamp_rto_to_user_timeout (sk),TCP_RTO_MAX );if (retransmits_timed_out (sk, net->ipv4.sysctl_tcp_retries1 +1 ,0 ))__sk_dst_reset (sk);
Signature · 1 line
2.13.6
Quoted 23 lines · Jon Maxwell
The final patch in this series. Create the
tcp_clamp_rto_to_user_timeout()helper routine. To calculate the correct rto, so that theTCP_USER_TIMEOUTsocket option is more accurate. Taking suggestions and feedback into account from Eric Dumazet, Neal Cardwell and David Laight. Due to the 1st commit we can avoid themsecs_to_jiffies()andjiffies_to_msecs()dance.Signed-off-by Jon Maxwell <[email protected]>--- net/ipv4/tcp_timer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/tcp_timer.c +4
-0@@ -36,6 +36,22 @@ u32 tcp_retransmit_stamp(const struct sock *sk)return start_ts; } +static u32 tcp_clamp_rto_to_user_timeout (const struct sock *sk) +{ +struct inet_connection_sock *icsk =inet_csk (sk); +u32 elapsed, start_ts;
net/ipv4/tcp_timer.c u32 tcp_retransmit_stamp(const struct sock *sk) · line 52
Quoted 10 lines
net/ipv4/tcp_timer.c +10
-0+ + start_ts =tcp_retransmit_stamp (sk); +if (!icsk->icsk_user_timeout || !start_ts) +return icsk->icsk_rto; + elapsed =tcp_time_stamp (tcp_sk (sk)) - start_ts; +if (elapsed >= icsk->icsk_user_timeout) +return 1 ;/* user timeout has passed; fire ASAP */ +else +return min_t (u32, icsk->icsk_rto,msecs_to_jiffies (icsk->icsk_user_timeout - + elapsed));
if (elapsed >= icsk->icsk_user_timeout) return 1; /* user timeout has passed; fire ASAP */ return min_t(u32, icsk->icsk_rto, msecs_to_jiffies(icsk->icsk_user_timeout - elapsed));
Thanks !
Sorry Eric, my bad. I'll do another version with the indentation fixed and reformatting of min_t() and resubmit.
Quoted 43 lines · Eric Dumazet
Quoted 23 lines · Jon Maxwell
The final patch in this series. Create the
tcp_clamp_rto_to_user_timeout()helper routine. To calculate the correct rto, so that theTCP_USER_TIMEOUTsocket option is more accurate. Taking suggestions and feedback into account from Eric Dumazet, Neal Cardwell and David Laight. Due to the 1st commit we can avoid themsecs_to_jiffies()andjiffies_to_msecs()dance.Signed-off-by Jon Maxwell <[email protected]>--- net/ipv4/tcp_timer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)net/ipv4/tcp_timer.c +4
-0@@ -36,6 +36,22 @@ u32 tcp_retransmit_stamp(const struct sock *sk)return start_ts; } +static u32 tcp_clamp_rto_to_user_timeout (const struct sock *sk) +{ +struct inet_connection_sock *icsk =inet_csk (sk); +u32 elapsed, start_ts;net/ipv4/tcp_timer.c u32 tcp_retransmit_stamp(const struct sock *sk) · line 52
Quoted 10 lines
net/ipv4/tcp_timer.c +10
-0+ + start_ts =tcp_retransmit_stamp (sk); +if (!icsk->icsk_user_timeout || !start_ts) +return icsk->icsk_rto; + elapsed =tcp_time_stamp (tcp_sk (sk)) - start_ts; +if (elapsed >= icsk->icsk_user_timeout) +return 1 ;/* user timeout has passed; fire ASAP */ +else +return min_t (u32, icsk->icsk_rto,msecs_to_jiffies (icsk->icsk_user_timeout - + elapsed));if (elapsed >= icsk->icsk_user_timeout) return 1; /* user timeout has passed; fire ASAP */ return min_t(u32, icsk->icsk_rto, msecs_to_jiffies(icsk->icsk_user_timeout - elapsed));Thanks !