: [XFRM]: Dynamic xfrm_state hash table sizing.
Subsystems (5)
David Miller
maintainerPATCH 5/10 : [XFRM]: Dynamic xfrm_state hash table sizing.
[XFRM]: Dynamic xfrm_state hash table sizing.
The grow algorithm is simple, we grow if:
1) we see a hash chain collision at insert, and
2) we haven't hit the hash size limit (currently 1*1024*1024 slots), and
3) the number of xfrm_state objects is > the current hash mask
All of this needs some tweaking.
Remove __initdata from "hashdist" so we can use it safely at run time.
--- include/linux/bootmem.h | 2 mm/page_alloc.c | 2 net/xfrm/xfrm_state.c | 200 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 165 insertions(+), 39 deletions(-)
include/linux/bootmem.h +1 -1
@@ -114,7 +114,7 @@ #define HASHDIST_DEFAULT 1#else #define HASHDIST_DEFAULT 0#endif -extern int __initdata hashdist;/* Distribute hashes across NUMA nodes? */ +extern int hashdist;/* Distribute hashes across NUMA nodes? */ #endif /* _LINUX_BOOTMEM_H */
mm/page_alloc.c +1 -1
@@ -2363,7 +2363,7 @@ int percpu_pagelist_fraction_sysctl_handreturn 0 ; } -__initdata int hashdist =HASHDIST_DEFAULT ; +int hashdist =HASHDIST_DEFAULT ;#ifdef CONFIG_NUMA static int __init set_hashdist (char *str)
net/xfrm/xfrm_state.c +163 -37
298 lines not on this page · raw message
Signature · 1 line
1.4.2.rc2.g3e042
Quoted 9 lines · David Miller
[XFRM]: Dynamic
xfrm_statehash table sizing.net/xfrm/xfrm_state.c +7
-0+static struct hlist_head *xfrm_state_hash_alloc (unsigned int sz) +{ +struct hlist_head *n; + +if (sz <=PAGE_SIZE ) + n =kmalloc (sz,GFP_KERNEL ); +else if (hashdist)
net/xfrm/xfrm_state.c EXPORT_SYMBOL(sysctl_xfrm_aevent_rseqth) · line 142
Quoted 10 lines
net/xfrm/xfrm_state.c +10
-0+ n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL ); + else + n = (struct hlist_head *) +__get_free_pages (GFP_KERNEL ,get_order (sz)); + +if (n) +memset (n,0 , sz); + +return n; +}
This kind of functions are becoming very common and duplicated... maybe we can factorize it ?
Also, it would be cool to be able to vmalloc()/free_pages hugetlb pages for very large hash tables...
net/xfrm/xfrm_state.c EXPORT_SYMBOL(sysctl_xfrm_aevent_rseqth) · line 153
Quoted 11 lines
net/xfrm/xfrm_state.c +11
-0+ +static void xfrm_state_hash_free (struct hlist_head *n,unsigned int sz) +{ +if (sz <=PAGE_SIZE ) +kfree (n); +else if (hashdist) +vfree (n); +else +free_pages ((unsigned long )n,get_order (sz)); +} +
Eric
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Tue, 29 Aug 2006 11:15:56 +0200
Quoted 2 lines
This kind of functions are becoming very common and duplicated... maybe we can factorize it ?
That's certainly why a subsequent patch in that set moved all of this to net/xfrm/xfrm_hash.c :-)
Only when my routing cache hash changes are checked in will there be any similar use outside of the XFRM layer. I did not put my routing cache dynamic hash table changes anywhere yet because frankly the growth logic is incomplete and needs to be in a working state.
If nobody takes on the task to work on that, and I might not be strong enough to do this, the dynamic hashing patches for the routing cache will certainly rot. We really cannot put those changes in without good growth logic.
Eric you used to be so active. Please try to find some free time from your busy schedule to work on something like this ;-)
Quoted 2 lines
Also, it would be cool to be able to vmalloc()/free_pages hugetlb pages for very large hash tables...
I always wanted to do this on sparc64, especially for modules. It requires arch-level support, for sure.
At least in the modules case, it's kind of easy, since you just preallocate 4MB chunks and then dish out regions within those chunks. Something similar could be done to handle hash tables too, but we'd need to be careful about fragmentation.