On Fri, 2005-12-16 at 11:42 -0800, Sanjay Acharya wrote: > Hello, > > I wanted to know the difference between vmalloc and kmalloc. I > understand the following, > 1. kmalloc allocations are physically contiguous whereas vmalloc > allocations may not be. > 2. kmalloc allocations have a size limit of 128KB (I am not sure of the > size limitations of vmalloc) > 3. vmalloc allocations can sleep and hence should not be used in an > interrupt context unlike kmalloc vmalloc is also limited to a system wide limit of somewhere between 64Mb and 128Mb *total*, eg you shouldn't depend on all allocations combined exceeding 64Mb (exact limit depends on the amount of ram and which PCI cards are present, 64Mb seems a reasonably safe value) vmalloc memory is generally slower than kmalloc memory due to TLB effects (it's indirect memory unlike "normal" kernel memory) vmalloc memory has a guard page at the end of it to detect overflows (it oopses if you go to far ;) vmalloc really should only be used during init of modules, not during "normal operation", since it's really slow in alloc/free as well (it sometimes needs a cross cpu tlb flush for example) vmalloc memory can't be used for dma without going through hoops, kmalloc memory can when using the pci dma mapping api in general the rule of thumb is: avoid vmalloc whenever possible. If you need a big allocation, think twice, and think again. Maybe it can be redesigned as a list or array of single pages for example. Only if you're really sure you can't do otherwise, use vmalloc in your initialisation. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/