the cost of vmalloc

Zheng Da zhengda1936 at
Sat Sep 10 11:15:02 EDT 2011

On Sat, Sep 10, 2011 at 3:35 AM, Michael Blizek
<michi1 at> wrote:
>> I need to allocate fairly a large piece of memory, about 128KB or
>> 256KB. I tried to use kmalloc, and it sometimes fails, but vmalloc in
>> this case usually still work.
>> But I'm not sure how costly vmalloc is. As far as I know, vmalloc
>> needs to change the page table, and thus might need to invalidate TLB.
>> It seems quite expensive. If it is, maybe I can allocate memory with
>> kmalloc first, and then try to use vmalloc if kmalloc fails. Any
>> suggestions?
> If it is at all possible, I would suggest avoiding to allocate more than
> PAGE_SIZE (usually 4KB) in one continuous chunk. You can use e.g.
> scatterlists (which are basically lists of pointers) if you need a bigger
> buffer.
Actually, I have seen some problems when allocating large pieces of
memory constantly. Occasionally, I see alloc_pages and kmalloc fails
to allocate the memory I want.
The whole point of allocating a large chunk of memory is to avoid
extra memory copy because I need to run decompression algorithms on
Or memory copy is cheaper?
I'm also thinking of using slab allocator. The size of memory I need
to allocate can change from 20KB to 128KB. Then I need quite a few
slab allocators.


More information about the Kernelnewbies mailing list