lkml.org 
[lkml]   [2000]   [Aug]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: When to use kmem_cache_alloc()?
On Mon, Aug 07, 2000 at 02:59:24PM +0000, Erik Mouw wrote:
> Hi,
>
> Is there a general guideline that says when kmem_cache_alloc() is
> preferred over kmalloc()?

kmem_cache_alloc makes sense when you allocate multiple objects with the
same size. It currently always uses an own page so you probably should have
more than ~2K bytes of objects at least to avoid wasting memory. It also
makes sense when your object sizes fit poorly into the power-of-2 kmalloc
sizes or when you need very fast allocation. In case your objects require
initialization it may also make sense to use the slab constructor/deconstructor
feature in this case.

kmem_cache_alloc creates less fragmentation than kmalloc because objects with
similar livetime are clustered together.

Hope this helps,

-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.055 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site