[Linux Memory] Partner System Learning Notes (iii)--Allocator API

Source: Internet
Author: User

1, Allocator API

http://blog.csdn.net/kickxxx/article/details/9287003

A partner system can allocate only 2 of an integer to a power page. Therefore, when applying, you need to specify the order of the request assignment.

2, Allocation page,

The function allocation page for all assigned partner systems will eventually be called to the Alloc_pages_nodemask () function

Static inline struct page*alloc_pages_nodemask (int nid,gfp_t gfp_mask,unsigned int order)
Nid: Refers to which node is allocated from
Gfp_mask: Some signs
Order: Assign Order

The function is divided into two major strides:

1. Select the page to find enough contiguous pages in one of the migrated areas of a node, and the process is to start scanning the management area from the designated administrative district--and find a sufficient admin section to start the traversal from the identified administrative zone, until you find one that has enough space for example, if High_ Zoneidx corresponding ZONE_HIGHMEM, the traversal order is HIGHMEM-->NORMAL-->DMA if high_zoneidx corresponds to Zone_normal, then the traversal order is normal-->dma-- > allocates memory from the list of specified migration types and if it is not found in the specified migration type, to other migration types (Get_page_from_freelist ()), if the second step cannot find the allocated memory in each region, That means that the management area of the memory is not enough, so began to enable a slow way to allocate (__alloc_pages_slowpath), including the attempt to swap out some infrequently used pages and so on, the kernel will be more active in this allocation, The details involve some other complex stuff.

2, in the first part just to determine that there are so many free pages, not sure whether it is continuous, if it is continuous remove the page, the page will be allocated from the current partner system to remove ~ may be broken down by the partner system and re-arrange the memory partition. If you just assign a page, the kernel will be optimized, the allocation of one page will not be allocated from the partner system, but taken from the PER-CPU cache, if the current PER-CPU cache is empty, you need to call the Rmqueue_bulk () function from the partner system to allocate the appropriate page populated into the PER-CPU cache , if you are allocating more than one page of memory, the __rmqueue () function is called to allocate and decompose the rearrangement memory partition from the partner system.

If there is not enough free page memory in the current partner system ~ Then the kernel will take the action is: failed to try the slow allocation, the general process is to wake up the memory page recycling thread, and then try to low water allocation, ignore water level allocation, such as compressed memory allocation, directly reclaim memory allocation- > Oom killer kills thread allocation, compression memory allocation.

[Linux Memory] Partner System Learning Notes (iii)--Allocator API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.