Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


After the first step, the allocation targets in the list are highmem, followed by normal memory and finally
the DMA zone of the second node.

The kernel must then establish the order in which the zones of the other nodes in the system are used as
fallback targets.

mm/page_alloc.c
static void __init build_zonelists(pg_data_t *pgdat)
{
...
for (node = local_node + 1; node < MAX_NUMNODES; node++) {
j = build_zonelists_node(NODE_DATA(node), zonelist, j, i);
}
for (node = 0; node < local_node; node++) {
j = build_zonelists_node(NODE_DATA(node), zonelist, j, i);
}

zonelist->zones[j] = NULL;
}
}
}

The first loop successively iterates over all nodes with ahighernumber than the node being processed. In
our example, there are four nodes numbered 0, 1, 2, and 3 and therefore only node number 3 is left. New
entries are added to the fallback list bybuild_zonelists_node. This is where the meaning ofjcomes
into play. After the fallback targets in the local node had been found, the value of the variable was 3;
this is used as the starting position for the new entries. If node number 3 also consists of three zones, the
situation after invocation ofbuild_zonelistsis as shown in the second step of Figure 3-9.

The secondforloop then generates the entries for all nodes withlowernumbers than the current node.
In our example, these nodes have the numbers 0 and 1. If three zones are also present in these nodes, the
fallback list situation is as shown in the lower part of Figure 3-9.

The number of entries in the fallback list is never known exactly because the zone configurations may be
different in the various nodes of the system. The last entry is therefore assigned a null pointer to explicitly
mark the end of the list.

For any nodemof a total number ofNnodes, the kernel always selects the orderm,m+1,m+
2,...,N,0,1,...,m−1 for the fallback nodes. This ensures that no node is overused (as compared, e.g.,
to an unchanging fallback list independent ofm).

Figure 3-10 shows the fallback lists built for the third node in a system with four nodes.

Normal

DMA

HighMem A0D0C0 B2 NULL

D1C0C1 D0 A1 A0 B1 B0 NULL

C0C1C2 D2 D1 D0 A2 A1 A0 B2 B1 B0 NULL

Figure 3-10: Finished fallback lists.
Free download pdf