Messages in this thread | | | From | David Laight <> | Subject | RE: [net-next,v3] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy | Date | Tue, 10 Jul 2018 09:17:27 +0000 |
| |
From: Jon Maxwell > Sent: 10 July 2018 07:52 ... > +static __u32 tcp_clamp_rto_to_user_timeout(struct sock *sk) > +{ > + struct inet_connection_sock *icsk = inet_csk(sk); > + __u32 elapsed, user_timeout; > + u32 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; > + user_timeout = jiffies_to_msecs(icsk->icsk_user_timeout); > + if (elapsed >= user_timeout) > + return 1; /* user timeout has passed; fire ASAP */ > + else > + return (icsk->icsk_rto < msecs_to_jiffies(user_timeout - elapsed)) ? > + icsk->icsk_rto : msecs_to_jiffies(user_timeout - elapsed);
You've not looked at what the above actually does - something like: msecs_to_jiffies() probably rounds up, the old code rounded down so dividing by HZ is probably right.
int new_tmo = icsk->icsk_user_timeout - (tcp_time_stamp(tcp_sk(sk)) - start_ts)/HZ;
if (new_tmo > (int) icsk->icsk_rto; return icsk->icsk_rto; return new_tmo <= 0 ? 1 : new_tmo; }
| |