System information

Tuning the Memory Management Subsystem 179
Tuning the Memory
Management Subsystem
15
In order to understand and tune the memory management behavior of the kernel, it is
important to first have an overview of how it works and cooperates with other subsys-
tems.
The memory management subsystem, also called the virtual memory manager, will
subsequently be referred to as “VM”. The role of the VM is to manage the allocation
of physical memory (RAM) for the entire kernel and user programs. It is also respon-
sible for providing a virtual memory environment for user processes (managed via
POSIX APIs with Linux extensions). Finally, the VM is responsible for freeing up
RAM when there is a shortage, either by trimming caches or swapping out “anony-
mous” memory.
The most important thing to understand when examining and tuning VM is how its
caches are managed. The basic goal of the VM's caches is to minimize the cost of I/O
as generated by swapping and file system operations (including network file systems).
This is achieved by avoiding I/O completely, or by submitting I/O in better patterns.
Free memory will be used and filled up by these caches as required. The more mem-
ory is available for caches and anonymous memory, the more effectively caches and
swapping will operate. However, if a memory shortage is encountered, caches will be
trimmed or memory will be swapped out.
For a particular workload, the first thing that can be done to improve performance
is to increase memory and reduce the frequency that memory must be trimmed or
swapped. The second thing is to change the way caches are managed by changing ker-
nel parameters.