提交 3df1cccd 编写于 作者: D David Rientjes 提交者: Pekka Enberg

slab: introduce slab_max_order kernel parameter

Introduce new slab_max_order kernel parameter which is the equivalent of
slub_max_order.

For immediate purposes, allows users to override the heuristic that sets
the max order to 1 by default if they have more than 32MB of RAM.  This
may result in page allocation failures if there is substantial
fragmentation.

Another usecase would be to increase the max order for better
performance.
Acked-by: NChristoph Lameter <cl@linux.com>
Signed-off-by: NDavid Rientjes <rientjes@google.com>
Signed-off-by: NPekka Enberg <penberg@kernel.org>
上级 543585cc
...@@ -2362,6 +2362,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -2362,6 +2362,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
slram= [HW,MTD] slram= [HW,MTD]
slab_max_order= [MM, SLAB]
Determines the maximum allowed order for slabs.
A high setting may cause OOMs due to memory
fragmentation. Defaults to 1 for systems with
more than 32MB of RAM, 0 otherwise.
slub_debug[=options[,slabs]] [MM, SLUB] slub_debug[=options[,slabs]] [MM, SLUB]
Enabling slub_debug allows one to determine the Enabling slub_debug allows one to determine the
culprit if slab objects become corrupted. Enabling culprit if slab objects become corrupted. Enabling
......
...@@ -479,11 +479,13 @@ EXPORT_SYMBOL(slab_buffer_size); ...@@ -479,11 +479,13 @@ EXPORT_SYMBOL(slab_buffer_size);
#endif #endif
/* /*
* Do not go above this order unless 0 objects fit into the slab. * Do not go above this order unless 0 objects fit into the slab or
* overridden on the command line.
*/ */
#define SLAB_MAX_ORDER_HI 1 #define SLAB_MAX_ORDER_HI 1
#define SLAB_MAX_ORDER_LO 0 #define SLAB_MAX_ORDER_LO 0
static int slab_max_order = SLAB_MAX_ORDER_LO; static int slab_max_order = SLAB_MAX_ORDER_LO;
static bool slab_max_order_set __initdata;
/* /*
* Functions for storing/retrieving the cachep and or slab from the page * Functions for storing/retrieving the cachep and or slab from the page
...@@ -851,6 +853,17 @@ static int __init noaliencache_setup(char *s) ...@@ -851,6 +853,17 @@ static int __init noaliencache_setup(char *s)
} }
__setup("noaliencache", noaliencache_setup); __setup("noaliencache", noaliencache_setup);
static int __init slab_max_order_setup(char *str)
{
get_option(&str, &slab_max_order);
slab_max_order = slab_max_order < 0 ? 0 :
min(slab_max_order, MAX_ORDER - 1);
slab_max_order_set = true;
return 1;
}
__setup("slab_max_order=", slab_max_order_setup);
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/* /*
* Special reaping functions for NUMA systems called from cache_reap(). * Special reaping functions for NUMA systems called from cache_reap().
...@@ -1499,9 +1512,10 @@ void __init kmem_cache_init(void) ...@@ -1499,9 +1512,10 @@ void __init kmem_cache_init(void)
/* /*
* Fragmentation resistance on low memory - only use bigger * Fragmentation resistance on low memory - only use bigger
* page orders on machines with more than 32MB of memory. * page orders on machines with more than 32MB of memory if
* not overridden on the command line.
*/ */
if (totalram_pages > (32 << 20) >> PAGE_SHIFT) if (!slab_max_order_set && totalram_pages > (32 << 20) >> PAGE_SHIFT)
slab_max_order = SLAB_MAX_ORDER_HI; slab_max_order = SLAB_MAX_ORDER_HI;
/* Bootstrap is tricky, because several objects are allocated /* Bootstrap is tricky, because several objects are allocated
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册