[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
kernel malloc usage
- Subject: kernel malloc usage
- From: gheinig at syskonnect.de (Gerald Heinig)
- Date: Mon Nov 3 02:09:09 2003
Hi all,
I have a question concerning the use of malloc to allocate small amounts
of memory for packet wrappers for certain packets.
Basically, I'm using malloc in much the same way as one would use it in
a standard userland program: allocating small chunks and freeing them
again a short(ish) time later.
A colleague said this was a bad idea, since malloc should only really be
used to allocate larger chunks (PAGE_SIZE and over) at driver
initialisation. Management and partition of the allocated space should
be done by the driver. His reason was that over time, the kernel heap
memory gets progressively more fragmented until it becomes difficult to
get larger blocks.
Is this true? I seem to remember that FreeBSD has a slab allocator,
which IIRC is particularly good at allocating small chunks.
Is it a better idea to write my own allocators which use a larger block
of memory allocated by malloc at driver start-time, or can I use malloc
as in userland?
Cheers,
Gerald
--
S y s K o n n e c t G m b H
A Marvell Company
Siemensstr. 23
D-76275 Ettlingen, Germany
---------------------------------
Gerald Heinig
Software Engineer
-------------------------------------
phone: + 49 (0) 7243 502 354
fax: +49 (0) 7243 502 364
email: gheinig_(_at_)_syskonnect_(_dot_)_de
http://www.syskonnect.com
Visit your host, monkey.org