Info

/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */

#define _GFP_HIGHMEM ((_force gfp_t)0x02u)

#define _GFP_DMA32 ((_force gfp_t)0x04u)

#define _GFP_MOVABLE ((_force gfp_t)0x100000u) /* Page is movable */

These constants are familiar from Section 3.4.1 in which the creation of fallback lists is discussed. The abbreviation gfp stands for get free pages._gfp_movable does not represent a physical memory zone, but instructs the kernel that an allocation should be fulfilled from the special virtual zone ZONE_MOVABLE.

Interestingly, there is no_gfp_normal constant, although the main burden of allocation falls on this zone. The kernel takes account of this fact by providing a function that calculates the highest memory zone compatible with the given allocation flags. Allocations can then be made from this zone and from those below it.

mm/page_alloc.c static inline enum zone_type gfp_zone(gfp_t flags) {

#ifdef CONFIG_ZONE_DMA

return ZONE_DMA;

#endif

#ifdef CONFIG_ZONE_DMA32

return ZONE_DMA32;

#endif if ((flags & (_GFP_HIGHMEM | _GFP_MOVABLE)) ==

return ZONE_MOVABLE; #ifdef CONFIG_HIGHMEM

return ZONE_HIGHMEM;

#endif return ZONE_NORMAL;

Because the way in which the zone modifiers are interpreted may not immediately appear to be intuitive, Table 3-7 shows an example of the function results when the zones for DMA and DMA32 are identical. Assume that the_gfp_movable modifier is not set in the following:

If both_gfp_dma and_gfp_highmem are not set, zone_normal is first scanned, followed by zone_dma. If

_gfp_highmem is set and_gfp_dma is not set, the result is that all three zones are scanned starting with zone_highmem. If_gfp_dma is set, it is irrelevant to the kernel whether_gfp_highmem is set or not. Only zone_dma is used in both cases. This is reasonable because the simultaneous use of_gfp_highmem and

_gfp_dma makes no sense. Highmem is never DMA-suitable.

Table 3-7: Correlation between Zone Modifiers and Zones Scanned

Modifier

Zones scanned

Empty

ZONE_NORMAL, ZONE_DMA

_GFP_DMA

ZONE_DMA

_GFP_DMA &_GFP_HIGHMEM

ZONE_DMA

_GFP_HIGHMEM

ZONE_HIGHMEM, ZONE_NORMAL, ZONE_DMA

Setting_gfp_movable will not influence the kernel's decision unless it is specified together with_gfp_highmem. In this case, the special virtual zone zone_movable will 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_dma32 appears several times because it may be located at different places.

Zone

UO^S^J^SQWO OPiSOPiH^PifefeH fefeOpi^^fe^O I I feNUOfefe^^O^^ «¡ I I I OS O H O I fefe fe fe ^ ^ O ü pi fe fe S

S S

Continue reading here: Figure 329 Layout of a GFP mask

Was this article helpful?

0 0