public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dipankar Sarma <dipankar@in.ibm.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: hch@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] kmem_cache_zalloc
Date: Thu, 28 Mar 2002 17:10:21 +0530	[thread overview]
Message-ID: <20020328171021.D22665@in.ibm.com> (raw)
In-Reply-To: <20020328165142.A23089@in.ibm.com> <20520.1017314712@redhat.com>

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.

  reply	other threads:[~2002-03-28 11:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-28 11:21 [RFC] kmem_cache_zalloc Dipankar Sarma
2002-03-28 11:25 ` David Woodhouse
2002-03-28 11:40   ` Dipankar Sarma [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-03-27 19:39 Eric Sandeen
2002-03-27 19:47 ` Andrew Morton
2002-03-27 19:52 ` Tigran Aivazian
2002-03-27 20:17   ` Alan Cox
2002-03-29 22:17     ` Pavel Machek
2002-03-29 23:21       ` Alan Cox
2002-03-27 20:19 ` Christoph Hellwig
2002-03-27 20:23   ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020328171021.D22665@in.ibm.com \
    --to=dipankar@in.ibm.com \
    --cc=dwmw2@infradead.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox