* Linux SLAB allocator issue
@ 2006-06-06 20:58 Xin Zhao
2006-06-07 12:16 ` Pekka Enberg
0 siblings, 1 reply; 4+ messages in thread
From: Xin Zhao @ 2006-06-06 20:58 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fsdevel
Hi,
I am trying to check how many slabs are used for inode_cache, but
found that all slabs are added to slabs_full list, and slabs_partial
is always empty. Even if the active object number does not exactly
occupy all slabs.
Does that mean Linux 2.6 remove the use of slabs_partial?
Another question, the constructor transfered to the
kmem_cache_create() function is called for every object in a slab when
it is created. Is this true? Is there any way to call back a function
_only once_ when a new slab is allocated?
Thanks,
Xin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Linux SLAB allocator issue
2006-06-06 20:58 Linux SLAB allocator issue Xin Zhao
@ 2006-06-07 12:16 ` Pekka Enberg
2006-06-07 15:37 ` Xin Zhao
0 siblings, 1 reply; 4+ messages in thread
From: Pekka Enberg @ 2006-06-07 12:16 UTC (permalink / raw)
To: Xin Zhao; +Cc: linux-kernel, linux-fsdevel
On 6/6/06, Xin Zhao <uszhaoxin@gmail.com> wrote:
> I am trying to check how many slabs are used for inode_cache, but
> found that all slabs are added to slabs_full list, and slabs_partial
> is always empty. Even if the active object number does not exactly
> occupy all slabs.
>
> Does that mean Linux 2.6 remove the use of slabs_partial?
No. If slabs_partial is really empty, the number of active objects
should match the number of objects in a slab; otherwise you should see
an error message when you do cat /proc/slabinfo (see s_show in
mm/slab.c for details).
How are you verifying that the partial list is empty?
On 6/6/06, Xin Zhao <uszhaoxin@gmail.com> wrote:
> Another question, the constructor transfered to the
> kmem_cache_create() function is called for every object in a slab when
> it is created. Is this true? Is there any way to call back a function
> _only once_ when a new slab is allocated?
We don't have per-slab constructors. Only per-object. What do you need it for?
Pekka
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Linux SLAB allocator issue
2006-06-07 12:16 ` Pekka Enberg
@ 2006-06-07 15:37 ` Xin Zhao
2006-06-07 17:41 ` Christoph Lameter
0 siblings, 1 reply; 4+ messages in thread
From: Xin Zhao @ 2006-06-07 15:37 UTC (permalink / raw)
To: Pekka Enberg; +Cc: linux-kernel, linux-fsdevel
Thanks for your kind reply.
I did the following experiment.
I create my own cache with kmem_cache_create() and specify the
constructor to be init_once()-- a simple constructor like NFS does.
I checked the cache parameter and find that each slab has 1 page and
can hold 10 objects.
Then, I used kmem_cache_alloc() to allocate 128 objects. So it should
occupy 12 full slabs and 1 partial slab. Right?
But when I walk through the slabs_full and slabs_partial list, I found
that slabs_full returned 13 slabs but slabs_partial returned 0.
That's why I am confused. I am using 2.6.16 BTW.
Any further insight?
Thanks,
Xin
On 6/7/06, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> On 6/6/06, Xin Zhao <uszhaoxin@gmail.com> wrote:
> > I am trying to check how many slabs are used for inode_cache, but
> > found that all slabs are added to slabs_full list, and slabs_partial
> > is always empty. Even if the active object number does not exactly
> > occupy all slabs.
> >
> > Does that mean Linux 2.6 remove the use of slabs_partial?
>
> No. If slabs_partial is really empty, the number of active objects
> should match the number of objects in a slab; otherwise you should see
> an error message when you do cat /proc/slabinfo (see s_show in
> mm/slab.c for details).
>
> How are you verifying that the partial list is empty?
>
> On 6/6/06, Xin Zhao <uszhaoxin@gmail.com> wrote:
> > Another question, the constructor transfered to the
> > kmem_cache_create() function is called for every object in a slab when
> > it is created. Is this true? Is there any way to call back a function
> > _only once_ when a new slab is allocated?
>
> We don't have per-slab constructors. Only per-object. What do you need it for?
>
> Pekka
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Linux SLAB allocator issue
2006-06-07 15:37 ` Xin Zhao
@ 2006-06-07 17:41 ` Christoph Lameter
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Lameter @ 2006-06-07 17:41 UTC (permalink / raw)
To: Xin Zhao; +Cc: Pekka Enberg, linux-kernel, linux-fsdevel
On Wed, 7 Jun 2006, Xin Zhao wrote:
> Then, I used kmem_cache_alloc() to allocate 128 objects. So it should
> occupy 12 full slabs and 1 partial slab. Right?
There may be additional objects in the various caches. If this is a UP
system then some will certainly be in the per cpu cache.
You can push these back into the free lists by draining the array cache.
If you allocate objects on a slab that is fresh (no objects in it) then
only full slabs will be used. The remaining objects will end up on the per
cpu lists where they can be consumed without more work on the full/partial
arrays.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-07 17:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-06 20:58 Linux SLAB allocator issue Xin Zhao
2006-06-07 12:16 ` Pekka Enberg
2006-06-07 15:37 ` Xin Zhao
2006-06-07 17:41 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).