netdev
[Top] [All Lists]

Re: [PATCH] optimize check in port-allocation code

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: Re: [PATCH] optimize check in port-allocation code
From: folkert@xxxxxxxxxxxxxx
Date: Thu, 28 Apr 2005 23:24:53 +0200
Cc: netdev@xxxxxxxxxxx
In-reply-to: <20050428120824.6cc9b345.davem@davemloft.net>
Organization: www.unixexpert.nl
Read-receipt-to: <folkert@vanheusden.com>
References: <20050420184419.GM20290@vanheusden.com> <20050424190427.11b4863e.davem@davemloft.net> <20050425061210.GB15167@vanheusden.com> <20050428120824.6cc9b345.davem@davemloft.net>
Reply-by: Thu Apr 28 19:51:31 CEST 2005
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.9i
> > I'll resend it as an attachment (see attachment).
> It still has spaces where there should be tabs, even though
> you compressed the patch and used attachment.
> The diff itself must already be corrupt before you attach
> it.
> Please double check that the patch you submit actually apply,
> this will save me a lot of wasted time.

Ok, I've redone them and tested if they patch cleanly, they now do.
See them attached.

While looking at the code I also saw something else:

--- tcp_ipv4.c.org      2005-04-28 23:13:32.000000000 +0200
+++ tcp_ipv4.c  2005-04-28 23:19:18.000000000 +0200
@@ -222,11 +222,11 @@
                int rover;
 
                spin_lock(&tcp_portalloc_lock);
-               rover = tcp_port_rover;
+               if (tcp_port_rover < low)
+                       rover = low;
+               else
+                       rover = tcp_port_rover;
                do {
-                       rover++;
-                       if (rover < low || rover > high)
-                               rover = low;
                        head = &tcp_bhash[tcp_bhashfn(rover)];
                        spin_lock(&head->lock);
                        tb_for_each(tb, node, &head->chain)
@@ -235,6 +235,10 @@
                        break;
                next:
                        spin_unlock(&head->lock);
+
+                       rover++;
+                       if (rover > high)
+                               rover = low;
                } while (--remaining > 0);
                tcp_port_rover = rover;
                spin_unlock(&tcp_portalloc_lock);

as you can see I moved (here! not in the included patches as I wanted
to discuss this first!) the 'rover++' and its check to the end of the
while loop. I did this because if they are at the top of the wile-loop
the 'low' port number is never used as the first statement was a
rover++!


Folkert van Heusden

-- 
Auto te koop, zie: http://www.vanheusden.com/daihatsu.php
Op zoek naar een IT of Finance baan? Mail me voor de mogelijkheden.
--------------------------------------------------------------------
 UNIX admin? Then give MultiTail (http://vanheusden.com/multitail/) 
 a try, it brings monitoring logfiles to a different level! See     
 http://vanheusden.com/multitail/features.html for a feature-list.  
--------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE
Get your PGP/GPG key signed at www.biglumber.com!

Attachment: tcp_ipv4.c.diff.gz
Description: Binary data

Attachment: tcp_ipv6.c.diff.gz
Description: Binary data

Attachment: signature.asc
Description: Digital signature

<Prev in Thread] Current Thread [Next in Thread>