diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2005-07-05 17:58:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-07-05 17:58:19 -0400 |
commit | 424c4b70cc4ff3930ee36a2ef7b204e4d704fd26 (patch) | |
tree | 66f39769069e9d52d8a51ed625250374f074d050 | |
parent | 22c047ccbc68fa8f3fa57f0e8f906479a062c426 (diff) |
[IPV4]: Use the fancy alloc_large_system_hash() function for route hash table
- rt hash table allocated using alloc_large_system_hash() function.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/route.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index daf82f8d3c4a..9fcbb1b0a8d6 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -71,6 +71,7 @@ | |||
71 | #include <linux/kernel.h> | 71 | #include <linux/kernel.h> |
72 | #include <linux/sched.h> | 72 | #include <linux/sched.h> |
73 | #include <linux/mm.h> | 73 | #include <linux/mm.h> |
74 | #include <linux/bootmem.h> | ||
74 | #include <linux/string.h> | 75 | #include <linux/string.h> |
75 | #include <linux/socket.h> | 76 | #include <linux/socket.h> |
76 | #include <linux/sockios.h> | 77 | #include <linux/sockios.h> |
@@ -3103,12 +3104,14 @@ __setup("rhash_entries=", set_rhash_entries); | |||
3103 | 3104 | ||
3104 | int __init ip_rt_init(void) | 3105 | int __init ip_rt_init(void) |
3105 | { | 3106 | { |
3106 | int order, goal, rc = 0; | 3107 | int rc = 0; |
3107 | 3108 | ||
3108 | rt_hash_rnd = (int) ((num_physpages ^ (num_physpages>>8)) ^ | 3109 | rt_hash_rnd = (int) ((num_physpages ^ (num_physpages>>8)) ^ |
3109 | (jiffies ^ (jiffies >> 7))); | 3110 | (jiffies ^ (jiffies >> 7))); |
3110 | 3111 | ||
3111 | #ifdef CONFIG_NET_CLS_ROUTE | 3112 | #ifdef CONFIG_NET_CLS_ROUTE |
3113 | { | ||
3114 | int order; | ||
3112 | for (order = 0; | 3115 | for (order = 0; |
3113 | (PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++) | 3116 | (PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++) |
3114 | /* NOTHING */; | 3117 | /* NOTHING */; |
@@ -3116,6 +3119,7 @@ int __init ip_rt_init(void) | |||
3116 | if (!ip_rt_acct) | 3119 | if (!ip_rt_acct) |
3117 | panic("IP: failed to allocate ip_rt_acct\n"); | 3120 | panic("IP: failed to allocate ip_rt_acct\n"); |
3118 | memset(ip_rt_acct, 0, PAGE_SIZE << order); | 3121 | memset(ip_rt_acct, 0, PAGE_SIZE << order); |
3122 | } | ||
3119 | #endif | 3123 | #endif |
3120 | 3124 | ||
3121 | ipv4_dst_ops.kmem_cachep = kmem_cache_create("ip_dst_cache", | 3125 | ipv4_dst_ops.kmem_cachep = kmem_cache_create("ip_dst_cache", |
@@ -3126,32 +3130,17 @@ int __init ip_rt_init(void) | |||
3126 | if (!ipv4_dst_ops.kmem_cachep) | 3130 | if (!ipv4_dst_ops.kmem_cachep) |
3127 | panic("IP: failed to allocate ip_dst_cache\n"); | 3131 | panic("IP: failed to allocate ip_dst_cache\n"); |
3128 | 3132 | ||
3129 | goal = num_physpages >> (26 - PAGE_SHIFT); | 3133 | rt_hash_table = (struct rt_hash_bucket *) |
3130 | if (rhash_entries) | 3134 | alloc_large_system_hash("IP route cache", |
3131 | goal = (rhash_entries * sizeof(struct rt_hash_bucket)) >> PAGE_SHIFT; | 3135 | sizeof(struct rt_hash_bucket), |
3132 | for (order = 0; (1UL << order) < goal; order++) | 3136 | rhash_entries, |
3133 | /* NOTHING */; | 3137 | (num_physpages >= 128 * 1024) ? |
3134 | 3138 | (27 - PAGE_SHIFT) : | |
3135 | do { | 3139 | (29 - PAGE_SHIFT), |
3136 | rt_hash_mask = (1UL << order) * PAGE_SIZE / | 3140 | HASH_HIGHMEM, |
3137 | sizeof(struct rt_hash_bucket); | 3141 | &rt_hash_log, |
3138 | while (rt_hash_mask & (rt_hash_mask - 1)) | 3142 | &rt_hash_mask, |
3139 | rt_hash_mask--; | 3143 | 0); |
3140 | rt_hash_table = (struct rt_hash_bucket *) | ||
3141 | __get_free_pages(GFP_ATOMIC, order); | ||
3142 | } while (rt_hash_table == NULL && --order > 0); | ||
3143 | |||
3144 | if (!rt_hash_table) | ||
3145 | panic("Failed to allocate IP route cache hash table\n"); | ||
3146 | |||
3147 | printk(KERN_INFO "IP: routing cache hash table of %u buckets, %ldKbytes\n", | ||
3148 | rt_hash_mask, | ||
3149 | (long) (rt_hash_mask * sizeof(struct rt_hash_bucket)) / 1024); | ||
3150 | |||
3151 | for (rt_hash_log = 0; (1 << rt_hash_log) != rt_hash_mask; rt_hash_log++) | ||
3152 | /* NOTHING */; | ||
3153 | |||
3154 | rt_hash_mask--; | ||
3155 | memset(rt_hash_table, 0, (rt_hash_mask + 1) * sizeof(struct rt_hash_bucket)); | 3144 | memset(rt_hash_table, 0, (rt_hash_mask + 1) * sizeof(struct rt_hash_bucket)); |
3156 | rt_hash_lock_init(); | 3145 | rt_hash_lock_init(); |
3157 | 3146 | ||