Fundamentals 12 min read

How Linux Translates Virtual Addresses into Physical Memory

This article explains Linux's memory management, detailing how physical memory is organized into pages, zones, and nodes, how virtual addresses are structured for user and kernel space, and how page tables, the buddy system, SLUB, and TLB work together to map virtual addresses to physical memory.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How Linux Translates Virtual Addresses into Physical Memory

Memory Management Overview

Memory management organizes physical memory and handles its allocation and reclamation, while Linux introduces the concept of virtual addresses.

Purpose of Virtual Addresses

Allowing user processes to operate directly on physical addresses would let them corrupt kernel memory, interfere with other processes, and break system stability. CPU registers hold logical (virtual) addresses that must be mapped to physical addresses before memory can be accessed.

Physical Memory Organization

Linux divides memory into three levels:

Page : The basic unit, typically 4 KB.

Zone : Groups pages into multiple queues. There are three zones:

ZONE_DMA – for DMA‑read I/O device data, kernel‑only.

ZONE_NORMAL – for kernel data, kernel‑only.

ZONE_HIGHMEM – for user‑process data.

Node : Each CPU has a corresponding node containing one of each zone. If a CPU’s memory is exhausted, memory from another CPU’s node can be allocated.

Physical Memory Allocation

Large allocations use the buddy system, which groups pages into linked lists of blocks sized 1, 2, 4, 8 … up to 1024 pages. When a request for a block of size 2ⁱ pages arrives, the system looks for a free block of that size; if none exists, it splits a larger block.

Small allocations use SLUB, which extracts a few pages as caches and maintains them in linked lists. Memory is taken from or returned to these lists without zeroing.

Organizing Virtual Addresses

Virtual addresses form a virtual space that maps to physical memory. The virtual space is divided into user space and kernel space.

In 32‑bit systems, the virtual space is split 1:3 between kernel and user; in 64‑bit systems, each gets 128 TB.

Each user process has its own virtual address layout, containing:

Text (code)

Data

BSS (global variables)

Heap

Stack

mmap region for dynamic mappings

The kernel shares a single virtual space, consisting of:

Direct mapping area (e.g., 896 MB) that maps kernel space directly to ZONE_DMA and ZONE_NORMAL.

Dynamic mapping area, which can map any physical address in ZONE_HIGHMEM as needed.

Mapping Virtual to Physical Addresses

Virtual addresses are translated to physical addresses via page tables. Both virtual space and physical memory are paged in 4 KB units, establishing a one‑to‑one correspondence between virtual pages and physical pages.

Each process has its own page table; the kernel has a single page table.

The virtual address is divided into three fields:

10 bits – index into the first level of page‑table entries.

10 bits – index into the second level (page‑table record).

12 bits – offset within the 4 KB page.

This scheme reduces the need for contiguous memory by storing page‑table records in separate pages.

TLB (Translation Lookaside Buffer)

The TLB is a CPU cache that stores recent virtual‑to‑physical address translations. A lookup first checks the TLB; on a miss, the page table is consulted.

Virtual Memory (Swap)

Virtual memory uses a swap partition on disk as an extension of RAM, holding pages that are not currently needed. When a page is accessed, it is swapped back into physical memory.

Summary

Both kernel and user spaces have distinct virtual address spaces that map to physical memory via page tables. User space can only map to user‑accessible physical memory, while kernel space handles both kernel and user mappings. Memory allocation relies on the buddy system for large blocks and SLUB for small objects, and the TLB accelerates address translation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Memory ManagementlinuxVirtual Memorypage-tablesOS fundamentals
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.