Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 18: Page Reclaim and Swapping


Objects are freed in chunks of 128 to ensure that the system is not blocked for too long. Between each
invocation of the shrinker function,cond_reschedgives the kernel the opportunity to perform scheduling
so that latency does not become too high during cache shrinking.

18.11 Summary


One of the fundamental design decisions of the Linux kernel is that caches are usually never fixed in size,
but can grow dynamically until all available RAM is used. You have seen in this chapter that filling RAM
with information is a good thing because unused memory is a wasted resource, but that the kernel needs
to use a mechanism that allows for shrinking caches if memory is required for more urgent tasks. You
have been introduced to the mechanisms employed to judge whether pages are actively used or not. This
allows for evicting rarely used pages from memory, and depending on how the pages are used, they can
be discarded, synchronized, or swapped out. The lastpoint implements the inverse of caching: A block
device can be used to extend the effectively available amount of memory at the cost of access speed.

The kernel uses two mechanisms to reclaim memory: A periodic daemon consistently monitors memory
usage and tries to keep the most active pages in RAM, but there are also routines that handle acute
memory pressure.

While page reclaim and swapping work on page-sizedobjects, the kernel also provides mechanisms to
shrink caches with smaller objects, and you have been introduced to the corresponding routines at the
end of this chapter.
Free download pdf