--- mm/slub.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2008-01-10 00:02:48.357282213 -0800 +++ linux-2.6/mm/slub.c 2008-01-10 00:32:35.336299123 -0800 @@ -2986,6 +2986,8 @@ static int slab_memory_callback(struct n #endif /* CONFIG_MEMORY_HOTPLUG */ +#define BOUNDARY_PERCENT 30 + /******************************************************************** * Basic setup of slabs *******************************************************************/ @@ -2995,6 +2997,23 @@ void __init kmem_cache_init(void) int i; int caches = 0; +#ifdef CONFIG_HUGETLBFS + /* + * Check if we should go into a huge page configuration. We do that if + * a huge slab configuration would use less than 5% of system memory. + * The memory use of a huge slab configuration is mainly driven by the + * number of cpu slabs needed for each slab on each processors. A huge + * page configuration can need up to about 100 huge pages + * per processor. That is around 200MB on a 4k platform. So a system + * must have more or equal to 4GB per processor for this to trigger. + */ + if (!slub_min_order && + (100 << (HPAGE_SHIFT - PAGE_SHIFT)) * nr_cpu_ids <= + totalram_pages * BOUNDARY_PERCENT / 100) { + slub_min_order = HPAGE_SHIFT - PAGE_SHIFT; +#endif + + init_alloc_cpu(); #ifdef CONFIG_NUMA