Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


The intervals for the other zones are then constructed in a straightforward manner: Thesmallestpage
frame for then-th zone is thelargestpage frame of the previous (nāˆ’1) zone. The largest page frames for
the current zone are already available inmax_zone_pfn.

mm/page_alloc.c
arch_zone_lowest_possible_pfn[ZONE_MOVABLE] = 0;
arch_zone_highest_possible_pfn[ZONE_MOVABLE] = 0;

/* Find the PFNs that ZONE_MOVABLE begins at in each node */
...
find_zone_movable_pfns_for_nodes(zone_movable_pfn);

SinceZONE_MOVABLEis a virtual zone and not associated with real hardware zones, the zone bound-
aries are always set to zero. Recall from above that it only exists if any of the kernel command-line
parameterkernelcoreormovablecorewas specified. The movable zone for each node starts above a
certain page frame number of a specific zone for each node. The corresponding numbers are computed
infind_zone_movable_pfns_for_nodes.

Some information about the determined page frame intervals is proudly presented to the user. This
includes, for instance, the following (the output is taken on an AMD64 system with 4 GiB of RAM):

root@meitner #dmesg
...
Zone PFN ranges:
DMA 0 -> 4096
DMA32 4096 -> 1048576
Normal 1048576 -> 1245184
...

The remaining portion offree_area_init_nodesiterates over all nodes to set up the data structures
for each.

mm/page_alloc.c
/* Print information about zones */
...
/* Initialise every node */
for_each_online_node(nid) {
pg_data_t *pgdat = NODE_DATA(nid);
free_area_init_node(nid, pgdat, NULL,
find_min_pfn_for_node(nid), NULL);

/* Any memory on that node */
if (pgdat->node_present_pages)
node_set_state(nid, N_HIGH_MEMORY);
check_for_regular_memory(pgdat);
}
}

The code iterates over all active nodes and delegates setting up the data structures for each to
free_area_init_node. The function requires the first available page frame as a parameter, and
find_min_pfn_for_nodeextracts this information from theearly_node_maparray.
Free download pdf