From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Xin Zhao" Subject: Re: Linux SLAB allocator issue Date: Wed, 7 Jun 2006 11:37:18 -0400 Message-ID: <4ae3c140606070837t23182496s42edb3a754169d43@mail.gmail.com> References: <4ae3c140606061358j140eec9fl45e22f8a9e673215@mail.gmail.com> <84144f020606070516m4bccdecdr998941ee74744a83@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-kernel , linux-fsdevel@vger.kernel.org Return-path: Received: from wr-out-0506.google.com ([64.233.184.234]:56342 "EHLO wr-out-0506.google.com") by vger.kernel.org with ESMTP id S932268AbWFGPhT (ORCPT ); Wed, 7 Jun 2006 11:37:19 -0400 Received: by wr-out-0506.google.com with SMTP id i11so462484wra for ; Wed, 07 Jun 2006 08:37:19 -0700 (PDT) To: "Pekka Enberg" In-Reply-To: <84144f020606070516m4bccdecdr998941ee74744a83@mail.gmail.com> Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 wrote: > On 6/6/06, Xin Zhao 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 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 >