Memory management is one of the most complex and at the same time most important parts of the kernel. It is characterized by the strong need for cooperation between the processor and the kernel because the tasks to be performed require them to collaborate very closely. Chapter 1 provided a brief overview of the various techniques and abstractions used by the kernel in the implementation of memory management. This chapter examines the technical aspects of implementation in detail.
Memory management implementation covers many areas:
Management of physical pages in memory.
The buddy system to allocate memory in large chunks.
The slab, slub, and slob allocators to allocate smaller chunks of memory.
vmalloc mechanism to allocate non-contiguous blocks of memory.
The address space of processes.
As we know, the virtual address space of the processor is in general divided into two parts by the Linux kernel. The lower and larger part is available to user processes, and the upper part is reserved for the kernel. Whereas the lower part is modified during a context switch (between two user processes), the kernel part of virtual address space always remains the same. On IA-32 systems, the address space is typically divided between user processes and the kernel in a ratio of 3:1; given a virtual address space of 4 GiB, 3 GiB would be available to userspace and 1 GiB for the kernel. This ratio can be changed by modifying the relevant configuration options. However, ...