diff options
author | Christoph Lameter <clameter@sgi.com> | 2007-05-17 01:11:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-17 08:23:04 -0400 |
commit | 0aa817f078b655d0ae36669169d73a5c8a388016 (patch) | |
tree | 140acc4d0dc992b4d20394f6a6412a7c1bb3a306 /mm/slab.c | |
parent | 3ec0974210fe1b7c0618ad6e39a882a4237d7de2 (diff) |
Slab allocators: define common size limitations
Currently we have a maze of configuration variables that determine the
maximum slab size. Worst of all it seems to vary between SLAB and SLUB.
So define a common maximum size for kmalloc. For conveniences sake we use
the maximum size ever supported which is 32 MB. We limit the maximum size
to a lower limit if MAX_ORDER does not allow such large allocations.
For many architectures this patch will have the effect of adding large
kmalloc sizes. x86_64 adds 5 new kmalloc sizes. So a small amount of
memory will be needed for these caches (contemporary SLAB has dynamically
sizeable node and cpu structure so the waste is less than in the past)
Most architectures will then be able to allocate object with sizes up to
MAX_ORDER. We have had repeated breakage (in fact whenever we doubled the
number of supported processors) on IA64 because one or the other struct
grew beyond what the slab allocators supported. This will avoid future
issues and f.e. avoid fixes for 2k and 4k cpu support.
CONFIG_LARGE_ALLOCS is no longer necessary so drop it.
It fixes sparc64 with SLAB.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 19 |
1 files changed, 2 insertions, 17 deletions
@@ -569,21 +569,6 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp) | |||
569 | #endif | 569 | #endif |
570 | 570 | ||
571 | /* | 571 | /* |
572 | * Maximum size of an obj (in 2^order pages) and absolute limit for the gfp | ||
573 | * order. | ||
574 | */ | ||
575 | #if defined(CONFIG_LARGE_ALLOCS) | ||
576 | #define MAX_OBJ_ORDER 13 /* up to 32Mb */ | ||
577 | #define MAX_GFP_ORDER 13 /* up to 32Mb */ | ||
578 | #elif defined(CONFIG_MMU) | ||
579 | #define MAX_OBJ_ORDER 5 /* 32 pages */ | ||
580 | #define MAX_GFP_ORDER 5 /* 32 pages */ | ||
581 | #else | ||
582 | #define MAX_OBJ_ORDER 8 /* up to 1Mb */ | ||
583 | #define MAX_GFP_ORDER 8 /* up to 1Mb */ | ||
584 | #endif | ||
585 | |||
586 | /* | ||
587 | * Do not go above this order unless 0 objects fit into the slab. | 572 | * Do not go above this order unless 0 objects fit into the slab. |
588 | */ | 573 | */ |
589 | #define BREAK_GFP_ORDER_HI 1 | 574 | #define BREAK_GFP_ORDER_HI 1 |
@@ -2002,7 +1987,7 @@ static size_t calculate_slab_order(struct kmem_cache *cachep, | |||
2002 | size_t left_over = 0; | 1987 | size_t left_over = 0; |
2003 | int gfporder; | 1988 | int gfporder; |
2004 | 1989 | ||
2005 | for (gfporder = 0; gfporder <= MAX_GFP_ORDER; gfporder++) { | 1990 | for (gfporder = 0; gfporder <= KMALLOC_MAX_ORDER; gfporder++) { |
2006 | unsigned int num; | 1991 | unsigned int num; |
2007 | size_t remainder; | 1992 | size_t remainder; |
2008 | 1993 | ||
@@ -2148,7 +2133,7 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
2148 | * Sanity checks... these are all serious usage bugs. | 2133 | * Sanity checks... these are all serious usage bugs. |
2149 | */ | 2134 | */ |
2150 | if (!name || in_interrupt() || (size < BYTES_PER_WORD) || | 2135 | if (!name || in_interrupt() || (size < BYTES_PER_WORD) || |
2151 | (size > (1 << MAX_OBJ_ORDER) * PAGE_SIZE) || dtor) { | 2136 | size > KMALLOC_MAX_SIZE || dtor) { |
2152 | printk(KERN_ERR "%s: Early error in slab %s\n", __FUNCTION__, | 2137 | printk(KERN_ERR "%s: Early error in slab %s\n", __FUNCTION__, |
2153 | name); | 2138 | name); |
2154 | BUG(); | 2139 | BUG(); |