Skip to content

Commit 3df1ccc

Browse files
rientjespenberg
authored andcommitted
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: Christoph Lameter <cl@linux.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
1 parent 543585c commit 3df1ccc

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Documentation/kernel-parameters.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
23622362

23632363
slram= [HW,MTD]
23642364

2365+
slab_max_order= [MM, SLAB]
2366+
Determines the maximum allowed order for slabs.
2367+
A high setting may cause OOMs due to memory
2368+
fragmentation. Defaults to 1 for systems with
2369+
more than 32MB of RAM, 0 otherwise.
2370+
23652371
slub_debug[=options[,slabs]] [MM, SLUB]
23662372
Enabling slub_debug allows one to determine the
23672373
culprit if slab objects become corrupted. Enabling

mm/slab.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,13 @@ EXPORT_SYMBOL(slab_buffer_size);
479479
#endif
480480

481481
/*
482-
* Do not go above this order unless 0 objects fit into the slab.
482+
* Do not go above this order unless 0 objects fit into the slab or
483+
* overridden on the command line.
483484
*/
484485
#define SLAB_MAX_ORDER_HI 1
485486
#define SLAB_MAX_ORDER_LO 0
486487
static int slab_max_order = SLAB_MAX_ORDER_LO;
488+
static bool slab_max_order_set __initdata;
487489

488490
/*
489491
* Functions for storing/retrieving the cachep and or slab from the page
@@ -851,6 +853,17 @@ static int __init noaliencache_setup(char *s)
851853
}
852854
__setup("noaliencache", noaliencache_setup);
853855

856+
static int __init slab_max_order_setup(char *str)
857+
{
858+
get_option(&str, &slab_max_order);
859+
slab_max_order = slab_max_order < 0 ? 0 :
860+
min(slab_max_order, MAX_ORDER - 1);
861+
slab_max_order_set = true;
862+
863+
return 1;
864+
}
865+
__setup("slab_max_order=", slab_max_order_setup);
866+
854867
#ifdef CONFIG_NUMA
855868
/*
856869
* Special reaping functions for NUMA systems called from cache_reap().
@@ -1499,9 +1512,10 @@ void __init kmem_cache_init(void)
14991512

15001513
/*
15011514
* Fragmentation resistance on low memory - only use bigger
1502-
* page orders on machines with more than 32MB of memory.
1515+
* page orders on machines with more than 32MB of memory if
1516+
* not overridden on the command line.
15031517
*/
1504-
if (totalram_pages > (32 << 20) >> PAGE_SHIFT)
1518+
if (!slab_max_order_set && totalram_pages > (32 << 20) >> PAGE_SHIFT)
15051519
slab_max_order = SLAB_MAX_ORDER_HI;
15061520

15071521
/* Bootstrap is tricky, because several objects are allocated

0 commit comments

Comments
 (0)