what is the difference between kmalloc and vmalloc?

Mulyadi Santosa mulyadi.santosa at gmail.com
Mon Nov 26 03:25:34 EST 2012


Hi...

On Mon, Nov 26, 2012 at 1:51 PM, Vijay Chauhan <kernel.vijay at gmail.com> wrote:
> Is it necessary that vmalloc always allocate virtually contiguous
> memory and not physically contiguous?

to the best I know, yes vmalloc allocate virtually contigous.

However, since they manage the pages by fiddling with the page tables,
there is a chance that some of them are physically contigous IMHO

> Except large size memory allocation why one needs to use vmalloc? Can
> we say that use kmalloc and  if it fails retry with kmalloc?

nice question: AFAIK vmalloc() is made to tackle large size memory
allocation, or in other word to side step memory fragmentation issue.

IIRC too, that by using vmalloc, the vmalloc-ed area are guarded by
guard pages on both start and end address. So it's like stack overflow
guard pages. But don't count me on this info. Check it by yourself.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list