[PATCH] optimize fixed-sized kmalloc calls
From: Manfred Spraul and Brian Gerst The patch performs the kmalloc cache lookup for constant kmalloc calls at compile time. The idea is that the loop in kmalloc takes a significant amount of time, and for kmalloc(4096,GFP_KERNEL), that lookup can happen entirely at compile time. A problem has been seen with gcc-3.2.2-5 from RedHat. This code: if(__builtin_constant_t(size)) { if(size < 32) return kmem_cache_alloc(...); if(size < 64) return kmem_cache_alloc(...); if(size < 96) return kmem_cache_alloc(...); if(size < 128) return kmem_cache_alloc(...); ... } doesn't work, because gcc only optimizes the first two or three comparisons, and then suddenly generates code. But we did it that way anyway. Apparently it's fixed in later compilers.
Showing
Please register or sign in to comment