slab: cache sizes for kmalloc

Maksym Planeta mcsim.planeta at gmail.com
Thu Mar 17 19:18:20 EDT 2011


There are predefined cache sizes in <linux/kmalloc_sizes.h>. But I don't
understand why exactly these sizes were chosen. 

I've wrote a hook were I've counted witch object sizes are the most
popular. They were objects of sizes 8 and 16 bytes, but the smallest
available cache has size 32 bytes. So in this cache fragmentation is
about 40%. There is big fragmentation in 512 and 1024-byte caches too --
25 and 35 percent correspondingly. Also there are empty caches, all DMA
caches on my system are empty. In total there is wasting of memory.

That's why, I think that caches for kmalloc can be created dynamically.
For example, if I have 32-byte cache, but it's fragmentation exceeds
level of 20% can be created new cache with smaller size and new objects,
that fit this new size, should be allocated there. But if there are too
little objects in the cache, new allocating to it can be stopped and
with the lapse of time when it become empty it could be destroyed.

The aim is to reduce memory waste and make fragmentation nearly equal.
So I would like to know is there any sense in such cache management. If
yes, I'll work on this.

-- 
Thanks,

Maksym Planeta




More information about the Kernelnewbies mailing list