Re: using kmalloc

Jan Hudec (bulb@ucw.cz)
Wed, 20 Mar 2002 12:48:37 +0100


> kmalloc() allocates physically-contiguous pages of memory. Due to
> fragmentation, more than 64KB-128KB of contiguous pages might not be
> available, and hence kmalloc() will fail.

kmalloc allocates from generic slab caches. They come in sizes of powers
of 2 from 32B to 128KiB. The largest has slabs 128KiB large (on i386 at least).
Pages are allocated via __get_free_pages, so they have to be continuous.

However if you allocate namy instances of some structure, it's best to create
a kmem cache and allocate via kmem_cache_alloc (since it does not round the
requested size up to a power of two).

--------------------------------------------------------------------------------
- Jan Hudec `Bulb' <bulb@ucw.cz>
-
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/