Skip to content

Kernel Memory

This section organizes the Linux kernel memory management topics into reusable reference pages.

The topics focus on how the Linux kernel manages physical pages, kernel object allocation, dynamic memory allocation, virtually contiguous mappings, Memory-Mapped I/O (MMIO), DMA memory mapping, and memory ordering.

Together they explain the allocation, mapping, access, synchronization, and ordering paths behind kmalloc(), vmalloc(), vmap(), ioremap(), MMIO access APIs, Linux DMA Mapping APIs, and Linux memory barriers.

Learning Path

Step Topic Main Idea Related Labs
1 Kernel Memory Management Understand physical memory pages, struct page, the Buddy Allocator, allocation order, fragmentation, and the relationship between Buddy and SLUB. Day90
2 Kernel Memory Allocation Understand the kernel dynamic allocation APIs (kmalloc(), kzalloc(), kcalloc(), kfree()) and how they are implemented through size-class caches. Day89, Day92
3 SLUB Allocator Understand kmem_cache, slabs, object allocation, bitmap management, object reuse, and integration with the Buddy Allocator. Day91
4 vmalloc() and vmap() Understand how virtually contiguous mappings are built from individual physical pages and how page ownership differs between vmalloc() and vmap(). Day93, Day94
5 ioremap() and MMIO Understand how physical MMIO regions are mapped into the kernel virtual address space and how drivers access hardware registers through virtual mappings. Day95
6 MMIO Access APIs Understand Linux MMIO read/write APIs, register access, Little Endian layout, and register offsets Day96
7 Memory Barriers Understand compiler and CPU reordering, Linux memory barrier APIs, Release/Acquire semantics, MMIO ordering, and DMA descriptor publication. Day97
8 Linux DMA Mapping Understand DMA mapping, streaming DMA, coherent DMA, DMA directions, ownership transfer, and cache coherency. Day98

Learning Flow

Kernel Memory Management
      Physical Pages
     Page Allocator (Buddy)
        │            │
        │            ├───────────────┐
        ▼            ▼               ▼
 SLUB Allocator   vmalloc()        vmap()
        │             │               │
        ▼             └───────┬───────┘
     kmalloc()                ▼
                    Virtual Mapping Manager
                ┌─────────────┴─────────────┐
                ▼                           ▼
       Memory Mapping                MMIO Mapping
    (`vmalloc()`/`vmap()`)          (`ioremap()`)
                                  MMIO Access APIs
                                   Memory Barriers
                                   Linux DMA Mapping