Christoph Lameter wrote: >On Wed, 16 Aug 2006, Andi Kleen wrote: > > > >>>2. use fls to calculate array position. >>> >>> >>I'm not sure that's a good idea. I always had my doubts that power of twos >>are a good size distribution. I remember the original slab paper from Bonwick >>also discouraged them. With fls you would hard code it. >> >> > >The original paper from Bonwick is pretty dated now. There are some >interesting ideas in there and we have mostly followed them. But it is an >academic paper after all. > It's not just an academic paper, it's implemented in Solaris. Check the opensolaris sources. > So not all ideas may be relevant in practice. >Support for non power of two sizes could lead to general slabs that do not >exactly fit into one page. > That's a good thing. I'm not sure that the current approach with virt_to_page()/vmalloc_to_page() is the right thing(tm): Both functions are slow. If you have non-power-of-two caches, you could store the control data at (addr&(~PAGE_SIZE)) - the lookup would be much faster. I wrote a patch a few weeks ago, it's attached. Right now we have a few slab users that perform kmalloc(PAGE_SIZE). But that's a mostly for historic reasons: kmalloc was significantly (IIRC up to factor 10) faster than get_free_pages(). Now get_free_pages() also contains per-cpu structures, so we could convert __get_name or the pipe code back to get_free_pages(). -- Manfred