memory management - Difference between return values of alloc_pages() and get_free_pages() -
why require alloc_pages() return pointer struct page unlike other memory allocator function (get_free_pages(), kmalloc() ) ? please provide use case. related highmem zone allocation?
alloc_pages(mask, order)
allocates 2order pages , returns instance of struct page represent start of reserved block. alloc_page(mask) shorter notation order = 0 if 1 page requested.
__get_free_pages(mask, order) , __get_free_page(mask)
work in same way above functions return virtual address of reserved memory chunk instead of page instance.
kmalloc(size, mask)
reserves memory area of size bytes , returns void pointer start of area. if insufficient memory available (a improbable situation in kernel 1 must catered for), null pointer result.
mask speciļ¬es details request:
• memory zone • behavior of allocator (blocking/unblocking request, etc.) • e.g. gfp_kernel, gfp_atomic, gfp_dma, etc
alloc_pages() , __get_free_pages() : allocate pages, @ low level
kmalloc() : allocate physically contiguous sequence of bytes
for more information refer professional linux kernel architecture wolfgang mauerer
Comments
Post a Comment