From: Jonathan Maxwell <jmaxwell37@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: Neal Cardwell <ncardwell@google.com>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
Netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"jmaxwell@redhat.com" <jmaxwell@redhat.com>
Subject: Re: [net-next,v2] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy
Date: Thu, 5 Jul 2018 09:34:23 +1000 [thread overview]
Message-ID: <CAGHK07Afdys4WHEjsekSChbFVGwWVccofSS+Bk357m8=1BfJBw@mail.gmail.com> (raw)
In-Reply-To: <2a78c5cbb53248289b54505aece15584@AcuMS.aculab.com>
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
>
>
next prev parent reply other threads:[~2018-07-04 23:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 0:06 [net-next,v2] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy Jon Maxwell
2018-07-04 14:13 ` Neal Cardwell
2018-07-04 14:57 ` David Laight
2018-07-04 23:34 ` Jonathan Maxwell [this message]
2018-07-10 5:03 ` Eric Dumazet
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='CAGHK07Afdys4WHEjsekSChbFVGwWVccofSS+Bk357m8=1BfJBw@mail.gmail.com' \
--to=jmaxwell37@gmail.com \
--cc=David.Laight@aculab.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.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).