Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Linux partition page frame allocator

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Linux partition page frame allocator how to use", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux partition page frame allocator how to use" it!

Partition page frame allocator

The mechanism of page frame allocation in the kernel is called the partition page frame allocator (zoned page frame allocator). In the linux system, the partition page frame allocator manages all physical memory. No matter you are the kernel or the process, you need to request the partition page frame allocator. Only then will it be allocated to the physical memory page frame you should get. When the page frames you have are no longer in use, you must release them and return them to the administrative area page frame allocator.

Sometimes the target management area does not necessarily have enough page frames to meet the allocation, and the system will obtain the required page frames from the other two management areas, but this is carried out according to certain rules, as follows:

If you want to get it from the DMA zone, you can only get it from the ZONE_DMA zone. If you don't specify which zone to get from, get it from ZONE_NORMAL-> ZONE_DMA in order. If it is specified to be obtained from the HIGHMEM area, it will be obtained from ZONE_HIGHMEM-> ZONE_NORMAL-> ZONE_DMA in order.

Its function interface

There are six function interfaces in the kernel to request page frames according to different allocation requirements, all of which will eventually be called to _ _ alloc_pages_nodemask.

You can see that the core function of the page frame allocator is _ _ alloc_pages_nodemask. Before we talk about this function, let's take a look at two flags:

Gfp_mask__GFP_DMA: request to allocate pages in ZONE_DMA area; _ _ GFP_HIGHMEM: request to allocate pages in ZONE_HIGHMEM area; _ _ GFP_MOVABLE:ZONE_MOVALBE to allocate pages in this area when available, indicating that pages can be migrated or recycled when memory is compressed; _ _ GFP_RECLAIMABLE: requests are allocated to recoverable pages; _ _ GFP_HIGH: requests are processed with high priority _ _ GFP_IO: request to perform I GFP_FS O operation during allocation; _ _ GFP_FS: request to make file system call during allocation; _ _ GFP_ZERO: request to initialize the allocated area to 0; failure is not allowed and will be retried indefinitely; _ _ GFP_NORETRY: request not to retry memory allocation request; alloc_flagsALLOC_WMARK_MIN: restrict page allocation only at the minimum water level water mark and above ALLOC_WMARK_LOW: restrict page allocation only in low water level water mark and above; ALLOC_WMARK_HIGH: restrict page allocation only in high water level water mark and above; ALLOC_HARDER: try to allocate, usually used when _ _ GFP_ATOMIC is set in gfp_mask; ALLOC_HIGH: high priority allocation, usually used when _ _ GFP_HIGH is set in gfp_mask; ALLOC_CPUSET: check whether it is correct cpuset;ALLOC_CMA: allow allocation from CMA area _ _ alloc_pages_nodemaskstruct page *

_ _ alloc_pages_nodemask (gfp_t gfp_mask, unsigned int order, int preferred_nid

Nodemask_t * nodemask)

{

Page = get_page_from_freelist (alloc_mask, order, alloc_flags, & ac); / / fastpath allocation page: normal allocation of memory space from pcp (per_cpu_pages) and partner systems

.

Page = _ _ alloc_pages_slowpath (alloc_mask, order, & ac); / / slowpath allocation page: if no space is allocated above, call the following function for slow allocation to allow waiting and recycling

.

}

In the page allocation, there are two paths to choose, if the allocation in the fast path is successful, then directly return to the assigned page; if the fast path assignment fails, choose the slow path to allocate. The summary is as follows:

Normal distribution (or quick distribution):

If a single page is allocated, consider allocating space from the per CPU cache, and if there are no pages in the cache, extract the page from the partner system as a supplement.

When multiple pages are assigned, they are allocated from the specified type, or from the list of alternate types if there are not enough pages in the specified type. Finally, the retention type linked list will be tested.

Slow (allow waiting and page recycling) allocation: when the above two allocation schemes can not meet the requirements, consider page recycling, kill process and other operations before trying. Thank you for your reading, the above is the "Linux partition page frame allocator how to use" the content, after the study of this article, I believe you on the Linux partition page frame allocator how to use this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report