LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   vmalloc or kmalloc for 16k memory space (http://www.linuxquestions.org/questions/linux-kernel-70/vmalloc-or-kmalloc-for-16k-memory-space-885748/)

lorizhuang 06-11-2011 10:45 AM

vmalloc or kmalloc for 16k memory space
 
I'm writing a device driver. When the device is going to be suspended, the driver allocates a 16k memory space. When the device is going to be resumed, the driver frees this memory space. The suspend/resume may happen quite often. My problem is whether to use vmalloc or kmalloc for this allocation. kmalloc is faster, but I'm worried about that frequently allocating & releasing a 16k memory space easily leads to a failure in allocation. vmalloc doesn't have this problem, but it's not as efficient as kmalloc.

nini09 06-13-2011 02:21 PM

For 16k memory, do you use it for hardware operation? If not, vmalloc should be Ok.

lorizhuang 06-14-2011 03:33 AM

No hardware operation, but vmalloc is expensive, it has to setup page tables.

nini09 06-14-2011 02:26 PM

You can use mempool to avoid frequently allocating & releasing physically. The pool always hold the memory even if the memory is freed.


All times are GMT -5. The time now is 02:46 PM.