Kernel Memory Allocation for Module Authors – Part 1
In the previous two chapters, one on the kernel’s internal aspects and architecture and the other on the essentials of memory management internals, we covered key aspects that serve to provide the required background information for this and the following chapter. In this and the next chapter, we will get down to the actual allocation and freeing of kernel memory by various means. We will demonstrate this via kernel modules that you can test and tweak, elaborate on the whys and hows of allocation, and provide many real-world tips and tricks to enable a kernel or driver developer like you to gain maximum efficiency when working with memory within your kernel module.
In this chapter, we will cover the kernel’s two primary memory allocators – the Page Allocator (PA) (aka the Buddy System Allocator (BSA)) and the slab allocator. We will delve into the nitty-gritty of working with their APIs within kernel...