Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


#endif
ZONE_MOVABLE,
MAX_NR_ZONES
};

In contrast to all other zones in the system,ZONE_MOVABLEis not associated with any memory range that
is of significance to the hardware. Indeed, the zoneis filled with memory taken from either the highmem
or the regular zone, and accordingly we callZONE_MOVABLEa virtual zone in the following.

The auxiliary functionfind_zone_movable_pfns_for_nodesis used to compute the amount of mem-
ory that goes intoZONE_MOVABLE. If neither thekernelcorenormovablecoreparameter was specified,
find_zone_movable_pfns_for_nodesleavesZONE_MOVABLEempty, and the mechanism is not active.

Two things must be considered with respect to how many pages are taken from a physical zone and used
forZONE_MOVABLE:

❑ The memory for non-movable allocations is spread evenly across all memory nodes.
❑ Only memory from the highest zone is used. On 32-bit systems with much memory, this will
usually beZONE_HIGHMEM, but for 64-bit systems,ZONE_NORMALorZONE_DMA32will be used.

The actual computation is rather lengthy, but not very interesting, so I do not consider it in detail. What
matters are the results:

❑ The physical zone from which pages for the virtual zoneZONE_MOVABLEare taken is stored in the
global variablemovable_zone.
❑ For each node, the page frame in the movable zone from which onward the memory belongs to
ZONE_MOVABLEis inzone_movable_pfn[node_id].
mm/page_alloc.c
unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];

The kernel ensures that these pages will be used to satisfy allocations that fall into the responsibility of
ZONE_MOVABLE.

Implementation


How are the data structures described so far brought to use? As with the page migration approach,
allocation flags play a crucial role. They are discussed below in Section 3.5.4 in more detail. Here, it
suffices to say that all movable allocations must specify both__GFP_HIGHMEMand__GFP_MOVABLE.

Since the kernel determines the zone from which an allocation is fulfilled by the allocation flags, it
can selectZONE_MOVABLEwhen the said flags are set. This is the only change required to integrate
ZONE_MOVABLEinto the buddy system! The rest is done bygeneric routines that work on all zones,
discussed below.

3.5.3 Initializing the Zone and Node Data Structures


Until now, we have only seen how the kernel detects the available memory in the system in the
architecture-specific code. The association with higher-level structures — zones and nodes — needs to
Free download pdf