Article directory
1. Regional waterline
The "preferred memory area " borrows physical memory from the "alternate memory area " in a specific case, which is related to the "area watermark" ;
Each "memory area" has 3 33 water lines:
① High water mark: High Water Marker, the number of free pages in the memory area is greater than the high water mark , and the memory is sufficient ;
② Low watermark: Low Water Marker, the number of free pages in the memory area is less than the low watermark , and the memory is slightly insufficient ;
③ Minimum water mark: Min Water Marker, the number of free pages in the memory area is less than the minimum water mark , and the memory is seriously insufficient;
The memory below the minimum waterline is "emergency reserved memory" , which will only be allocated to specific processes when the memory is seriously insufficient , and these processes must promise to "allocate a small amount of memory and release more memory";
2. Zone watermark data structure zone_watermarks enumeration ( WMARK_MIN | WMARK_LOW | WMARK_HIGH | NR_WMARK )
The data structure corresponding to the zone waterline is defined in the linux-4.12\include\linux\mmzone.h #255 location of the linux kernel source code , which is an enumeration;
enum zone_watermarks {
WMARK_MIN,
WMARK_LOW,
WMARK_HIGH,
NR_WMARK
};
Source code path: linux-4.12\include\linux\mmzone.h #255
3. The regional watermark members in the memory area zone
The member in the "memory area" structurestruct zone
is the area watermark used by the "page allocator" in the memory area;unsigned long watermark[NR_WMARK];
struct zone {
/* Read-mostly fields */
/* zone watermarks, access with *_wmark_pages(zone) macros */
unsigned long watermark[NR_WMARK];
}
Source code path: linux-4.12\include\linux\mmzone.h #354