Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


Memory management based on the buddy system isconcentrated on a single memory zone of a node,
for instance, the DMA or high-memory zone. However, the buddy systems of all zones and nodes are
linked via the allocation fallback list. Figure 3-23 illustrates this relationship.

When a request for memory cannot be satisfied in the preferred zone or node, first another zone in the
same node, and then another node is picked to fulfill the request.

Zone Zone Zone

Zone Zone Zone

Fallback
list

Figure 3-23: Relationship between buddy system and memory zones/nodes.

Finally, note that information about the current state of the buddy system is available in
/proc/buddyinfo:

wolfgang@meitner>cat /proc/buddyinfo
Node 0, zone DMA 3 5 7 4 6 3 3 3 1 1 1
Node 0, zone DMA32 130 546 695 271 107 38 2 2 1 4 479
Node 0, zone Normal 23 6 6 81430000


The number of free entries per allocation order is printed for each zone, and the order increases from left
to right. The information shown above is taken from an AMD64 system with 4 GiB of RAM.

3.5.2 Avoiding Fragmentation


In the simplified explanation given in the Introduction, one doubly linked list was sufficient to satisfy all
the needs of the buddy system. This has, indeed, been the situation until kernel 2.6.23. During the devel-
opment of the kernel 2.6.24, the buddy system has, however, seen the integration of patches disputed
among the kernel developers for an unusually long amount of time. Since the buddy system is one of the
most venerable components of the kernel, changes are not accepted lightly.

Grouping Pages by Mobility


The basic principle of the buddy system has been discussed in the Introduction, and the scheme has,
indeed, worked very well during the last couple of years. However, there is one issue that has been a
long-standing problem with Linux memory management: After systems have been up and running for
longer times, physical memory tends to become fragmented. The situation is depicted in Figure 3-24.
Free download pdf