http://scriptmatrix.net/cs2106/wiki/index.php/Zone_AllocatorZone AllocatorFrom The Linux Memory WikiThere are several functions and macros that can be used to allocate 2^order of contiguous page frames. 2 of these functions are essential while others are just macros that used to call that functions. alloc_pages(gfp_mask, order)struct page * __alloc_pages( unsigned int gfp_mask, unsigned int order, zonelist_t *zonelist) allocate 2^order of continuous page frames. This function returns the address of the page descriptor of the first page frame in this block. __get_free_pages(gfp_mask, order)unsigned long __get_free_pages(int flags, unsigned long order) same as alloc_pages(), it allocate 2^order of continuous page frames. But this function returns the linear address of the first page frame instead of the page descriptor address.
gfp_maskThe gfp_mask contains flags to describe the type of memory that is needed. For instance, there is a flag called __GFP_DMA to indicate if the zone needs to be from DMA zone, and another called __GFP_HIGHMEM to indicate High memory zone is needed. There are also some other flags such as the zero flag which request to zero the content of page frames after allocation. There are also a flag which indicate wheter the call can be blocked to wait until free memory is available or not.
|