[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5f34e43135ed4948bbc32849289aeb20@AcuMS.aculab.com>
Date: Tue, 10 Jul 2018 09:17:27 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jon Maxwell' <jmaxwell37@...il.com>,
"davem@...emloft.net" <davem@...emloft.net>
CC: "edumazet@...gle.com" <edumazet@...gle.com>,
"eric.dumazet@...il.com" <eric.dumazet@...il.com>,
"ncardwell@...gle.com" <ncardwell@...gle.com>,
"kuznet@....inr.ac.ru" <kuznet@....inr.ac.ru>,
"yoshfuji@...ux-ipv6.org" <yoshfuji@...ux-ipv6.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"jmaxwell@...hat.com" <jmaxwell@...hat.com>
Subject: RE: [net-next,v3] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy
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;
}
Powered by blists - more mailing lists