From: Eric Dumazet <[EMAIL PROTECTED]>
Date: Wed, 9 Aug 2006 10:32:54 +0200

> On Wednesday 09 August 2006 09:53, David Miller wrote:
> > [IPV4] route: Dynamic hash table sizing.
> >
> 
>  Excellent work David, Thank you !!!

No problem.  It's much more productive than all the pure-talk that
usually occurs on these topics.

Here is a patch implementing fixes for the problems you found, thanks
for reviewing.

commit fc03f220a20f0fef0567e7427d0e06d234b98531
Author: David S. Miller <[EMAIL PROTECTED]>
Date:   Wed Aug 9 02:06:33 2006 -0700

    [IPV4] route: Fix 3 bugs in dynamic hash table code.
    
    All problems were spotted by Eric Dumazet.
    
    1) During rehashing, the hash function was wrong.
       It should "xor" in the iface number not "and" it.
    
    2) Mark ip_rt_hashsz_limit __read_mostly
    
    3) Instead of rejecting non-power-of-2 rhash_entries
       values, round them up just like the alloc_large_system_hash
       function was doing for us previously
    
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 897e67c..a9216e2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -123,7 +123,6 @@ #define RT_GC_TIMEOUT (300*HZ)
 static int ip_rt_min_delay             = 2 * HZ;
 static int ip_rt_max_delay             = 10 * HZ;
 static int ip_rt_max_size;
-static int ip_rt_hashsz_limit          = (8 * 1024 * 1024) / sizeof(void *);
 static int ip_rt_gc_timeout            = RT_GC_TIMEOUT;
 static int ip_rt_gc_interval           = 60 * HZ;
 static int ip_rt_gc_min_interval       = HZ / 2;
@@ -253,6 +252,8 @@ static seqlock_t rt_hash_seq __read_most
 static struct rt_hash_bucket   *__rt_hash_table __read_mostly;
 static unsigned                        __rt_hash_mask __read_mostly;
 static unsigned int            rt_hash_rnd __read_mostly;
+static int ip_rt_hashsz_limit __read_mostly =
+       (8 * 1024 * 1024) / sizeof(void *);
 
 static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
 #define RT_CACHE_STAT_INC(field) \
@@ -351,7 +352,7 @@ static void rtcache_transfer(struct rtab
                if (!iface)
                        iface = list->fl.oif;
                hash = __rt_hash_code(list->fl.fl4_dst,
-                                     list->fl.fl4_src &
+                                     list->fl.fl4_src ^
                                      (iface << 5),
                                      nhashmask);
                ent = &new_table[hash];
@@ -3338,9 +3339,7 @@ static int __init set_rhash_entries(char
                return 0;
        val = simple_strtoul(str, &str, 0);
 
-       /* Only use it if it's a power-of-2. */
-       if (!(val & (val - 1)))
-               rhash_entries = val;
+       rhash_entries = roundup_pow_of_two(val);
 
        return 1;
 }
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to