From: David Laight <David.Laight@ACULAB.COM>
To: 'Jon Maxwell' <jmaxwell37@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>
Cc: "edumazet@google.com" <edumazet@google.com>,
"eric.dumazet@gmail.com" <eric.dumazet@gmail.com>,
"ncardwell@google.com" <ncardwell@google.com>,
"kuznet@ms2.inr.ac.ru" <kuznet@ms2.inr.ac.ru>,
"yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jmaxwell@redhat.com" <jmaxwell@redhat.com>
Subject: RE: [net-next,v3] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy
Date: Tue, 10 Jul 2018 09:17:27 +0000 [thread overview]
Message-ID: <5f34e43135ed4948bbc32849289aeb20@AcuMS.aculab.com> (raw)
In-Reply-To: <20180710065147.27647-1-jmaxwell37@gmail.com>
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;
}
next prev parent reply other threads:[~2018-07-10 9:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-10 6:51 [net-next,v3] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy Jon Maxwell
2018-07-10 9:17 ` David Laight [this message]
2018-07-10 12:38 ` Eric Dumazet
2018-07-10 12:48 ` Eric Dumazet
2018-07-11 0:33 ` Jonathan Maxwell
2018-07-11 2:04 ` Eric Dumazet
2018-07-11 2:34 ` Jonathan Maxwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f34e43135ed4948bbc32849289aeb20@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=jmaxwell37@gmail.com \
--cc=jmaxwell@redhat.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).