* slab: cache sizes for kmalloc
@ 2011-03-17 23:18 Maksym Planeta
2011-03-17 23:56 ` Mulyadi Santosa
0 siblings, 1 reply; 4+ messages in thread
From: Maksym Planeta @ 2011-03-17 23:18 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* slab: cache sizes for kmalloc
2011-03-17 23:18 slab: cache sizes for kmalloc Maksym Planeta
@ 2011-03-17 23:56 ` Mulyadi Santosa
2011-03-18 5:52 ` Maksym Planeta
0 siblings, 1 reply; 4+ messages in thread
From: Mulyadi Santosa @ 2011-03-17 23:56 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* slab: cache sizes for kmalloc
2011-03-17 23:56 ` Mulyadi Santosa
@ 2011-03-18 5:52 ` Maksym Planeta
2011-03-18 22:26 ` Mulyadi Santosa
0 siblings, 1 reply; 4+ messages in thread
From: Maksym Planeta @ 2011-03-18 5:52 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* slab: cache sizes for kmalloc
2011-03-18 5:52 ` Maksym Planeta
@ 2011-03-18 22:26 ` Mulyadi Santosa
0 siblings, 0 replies; 4+ messages in thread
From: Mulyadi Santosa @ 2011-03-18 22:26 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-18 22:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 23:18 slab: cache sizes for kmalloc Maksym Planeta
2011-03-17 23:56 ` Mulyadi Santosa
2011-03-18 5:52 ` Maksym Planeta
2011-03-18 22:26 ` Mulyadi Santosa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.