Memory Management
Virtual memory, page allocator, slab/slub, NUMA topology, huge pages, and OOM killer — the mm subsystem dissected.
Subsystem Overview
The Linux memory management subsystem is responsible for the entire lifecycle of physical and virtual memory: allocation, mapping, reclaim, and release. It abstracts hardware MMU differences behind a unified virtual address space model, implements demand paging, and enforces memory isolation between processes.
At its core, mm/ manages a hierarchy of allocators — from the raw page allocator (buddy system) at the bottom, through the slab/slub object caches in the middle, up to the vmalloc and kmalloc interfaces used by the rest of the kernel. Each layer trades granularity for speed.
In Linux 7.2, the mm subsystem introduced per-node compaction throttling, improved folio-based page cache operations, and extended the memory-tiering framework for CXL-attached memory.
Diagrams
// interactive · hover to explore
Virtual Memory Layout
Full x86-64 address space: user regions, kernel direct map, vmalloc, and text.
Buddy Allocator Free Lists
Per-order free lists showing how 2^N page blocks are tracked and coalesced.
Page Fault Handler Flow
From CPU #PF exception through do_page_fault() to COW, swap-in, or SIGSEGV.
Key Concepts
struct page
The fundamental unit of physical memory tracking. Each physical page frame has a corresponding struct page in the mem_map array. In 7.2, folios (compound pages) are the preferred abstraction for multi-page allocations.
VMA (vm_area_struct)
Describes a contiguous virtual address range within a process address space. VMAs are stored in an interval tree (maple tree in 7.2) for O(log n) lookup. Each VMA carries vm_flags, a backing vm_file, and vm_ops function pointers.
Page Tables
Multi-level hardware page tables (PGD → P4D → PUD → PMD → PTE on x86-64) map virtual to physical addresses. The kernel maintains per-process page tables and a shared kernel page table region above PAGE_OFFSET.
Buddy Allocator
The physical page allocator. Maintains free lists of 2^order contiguous pages (order 0–10). Allocation splits higher-order blocks; freeing coalesces buddies. Fragmentation is managed by compaction and memory defragmentation.
SLAB/SLUB/SLOB
Object-level allocators built on top of the buddy system. SLUB (the default since 2.6.23) groups same-size objects into slabs, minimising internal fragmentation and improving cache locality via per-CPU partial lists.
OOM Killer
When the system cannot satisfy an allocation after reclaim, the OOM killer selects a victim process using an oom_score heuristic (RSS + swap + child RSS, adjusted by oom_score_adj) and sends SIGKILL.
Linux 7.2 Changes
// recent mm/ commits