Article directory
1. Analysis of physical page allocation flags
Use the watermark bit to allocate memory , the relevant source code is defined in the linux-4.12\mm\internal.h #475 location of the Linux kernel source code ;
1. Watermark related flags ( ALLOC_WMARK_MIN | ALLOC_WMARK_LOW | ALLOC_WMARK_HIGH | ALLOC_NO_WATERMARKS )
ALLOC_WMARK_MIN
Macro definition, indicating that the "lowest watermark" is used to allocate memory;
ALLOC_WMARK_LOW
Macro definition, indicating the use of "low watermark" to allocate memory;
ALLOC_WMARK_HIGH
Macro definition, indicating the use of "high watermark" to allocate memory;
ALLOC_NO_WATERMARKS
Macro definition, indicating that when using allocated memory, the watermark is not checked;
/* The ALLOC_WMARK bits are used as an index to zone->watermark */
#define ALLOC_WMARK_MIN WMARK_MIN
#define ALLOC_WMARK_LOW WMARK_LOW
#define ALLOC_WMARK_HIGH WMARK_HIGH
#define ALLOC_NO_WATERMARKS 0x04 /* don't check watermarks at all */
Source code path: linux-4.12\mm\internal.h #475
2. Watermark bit source code ( ALLOC_WMARK_MASK )
ALLOC_WMARK_MASK
Macro definition, which means to get the mask of "watermark bit";
/* Mask to get the watermark bits */
#define ALLOC_WMARK_MASK (ALLOC_NO_WATERMARKS-1)
Source code path: linux-4.12\mm\internal.h #481
3. Physical page allocation flag ( ALLOC_HARDER | ALLOC_HIGH | ALLOC_CPUSET | ALLOC_CMA )
ALLOC_HARDER
Macro definition, which means trying to allocate memory harder;
ALLOC_HIGH
Macro definition, which means to set the caller's __GFP_HIGH
high priority;
ALLOC_CPUSET
Macro definition, which means to check whether cpuset is allowed to allocate memory pages;
ALLOC_CMA
Macro definition, indicating that the CMA continuous memory allocator migration type is allowed to allocate memory;
#define ALLOC_HARDER 0x10 /* try to alloc harder */
#define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
#define ALLOC_CPUSET 0x40 /* check for correct cpuset */
#define ALLOC_CMA 0x80 /* allow allocations from CMA areas */
Source code path: linux-4.12\mm\internal.h #483
2. Complete source code of physical page allocation related flag bits
The source code is as follows:
/* The ALLOC_WMARK bits are used as an index to zone->watermark */
#define ALLOC_WMARK_MIN WMARK_MIN
#define ALLOC_WMARK_LOW WMARK_LOW
#define ALLOC_WMARK_HIGH WMARK_HIGH
#define ALLOC_NO_WATERMARKS 0x04 /* don't check watermarks at all */
/* Mask to get the watermark bits */
#define ALLOC_WMARK_MASK (ALLOC_NO_WATERMARKS-1)
#define ALLOC_HARDER 0x10 /* try to alloc harder */
#define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
#define ALLOC_CPUSET 0x40 /* check for correct cpuset */
#define ALLOC_CMA 0x80 /* allow allocations from CMA areas */
Source code path: linux-4.12\mm\internal.h #475