Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


Naturally, not too many movable allocations willhave been performed during boot, so chances are
good that the allocator can pick maximally sized blocks and transfer them from the movable to the non-
movable list. Because the blocks have maximal size, no fragmentation is introduced into the movable
zone!

All in all, this avoids situations in which kernel allocations that are done during boot (and which
often last for the whole system uptime) are spread across the physical RAM such that other allo-
cation types are fragmented — one of the most important goals of the page mobility grouping
framework.

The VirtualMovableZone


Grouping pages by mobility order is one possible method to prevent fragmentation of physical
memory, but the kernel additionally provides another means to fight this problem: the virtual
zoneZONE_MOVABLE. The mechanism has even found its way into the kernel during the devel-
opment of kernel 2.6.23, one release before the mobility grouping framework was merged. In
contrast to mobility grouping, theZONE_MOVABLEfeature must be explicitly activated by the
administrator.

The basic idea is simple: The available physical memory is partitioned into one zone used for movable
allocations, and one zone used for non-movable allocations. This will automatically prevent any non-
movable pages from introducing fragmentation into the movable zone.

This immediately raises the question of how the kernel is supposed to decide how the available memory
will be distributed between the two competitors. Clearly, this asks too much of the poor kernel, so the
system administrator has to make the decision. After all, a human can predict much better which sce-
narios the machine will handle and what the expecteddistribution of allocations into the various types
will be.

Data Structures


Thekernelcoreparameter allows for specifying the amount of memory used for non-movable allo-
cations, that is, for allocations that can neither be reclaimed nor migrated. The remaining memory is
used for movable allocations. After parsing the parameter, the result is stored in the global variable
required_kernelcore.

It is also possible to use the parametermovablecoreto control the amount of memory that is used for
movablememory.Thesizeofrequired_kernelcorewill be computed accordingly. If wise guys specify
both parameters simultaneously, the kernel computesrequired_kernelcoreas before, and takes the
larger one of the computed and specified value.

Depending on the architecture and the kernel configuration, the new zoneZONE_MOVABLEis located above
the high-memory or regular-memory zone:

<mmzone.h>
enum zone_type {
...
ZONE_NORMAL
#ifdef CONFIG_HIGHMEM
ZONE_HIGHMEM,
Free download pdf