Limit the route hash size.

From: Robin Holt
Date: Thu Dec 09 2004 - 11:28:21 EST



I got the following from the boot of one of our really large machines:
IP: routing cache hash table of 33554432 buckets, 524288Kbytes

I have done a lot of testing with the rt_hash_table. I would like to
propose that for the overwhelming majority of machines, the default size
is wrong.

It is currently based on numphyspages(). I would suggest that the
majority of machines will never need more than a single page of memory
for this hash. In my testing, I found a single 16k page would only get an
11% fill in a fairly heavily used production machine on a large network.

The only place where the large route cache seems to make sense is for
larger servers that are servicing internet connections from many sites.
Since the cache is completely flushed every 10 minutes by default, the
above machine would have to be adding 55,924 routes per second that were
ideally distrbuted throughout the hash space to even fill every bucket.

The patch I am proposing is as follows. For the sites that need larger
route hashes, they can use the rhash_entries command line option to set
it as desired.

Signed-off-by: Robin Holt <holt@xxxxxxx>


diff -Naur linux-orig/net/ipv4/route.c linux/net/ipv4/route.c
--- linux-orig/net/ipv4/route.c 2004-12-09 09:00:06 -06:00
+++ linux/net/ipv4/route.c 2004-12-09 08:56:33 -06:00
@@ -2728,7 +2728,7 @@
if (!ipv4_dst_ops.kmem_cachep)
panic("IP: failed to allocate ip_dst_cache\n");

- goal = num_physpages >> (26 - PAGE_SHIFT);
+ goal = 0;
if (rhash_entries)
goal = (rhash_entries * sizeof(struct rt_hash_bucket)) >> PAGE_SHIFT;
for (order = 0; (1UL << order) < goal; order++)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/