[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: memory allocation in kernel
Guennadi Liakhovetski wrote:
>
> Hi
>
> Could somebody, please, tell me: what is vmalloc() and is there an
vmalloc() allocates kernel memory that is not necessarily
physically contiguous, and maps that memory into kernel virtual
memory contiguously. (As opposed to eg get_free_pages(), which
always returns a contiguous block of physical pages mapped at kernel
address PAGE_OFFSET+physical_address.)
Why use vmalloc() rather than get_free_pages() or kmalloc()?
Physical memory fragmentation is not a problem for vmalloc() (as it
is for get_free_pages()), so requests for large blocks using
vmalloc() are more likely to succeed. Also vmalloc() requests can
be of arbitrary size, whereas the slab allocator (kmalloc()) can
only deal well with a limited range of request sizes, as I understand
it (though I have not looked at kmalloc() in detail yet).
I have read somewhere that Linus would like to get rid of
vmalloc(), but I don't know if that is still true, or if it is,
what it is that he dislikes about vmalloc().
> anologue of realloc() (krealloc...)?
I don't know for sure, but I do not think there is such a thing.
You probably need to allocate new memory and do the copying
yourself.
HTH,
-- Joe
-- Joe Knapka
"It was just a maddened crocodile hidden in a flower bed. It could
have happened to anyone." -- Pratchett
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
* Evolution is an "unproven theory" in the same sense that gravity is. *
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml