Messages in this thread | | | From | Jonathan Maxwell <> | Date | Thu, 5 Jul 2018 09:34:23 +1000 | Subject | Re: [net-next,v2] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy |
| |
Let's wait for Eric to review. Then I'll put together the next version.
Regards
Jon
On Thu, Jul 5, 2018 at 12:57 AM, David Laight <David.Laight@aculab.com> wrote: > From: Neal Cardwell >> Sent: 04 July 2018 15:14 >> >> On Tue, Jul 3, 2018 at 8:06 PM Jon Maxwell <jmaxwell37@gmail.com> wrote: >> > >> > Signed-off-by: Jon Maxwell <jmaxwell37@gmail.com> >> > --- >> > net/ipv4/tcp_timer.c | 48 +++++++++++++++++++++++++++++++++++++++--------- >> > 1 file changed, 39 insertions(+), 9 deletions(-) >> > >> > diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c >> > index 3b3611729928..d129e670d02a 100644 >> > --- a/net/ipv4/tcp_timer.c >> > +++ b/net/ipv4/tcp_timer.c > ... >> > +static __u32 tcp_clamp_rto_to_user_timeout(struct sock *sk) >> > +{ >> > + struct inet_connection_sock *icsk = inet_csk(sk); >> > + __u32 rto = icsk->icsk_rto; > > Why cache rto past all the function calls until it is needed? > >> > + __u32 elapsed, user_timeout; >> > + unsigned int start_ts; >> >> I'd suggest u32 here for start_ts (per the rationale above). >> >> > + >> > + start_ts = tcp_retransmit_stamp(sk); >> > + if (!icsk->icsk_user_timeout || !start_ts) >> > + return rto; >> > + elapsed = tcp_time_stamp(tcp_sk(sk)) - start_ts; >> > + user_timeout = jiffies_to_msecs(icsk->icsk_user_timeout); >> > + if (elapsed >= user_timeout) >> > + rto = 1; /* user timeout has passed; fire ASAP */ >> > + else >> > + rto = min(rto, (__u32)msecs_to_jiffies(user_timeout - elapsed)); >> >> My sense is that min_t would be preferred here, e.g: >> >> rto = min_t(__u32, rto, msecs_to_jiffies(user_timeout - elapsed)); > > Think I'd just write the conditional... > >> > + return rto; >> > +} > > Looks to me like it doesn't correctly allow for the conversions > between millisecond and jiffies either. > I suspect the msecs_to_jiffies() call can return zero (unless it rounds up). > Coding with a signed 'time until user timeout' might make it simpler. > > David > >
| |