[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>
This commit is contained in:
parent
22c047ccbc
commit
424c4b70cc
|
@ -71,6 +71,7 @@
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
#include <linux/bootmem.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <linux/socket.h>
|
#include <linux/socket.h>
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
|
@ -3103,12 +3104,14 @@ __setup("rhash_entries=", set_rhash_entries);
|
||||||
|
|
||||||
int __init ip_rt_init(void)
|
int __init ip_rt_init(void)
|
||||||
{
|
{
|
||||||
int order, goal, rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
rt_hash_rnd = (int) ((num_physpages ^ (num_physpages>>8)) ^
|
rt_hash_rnd = (int) ((num_physpages ^ (num_physpages>>8)) ^
|
||||||
(jiffies ^ (jiffies >> 7)));
|
(jiffies ^ (jiffies >> 7)));
|
||||||
|
|
||||||
#ifdef CONFIG_NET_CLS_ROUTE
|
#ifdef CONFIG_NET_CLS_ROUTE
|
||||||
|
{
|
||||||
|
int order;
|
||||||
for (order = 0;
|
for (order = 0;
|
||||||
(PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++)
|
(PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++)
|
||||||
/* NOTHING */;
|
/* NOTHING */;
|
||||||
|
@ -3116,6 +3119,7 @@ int __init ip_rt_init(void)
|
||||||
if (!ip_rt_acct)
|
if (!ip_rt_acct)
|
||||||
panic("IP: failed to allocate ip_rt_acct\n");
|
panic("IP: failed to allocate ip_rt_acct\n");
|
||||||
memset(ip_rt_acct, 0, PAGE_SIZE << order);
|
memset(ip_rt_acct, 0, PAGE_SIZE << order);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ipv4_dst_ops.kmem_cachep = kmem_cache_create("ip_dst_cache",
|
ipv4_dst_ops.kmem_cachep = kmem_cache_create("ip_dst_cache",
|
||||||
|
@ -3126,32 +3130,17 @@ int __init ip_rt_init(void)
|
||||||
if (!ipv4_dst_ops.kmem_cachep)
|
if (!ipv4_dst_ops.kmem_cachep)
|
||||||
panic("IP: failed to allocate ip_dst_cache\n");
|
panic("IP: failed to allocate ip_dst_cache\n");
|
||||||
|
|
||||||
goal = num_physpages >> (26 - PAGE_SHIFT);
|
rt_hash_table = (struct rt_hash_bucket *)
|
||||||
if (rhash_entries)
|
alloc_large_system_hash("IP route cache",
|
||||||
goal = (rhash_entries * sizeof(struct rt_hash_bucket)) >> PAGE_SHIFT;
|
sizeof(struct rt_hash_bucket),
|
||||||
for (order = 0; (1UL << order) < goal; order++)
|
rhash_entries,
|
||||||
/* NOTHING */;
|
(num_physpages >= 128 * 1024) ?
|
||||||
|
(27 - PAGE_SHIFT) :
|
||||||
do {
|
(29 - PAGE_SHIFT),
|
||||||
rt_hash_mask = (1UL << order) * PAGE_SIZE /
|
HASH_HIGHMEM,
|
||||||
sizeof(struct rt_hash_bucket);
|
&rt_hash_log,
|
||||||
while (rt_hash_mask & (rt_hash_mask - 1))
|
&rt_hash_mask,
|
||||||
rt_hash_mask--;
|
0);
|
||||||
rt_hash_table = (struct rt_hash_bucket *)
|
|
||||||
__get_free_pages(GFP_ATOMIC, order);
|
|
||||||
} while (rt_hash_table == NULL && --order > 0);
|
|
||||||
|
|
||||||
if (!rt_hash_table)
|
|
||||||
panic("Failed to allocate IP route cache hash table\n");
|
|
||||||
|
|
||||||
printk(KERN_INFO "IP: routing cache hash table of %u buckets, %ldKbytes\n",
|
|
||||||
rt_hash_mask,
|
|
||||||
(long) (rt_hash_mask * sizeof(struct rt_hash_bucket)) / 1024);
|
|
||||||
|
|
||||||
for (rt_hash_log = 0; (1 << rt_hash_log) != rt_hash_mask; rt_hash_log++)
|
|
||||||
/* NOTHING */;
|
|
||||||
|
|
||||||
rt_hash_mask--;
|
|
||||||
memset(rt_hash_table, 0, (rt_hash_mask + 1) * sizeof(struct rt_hash_bucket));
|
memset(rt_hash_table, 0, (rt_hash_mask + 1) * sizeof(struct rt_hash_bucket));
|
||||||
rt_hash_lock_init();
|
rt_hash_lock_init();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue