Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


The buddy system is centered around the idea of splitting and recombining larger continuous blocks of
pages. When a continuous area becomes free, the kernel notices this automatically, and can use it once the
need for a corresponding allocation arises. Since this is unfortunately not sufficient to prevent fragmen-
tation of physical memory after longer uptimes in a satisfactory manner, recent kernels have acquired
anti-fragmentation techniques that allow grouping pages by their mobility, on the one hand, and aug-
ment the kernel with a new virtual memory zone, on the other hand. Both help to avoid fragmentation
by essentially decreasing the chance that coalescing of larger regions is prohibited by allocated blocks in
their middle.

The slab allocator is implemented on top of the buddy system. It does not only allow to allocate small
chunks of memory for arbitrary use, but additionally offers the possibility to create specific caches for
often used data structures.

Initializing memory management is challenging because the data structures employed by the subsystem
itself also require memory, which must be allocated from somewhere. We have seen how the kernel
solves the situation by introducing a very simple boot memory allocator that is shut down after the
proper allocation routines function fully.

While we have mostly focused on physical memory here, the next chapter will discuss how the virtual
address space is managed by the kernel.
Free download pdf