]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
SLUB: faster more efficient slab determination for __kmalloc
authorChristoph Lameter <clameter@sgi.com>
Tue, 17 Jul 2007 11:03:26 +0000 (04:03 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 17:23:01 +0000 (10:23 -0700)
commitf1b263393626fe66bee34ccdbf0487cd377e0213
treec144c6f8c0fd8f5eeeac1504bf7204c09938135f
parentdfce8648d64c07eade40d456d59cb4bfcbba008c
SLUB: faster more efficient slab determination for __kmalloc

kmalloc_index is a long series of comparisons.  The attempt to replace
kmalloc_index with something more efficient like ilog2 failed due to compiler
issues with constant folding on gcc 3.3 / powerpc.

kmalloc_index()'es long list of comparisons works fine for constant folding
since all the comparisons are optimized away.  However, SLUB also uses
kmalloc_index to determine the slab to use for the __kmalloc_xxx functions.
This leads to a large set of comparisons in get_slab().

The patch here allows to get rid of that list of comparisons in get_slab():

1. If the requested size is larger than 192 then we can simply use
   fls to determine the slab index since all larger slabs are
   of the power of two type.

2. If the requested size is smaller then we cannot use fls since there
   are non power of two caches to be considered. However, the sizes are
   in a managable range. So we divide the size by 8. Then we have only
   24 possibilities left and then we simply look up the kmalloc index
   in a table.

Code size of slub.o decreases by more than 200 bytes through this patch.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/slub.c