Fundamentals 8 min read

Understanding Linux Kernel Memory Management: Architecture, Address Spaces, and Allocation Strategies

This article provides a comprehensive overview of the Linux kernel memory management subsystem, covering its hardware architecture, address‑space layout, various memory zones, and the software structures for page and object allocation and reclamation.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Understanding Linux Kernel Memory Management: Architecture, Address Spaces, and Allocation Strategies

Memory Management Hardware Architecture

Modern processors implement a multi‑level cache hierarchy and a Translation Lookaside Buffer (TLB) to accelerate memory accesses. L1 cache can be indexed directly by virtual addresses, eliminating the need for immediate address translation. If L1 misses, the CPU uses the TLB to quickly translate virtual to physical addresses, avoiding costly page‑table walks. After obtaining a physical address, the L2 cache is consulted, offering a larger capacity and higher hit rate before accessing main memory.

Memory Mapping Address‑Space Division

The kernel partitions the virtual address space into distinct zones to accommodate different hardware constraints and usage scenarios. Typical zones on a 32‑bit system include:

DMA zone : Reserved for devices with limited addressing capability (e.g., early ISA devices limited to the first 16 MiB). Allocated via kmalloc with the GFP_ATOMIC flag.

Normal zone : The primary area for general kernel allocations, also obtained through kmalloc.

Highmem zone : Holds memory that cannot be directly mapped due to the 3 GiB/1 GiB split of kernel virtual address space on 32‑bit CPUs.

On 64‑bit architectures the highmem zone is usually unnecessary, and the address‑space layout differs, as illustrated by the X86_64 kernel map.

Memory Management Software Architecture

The kernel’s memory manager consists of two interrelated subsystems:

Page management : A two‑level hierarchy (cold/hot caches and the buddy allocator) responsible for allocating and reclaiming whole pages.

Object management : A three‑level hierarchy (per‑CPU caches, slab allocator, and the buddy system) that handles sub‑page objects. Allocation proceeds from per‑CPU caches to slabs and finally to the buddy system; deallocation follows the reverse order.

Additional mapping mechanisms address special needs:

vmalloc / vmap : Provide virtually contiguous memory regions backed by non‑contiguous physical pages.

ioremap : Map specific physical I/O regions into the kernel’s virtual address space.

Persistent mappings (kmap) : Keep mappings across context switches without TLB flushes, useful for high‑performance drivers.

Fixed mappings (kmap_atomic) : Non‑sleeping mappings suitable for interrupt or spin‑lock contexts.

Despite architectural differences across CPU families, the kernel presents a uniform API for zone allocation, ensuring portability of drivers and subsystems.

Linuxhardware architectureaddress space
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.