i386: Another case of i386 exploiting page sized special casing i386 uses kmalloc to allocage the thread structure assuming that the allocation results in a page sized aligned allocation. That has worked so far because SLAB exempts page sized slabs from debugging and aligns them in special ways that go beyond the restrictions imposed by KMALLOC_ARCH_MINALIGN. SLUB also works fine since the page sized allocations neatly align at page boundaries. However, if debugging is switched on then SLUB will only follow the requirements imposed by KMALLOC_ARCH_MINALIGN and not preserve page sized alignment. So this fix is necessary for SLUB debug to work cleanly with i386 code. The solution here is to replace the called to kmalloc with calles into the page allocator. An alternate solution may be to create a custom slab cache where the alignment is set to PAGE_SIZE (no problem here with page_struct modifications). That would allow slub debugging to be applied to the threadinfo structure. Signed-off-by: Christoph Lameter Index: linux-2.6.21-rc5-mm4/include/asm-i386/thread_info.h =================================================================== --- linux-2.6.21-rc5-mm4.orig/include/asm-i386/thread_info.h 2007-04-03 23:48:34.000000000 -0700 +++ linux-2.6.21-rc5-mm4/include/asm-i386/thread_info.h 2007-04-04 17:33:41.000000000 -0700 @@ -95,12 +95,14 @@ static inline struct thread_info *curren /* thread information allocation */ #ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL) +#define alloc_thread_info(tsk) ((struct thread_info *) \ + __get_free_pages(GFP_KERNEL| __GFP_ZERO, get_order(THREAD_SIZE))) #else -#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) +#define alloc_thread_info(tsk) ((struct thread_info *) \ + __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE))) #endif -#define free_thread_info(info) kfree(info) +#define free_thread_info(info) free_pages((unsigned long)(info), get_order(THREAD_SIZE)) #else /* !__ASSEMBLY__ */