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. :)
hmmm..does this mean that if you allocate size less than the maximum for kmalloc(128kb) using vmalloc, would it still be contiguous in physical memory?
kmalloc vs vmalloc
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. :)
kmalloc vs vmalloc
Hi All,
When we want a big chunk (8Kb) of memory does Kmalloc allocates Physically conguious memory or it will be discrete
Regards
Anand
kmalloc always allocates cont
kmalloc always allocates contiguous chunks.
Regards,
Narendra Kiran Chinnam.
8Kb not a big chunk! That th
8Kb not a big chunk!
That the kmalloc can malloc max chunk is 128K !
Wouldn't anything above 4k be
Wouldn't anything above 4k be a 'big' chunk in that it's more than a single page, which means a set of neighbouring pages must be found?
Finding two consequent pages
Finding two consequent pages (8k) is not a big problem unless the memory is almost extinct/too fragmented.
Regards,
Narendra Kiran Chinnam.
Most hardware is able to do s
Most hardware is able to do scatter-gather with DMA, so big contiguous areas aren't needed often.
What to do if we want to
What to do if we want to allocate chunks of more than 128k?????????????
use buddy allocator.
u can make new-size slab with slab allocator
or use buddy allocator directly.
contiguous issues
hmmm..does this mean that if you allocate size less than the maximum for kmalloc(128kb) using vmalloc, would it still be contiguous in physical memory?
Maybe, but it is not
Maybe, but it is not guaranteed to. Always assume vmalloc returns physically-discontiguous memory regions.