[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0712311559170.4163@kivilampi-30.cs.helsinki.fi>
Date: Mon, 31 Dec 2007 16:17:58 +0200 (EET)
From: "Ilpo Järvinen" <ilpo.jarvinen@...sinki.fi>
To: David Miller <davem@...emloft.net>
cc: Netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH 3/9] [TCP]: Remove unnecessary local variables
On Mon, 31 Dec 2007, David Miller wrote:
> From: "Ilpo_Järvinen" <ilpo.jarvinen@...sinki.fi>
> Date: Mon, 31 Dec 2007 12:47:51 +0200
>
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...sinki.fi>
> ...
> >
> > - in_flight = tcp_packets_in_flight(tp);
> > - cwnd = tp->snd_cwnd;
> > - if (in_flight < cwnd)
> > - return (cwnd - in_flight);
> > + if (tcp_packets_in_flight(tp) < tp->snd_cwnd)
> > + return tp->snd_cwnd - tcp_packets_in_flight(tp);
> >
>
> I don't know about this one.
>
> Although tcp_packets_in_flight() is inline and the compiler
> should CSE the first call into a local register and not
> redo the calculation:
>
> 1) That isn't something to rely upon. The compiler might look
> at a function or set of functions in this file and decide
> to not inline tcp_packets_in_flight() or not see the CSE
> opportunity and that the second call is redundant.
How about doing something really straight-forward then:
return max_t(s32, tp->snd_cwnd - tcp_packets_in_flight(tp), 0);
...I was a bit unsure to add such type trickery and thus didn't go
for that right away.
> So best to keep the local vars here.
>
> I also think the code is clearer that way too.
Fair enough.
--
i.
Powered by blists - more mailing lists