query related to kmalloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Just wanted to know, is it a good idea to kmalloc for a small
structure. For example if I define a structure in kernel of 10 bytes,
and I want to get the memory allocated dynamically for it N number of
times, is it good to kmalloc for it every time.

As kmalloc() allocates the memory in terms of page size (4k), atleast
4K will be allocated for each kmalloc() call in above case. On other
side, wont it be good idea to get one page allocated with kmalloc()
and then use it to store an array of our 10 byte structure and if we
need more we can get one more page allocated with kmalloc(). In this
way we can have list of kmalloc'ed pages and each page represents the
array of out 10 byte strucutre.

I am asking this as I am adopting the second approch (list of
kmalloc'ed pages) in one of my kernel modules, just wanted to know is
it worth doing so much of list maintaince of kmalloc'ed pages or we
can simply use the kmalloc for allocating memory to each structure.

regards,
-Gaurav

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux