Lorenzo Stoakes

The Linux Memory Manager

I am writing a book about the Linux memory management subsystem which I anticipate will be ready around mid-2024. I provide periodic updates in my development diary and more frequent ones on Mastodon or Twitter.


Please register your interest in the book to receive an email as soon as it is released (and optionally infrequent updates on progress).


Progress

300 pages

Confirmed Chapters

  1. Allocators - Describe in detail how dynamic memory allocation works, the trade-offs, the algorithms - essentially the what, why and how of memory allocation. [INCOMPLETE]

  2. Physical memory - The buddy allocator, struct page*, struct folio*, the kernel functions that provide memory (e.g. alloc_pages()), nodes, zones (in brief, more detailed in NUMA chapter), watermarks, migrate types, page blocks, GFP flags, migrate types, detailed analysis of physical page allocation and freeing. [ROUGH DRAFT COMPLETE]

  3. Virtual memory - The why, what and how, page tables, page table flags, page table sizes, virtual memory layout, direct mapping, kernel/userland split. vmalloc(), kernel process address space. [ROUGH DRAFT COMPLETE]

  4. Process memory - mm_struct, Process VMAs, page faults, demand paging, dynamic stack allocation, how memory is copied between userland/kernel, how malloc() actually feeds into the kernel (e.g. sbrk(), mmap()). Copy-on-write, forking, basics of huge pages (covered in more detail in huge pages chapter), rmaps, pagevecs, lru + lruvecs. GUP.[CURRENTLY WORKING ON]


Proposed Chapters