Chapter3:MemoryManagement
Setting__GFP_MOVABLEwill not influence the kernel’s decision unless it is specified together
with__GFP_HIGHMEM. In this case, the special virtual zoneZONE_MOVABLEwill be used to satisfy
a memory request. This behavior is essential for the anti-fragmentation strategy of the kernel as
outlined.
A few flags can be set in the mask in addition to the zone modifiers. Figure 3-29 shows the layout of the
mask and the constants associated with the bit positions.__GFP_DMA32appears several times because it
may be located at different places.
Flags
Zone
modifiers
_ _GFP_MOVABLE
_ _GFP_RECLAIMABLE
_ _GFP_THISNODE_ _GFP_HADRWALL
_ _GFP_NOMEMMALLOC
_ _GFP_ZERO_ _GFP_COMP
_ _GFP_NO_GROW_ _GFP_NORETRY_ _GFP_NOFAIL_ _GFP_REPEAT_ _GFP_NOWARN
_ _GFP_COLD
_ _GFP_FS_ _GFP_IO
_ _GFP_HIGH_ _GFP_WAIT_ _GFP_DMA
_ _GFP_HIGHMEM_ _GFP_DMA (32)
Figure 3-29: Layout of a GFP mask.
In contrast to the zone modifiers, the additional flags donotlimit the RAM segments from which
memory can be allocated, but they do alter the behavior of the allocator. For example, they modify
how aggressively a search is made for free memory. The following flags are defined in the kernel
sources:
/* Action modifiers - doesn’t change the zoning */
#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */
#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */
#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */
#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */
#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */
#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */
#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */
#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */
#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */
#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */
#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */
#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */
#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don’t use emergency reserves */
#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */
#define __GFP_THISNODE ((__force gfp_t)0x40000u)/* No fallback, no policies */
#define __GFP_RECLAIMABLE ((__force gfp_t)0x80000u) /* Page is reclaimable */
#define __GFP_MOVABLE ((__force gfp_t)0x100000u) /* Page is movable */