[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kmalloc issue
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, Aug 10, 2007 at 10:42:14AM +0200, Andrea Gasparini wrote:
> i have a structure that could grow while time goes on.
> rather that have a biiig static structure, we want to make it possible
> allocate it in block in order to don't make kmalloc call each single time,
> but don't make it to big if requests are a few.
>
> we have a code like that:
> too_little_mystruct = mystruct;
> mystruct =kmalloc(bunch_of_struct * sizeof(struct
> mystruct_type),GFP_KERNEL);
> memcpy(mystruct,too_little_mystruct,oldsize *sizeof(struct
> mystruct_type));
> kfree(old_head);
>
> but i think it could lead to waste of memory, or fragmentation. or at least
> it cuold be better have a single growing area.
>
> Are there some support for this kind of allocation inside the kernel?
> It could be enough using kmalloc and kfree?
> whatever?
Have a look at the slab allocator (kmem_cache_create() and friends).
Erik
- --
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGvDkE/PlVHJtIto0RArUPAJ4pmKBae3mx53H4f9ISjK4y7EKMPQCgjs84
iw3rIvWIZ9gmWPCpGweChag=
=G1FT
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ