开发者

What is the major difference between kmalloc and vmalloc? [duplicate]

This question already has answers here: 开发者_StackOverflow中文版 Closed 12 years ago.

Possible Duplicate:

What is the difference between vmalloc and kmalloc?

Please tell in detail explanation


kmalloc allocates physically contiguous memory, memory which pages are laid consecutively in physical RAM. vmalloc allocates memory which is contiguous in kernel virtual memory space (that means pages allocated that way are not contiguous in RAM, but the kernel sees them as one block).

kmalloc is the preffered way, as long as you don't need very big areas. The trouble is, if you want to do DMA from/to some hardware device, you'll need to use kmalloc, and you'll probably need bigger chunk. The solution is to allocate memory as soon as possible, before memory gets fragmented.

If you only allocate small chunks (page or few pages), just use kmalloc and don't worry about details. :)

Above answer has been copied from source - http://kerneltrap.org/node/4020


kmalloc returns physically contiguous memory, kmalloc memory is reserved and locked, it cannot be swapped, Memory is subject to fragmentation, If you don't need contiguous mapping in kernel space, you can use vmalloc to avoid the fragmentation problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜