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
Hi.... Probably just a quick share from me... On Fri, Mar 18, 2011 at 06:18, Maksym Planeta <mcsim.planeta@gmail.com> wrote:
I've wrote a hook were I've counted witch object sizes are the most popular.
Uhuh, and why you just don't use "slabtop" utility which just use /proc/slabinfo?
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.
I think 32 byte is chosen due to the size of the page in x86 32 bit == 4 KiB... by doing that, cache is simply allocated using page_alloc (or alloc_page? I forgot) and then later "teared apart" into slab objects... -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
On Fri, 18/03/2011 at 06:56 +0700, Mulyadi Santosa wrote:
On Fri, Mar 18, 2011 at 06:18, Maksym Planeta <mcsim.planeta@gmail.com> wrote:
I've wrote a hook were I've counted witch object sizes are the most popular.
Uhuh, and why you just don't use "slabtop" utility which just use /proc/slabinfo?
In slabinfo I can see which cache how many objects has. But I was interested witch object sizes are requested most of all. And there isn't such information in slabinfo. For example, if I request 8 bytes 32-byte object will be allocated. And there is no information in slabinfo how much memory I really needed.
I think 32 byte is chosen due to the size of the page in x86 32 bit == 4 KiB... by doing that, cache is simply allocated using page_alloc (or alloc_page? I forgot) and then later "teared apart" into slab objects...
But in slub allocator there are 8- and 16- byte caches. Why in slab can't be the same? -- Thanks, Maksym Planeta
Hi .... On Fri, Mar 18, 2011 at 12:52, Maksym Planeta <mcsim.planeta@gmail.com> wrote:
In slabinfo I can see which cache how many objects has. But I was interested witch object sizes are requested most of all. And there isn't such information in slabinfo. For example, if I request 8 bytes 32-byte object will be allocated. And there is no information in slabinfo how much memory I really needed.
Hm... alright, if that's the one you seek,maybe slabinfo can't provide it.. although once I think you can approximate it by number of objects. But since you need to compare between requested v.s actual allocation, that would be something hardly provided in slabinfo AFAIK
But in slub allocator there are 8- and 16- byte caches. Why in slab can't be the same?
From related Kconfig: " config SLAB bool "SLAB" help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in per cpu and per node queues. "
I am thinking about the word "cache hot objects". Well, IMHO, it is achievable by allocating biggest page size possible (without using PAE etc), and that's 4K in x86. So we get this 4 KiB arena and put it as close as possible to the needed CPU ( to avoid cache ping pong AFAIK)...or in NUMA case, to make it real close to the needing CPU. By using the normal granularity (which is page size), I think moving cache will be a lot simplier.... just my thoughts... -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
participants (2)
-
Maksym Planeta -
Mulyadi Santosa