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 /include/linux/slab.h | |
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 'include/linux/slab.h')
-rw-r--r-- | include/linux/slab.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 6fb2ae214152..a015236cc572 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -74,6 +74,21 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep, | |||
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | /* | 76 | /* |
77 | * The largest kmalloc size supported by the slab allocators is | ||
78 | * 32 megabyte (2^25) or the maximum allocatable page order if that is | ||
79 | * less than 32 MB. | ||
80 | * | ||
81 | * WARNING: Its not easy to increase this value since the allocators have | ||
82 | * to do various tricks to work around compiler limitations in order to | ||
83 | * ensure proper constant folding. | ||
84 | */ | ||
85 | #define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT) <= 25 ? \ | ||
86 | (MAX_ORDER + PAGE_SHIFT) : 25) | ||
87 | |||
88 | #define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_HIGH) | ||
89 | #define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_HIGH - PAGE_SHIFT) | ||
90 | |||
91 | /* | ||
77 | * Common kmalloc functions provided by all allocators | 92 | * Common kmalloc functions provided by all allocators |
78 | */ | 93 | */ |
79 | void *__kmalloc(size_t, gfp_t); | 94 | void *__kmalloc(size_t, gfp_t); |