Skip to content

Kernel Memory API Reference

This section collects the Linux kernel memory management APIs used throughout the labs.

It covers memory allocation, virtual memory mapping, MMIO mapping, memory ordering, and DMA mapping APIs commonly used by Linux kernel drivers.

Linux kernel memory management includes both dynamic memory allocation and Memory-Mapped I/O (MMIO). This reference explains the programming interfaces as well as the underlying allocator and mapping implementations.

References

Reference Purpose
Kernel Memory Allocation Overview of kernel dynamic memory allocation APIs, including kmalloc(), kzalloc(), kcalloc(), and kfree().
Page Allocator Understand the Buddy Allocator, page allocation, struct page, allocation order, page split, and page merge.
SLUB Allocator Understand kmem_cache, slabs, bitmap management, object allocation, object reuse, and integration with the Buddy Allocator.
vmalloc() Understand virtually contiguous memory mappings, including vmalloc(), vmap(), vzalloc(), vfree(), and vmalloc_to_page().
ioremap() Map MMIO physical addresses into the kernel virtual address space and release mappings with iounmap().
MMIO Access APIs Linux MMIO register access APIs, including readb(), readw(), readl(), writeb(), writew(), and writel().
Memory Barrier APIs Linux compiler, CPU, SMP, Release, and Acquire ordering APIs, including barrier(), mb(), rmb(), wmb(), smp_mb(), smp_store_release(), and smp_load_acquire().
Linux DMA Mapping APIs Allocate coherent DMA buffers, map streaming DMA buffers, synchronize CPU and device access, and validate DMA mappings.

Relationships

Kernel Memory Management
      Page Allocator (Buddy)
        │              │
        │              ▼
        │         Virtual Mapping
        │              │
        │     ┌────────┴────────┐
        │     ▼                 ▼
        │  vmalloc()       ioremap()
        │                        │
        │                        ▼
        │                 MMIO Access APIs
        │                        │
        │                        ▼
        │                 Memory Barriers
 SLUB Allocator
     kmalloc()