Re: [RFC] kmem_cache_zalloc

From: Dipankar Sarma (dipankar@in.ibm.com)
Date: Thu Mar 28 2002 - 06:40:21 EST


On Thu, Mar 28, 2002 at 11:25:12AM +0000, David Woodhouse wrote:
>
>
> dipankar@in.ibm.com said:
> > I thought that the life span of an object is between
> > kmem_cache_alloc and kmem_cache_free. If you are expecting caching
> > beyond this, you may not get correct data. kmem_cache allocator is
> > supposed to quickly allocate fixed size structures avoiding the need
> > for frequent splitting and coalescing in the allocator.
>
> > Am I missing something here ?
>
> Yes. Slab objects can be initialised once when a new page is added to the
> slab, and returned to the slab in reusable form so that you don't have the
> cost of complete initialisation on each allocation.
>
> So if for example you have a semaphore in your slab object, instead of
> initialising it on each kmem_cache_alloc() you do it once when the new pages
> are added to the slab. Then you just make sure it's unlocked each time you
> free a slab object.

Ok. That makes clear why hch thought kmem_cache_alloc() can lead
to people writing bad code.

Thanks

-- 
Dipankar Sarma  <dipankar@in.ibm.com> http://lse.sourceforge.net
Linux Technology Center, IBM Software Lab, Bangalore, India.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Mar 31 2002 - 22:00:16 EST