Index: linux-2.6.21-rc7-mm2/include/linux/slub_def.h =================================================================== --- linux-2.6.21-rc7-mm2.orig/include/linux/slub_def.h 2007-04-26 18:25:50.000000000 -0700 +++ linux-2.6.21-rc7-mm2/include/linux/slub_def.h 2007-04-26 18:31:31.000000000 -0700 @@ -143,14 +143,6 @@ static inline struct kmem_cache *kmalloc if (index == 0) return NULL; - 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(); - } return &kmalloc_caches[index]; } @@ -166,6 +158,8 @@ static inline void *kmalloc(size_t size, if (__builtin_constant_p(size) && !(flags & SLUB_DMA)) { struct kmem_cache *s = kmalloc_slab(size); + BUILD_BUG_ON(size > (1 << KMALLOC_SHIFT_HIGH)); + if (!s) return NULL; @@ -174,11 +168,15 @@ static inline void *kmalloc(size_t size, return __kmalloc(size, flags); } -static inline void *kzalloc(size_t size, gfp_t flags) +static __always_inline void *kzalloc(size_t size, gfp_t flags) { - if (__builtin_constant_p(size) && !(flags & SLUB_DMA)) { + BUILD_BUG_ON(size > (1 << KMALLOC_SHIFT_HIGH)); + if (__builtin_constant_p(size) +// && !(flags & SLUB_DMA) +) { struct kmem_cache *s = kmalloc_slab(size); + if (!s) return NULL; Index: linux-2.6.21-rc7-mm2/mm/slub.c =================================================================== --- linux-2.6.21-rc7-mm2.orig/mm/slub.c 2007-04-26 18:27:44.000000000 -0700 +++ linux-2.6.21-rc7-mm2/mm/slub.c 2007-04-26 18:28:09.000000000 -0700 @@ -2660,6 +2660,8 @@ static void resiliency_test(void) p[512] = 0xab; printk(KERN_ERR "\n3. kmalloc-512: Clobber redzone 0xab->0x%p\n\n", p); validate_slab_cache(kmalloc_caches + 9); + p= kzalloc(1 << 30, GFP_KERNEL); + printk("%p", p); } #else static void resiliency_test(void) {};