All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: tingw.liu@gmail.com, netdev@vger.kernel.org, kuznet@ms2.inr.ac.ru
Subject: Re: [PATCH net-next] tcp:elapsed variable calculated twice while keepalive working
Date: Fri, 09 Aug 2013 14:06:39 -0700	[thread overview]
Message-ID: <1376082399.20509.12.camel@edumazet-glaptop> (raw)
In-Reply-To: <20130809.111229.1955078847385749897.davem@davemloft.net>

On Fri, 2013-08-09 at 11:12 -0700, David Miller wrote:
> From: Tingwei Liu <tingw.liu@gmail.com>
> Date: Tue,  6 Aug 2013 20:38:58 +0800
> 
> > When tcp keepalive working elapsed calculated twice while the first time is not needed!
> > 
> > CC: Eric Dumazet <eric.dumazet@gmail.com>
> > CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
> > Signed-off-by: Tingwei Liu <tingw.liu@gmail.com>
> 
> 
> Please put a space after "tcp:" in your Subject line prefixes, it looks
> awful the way you've done it here.
> 
> > @@ -591,11 +591,11 @@ static void tcp_keepalive_timer (unsigned long data)
> >  	if (!sock_flag(sk, SOCK_KEEPOPEN) || sk->sk_state == TCP_CLOSE)
> >  		goto out;
> >  
> > -	elapsed = keepalive_time_when(tp);
> > -
> >  	/* It is alive without keepalive 8) */
> > -	if (tp->packets_out || tcp_send_head(sk))
> > +	if (tp->packets_out || tcp_send_head(sk)) {
> > +		elapsed = keepalive_time_when(tp);
> >  		goto resched;
> > +	}
> >  
> >  	elapsed = keepalive_time_elapsed(tp);
> 
> This is overkill, just delete the second assignment.  Your version makes
> the code look less elegant and also makes it harder to audit.
> --

As a matter of fact, 
keepalive_time_when(tp) and keepalive_time_elapsed(tp) are different ;)

This is very slow path in TCP stack, so it should not matter a lot.

 

  reply	other threads:[~2013-08-09 21:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 12:38 [PATCH net-next] tcp:elapsed variable calculated twice while keepalive working Tingwei Liu
2013-08-09 18:12 ` David Miller
2013-08-09 21:06   ` Eric Dumazet [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-08-06 12:05 Tingwei Liu
2013-08-06 12:23 ` Eric Dumazet
2013-08-06 12:29   ` tingwei liu

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=1376082399.20509.12.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@vger.kernel.org \
    --cc=tingw.liu@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.