Index: linux-2.6.21-rc2/include/linux/slub_def.h =================================================================== --- linux-2.6.21-rc2.orig/include/linux/slub_def.h 2007-03-01 12:09:54.000000000 -0800 +++ linux-2.6.21-rc2/include/linux/slub_def.h 2007-03-01 12:12:50.000000000 -0800 @@ -55,7 +55,7 @@ struct kmem_cache { */ #define KMALLOC_SHIFT_LOW 3 -#define KMALLOC_SHIFT_HIGH 18 +#define KMALLOC_SHIFT_HIGH 12 #if L1_CACHE_BYTES <= 64 #define KMALLOC_EXTRAS 2 @@ -94,12 +94,6 @@ static inline int kmalloc_index(int size if (size <= 1024) return 10; if (size <= 2048) return 11; if (size <= 4096) return 12; - if (size <= 8 * 1024) return 13; - if (size <= 16 * 1024) return 14; - if (size <= 32 * 1024) return 15; - if (size <= 64 * 1024) return 16; - if (size <= 128 * 1024) return 17; - if (size <= 256 * 1024) return 18; return -1; } @@ -107,20 +101,14 @@ static inline int kmalloc_index(int size * Find the slab cache for a given combination of allocation flags and size. * * This ought to end up with a global pointer to the right cache - * in kmalloc_caches. + * in kmalloc_caches or NULL for too large caches. */ static inline struct kmem_cache *kmalloc_slab(size_t size) { int index = kmalloc_index(size) - KMALLOC_SHIFT_LOW; - if (index < 0) { - /* - * Generate a link failure. Would be great if we could - * do something to stop the compile here. - */ - extern void __kmalloc_size_too_large(void); - __kmalloc_size_too_large(); - } + if (index < 0) + return NULL; return &kmalloc_caches[index]; } @@ -136,6 +124,8 @@ static inline void *kmalloc(size_t size, if (__builtin_constant_p(size) && !(flags & SLUB_DMA)) { struct kmem_cache *s = kmalloc_slab(size); + if (s == NULL) + return __alloc_page(page_order_of(size), flags) return kmem_cache_alloc(s, flags); } else return __kmalloc(size, flags);