Skip to content
Understanding Linux’s Three‑Tier Physical Memory and Virtual Page Table Architecture
Fundamentals 6 min read

Understanding Linux’s Three‑Tier Physical Memory and Virtual Page Table Architecture

This article explains Linux’s hardware‑independent three‑tier physical memory model (node, zone, page) and the three‑level virtual memory page‑table hierarchy (PGD, PMD, PTE), including key macros, structure definitions, and the macros used to walk the tables from a virtual address to a physical page.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations

1. Linux Physical Memory Three‑Tier Architecture

Linux uses a hardware‑independent memory model composed of memory nodes, zones, and pages, providing scalability across UMA and NUMA systems.

Memory Node (node)

A memory node groups physical memory that can be accessed with uniform cost; accessing memory in different nodes incurs higher latency. Linux represents nodes with the pg_data_t structure.

Memory Zone (zone)

Zones reside within a node and serve different purposes; for example, on IA‑32 machines the first 16 MiB is reserved for ISA DMA.

Physical Page (page)

Pages are the basic unit of allocation, tracked by the kernel.

2. Linux Virtual Memory Three‑Level Page Tables

The virtual memory subsystem uses three levels: PGD (Page Global Directory), PMD (Page Middle Directory), and PTE (Page Table Entry).

Key Macros per Level

SHIFT

SIZE

MASK

Structure Definitions

PGD and PMD are defined in <asm/page.h> (e.g., for ARM) and stored in each process’s pgd_t array referenced via task_struct->mm_struct->pgd.

PTEs, PMDs, and PGDs are described by pte_t, pmd_t, and pgd_t. Protection bits are stored in pgprot_t, often in the low bits of the entry.

Accessing Physical Memory via the Three‑Level Page Table

Macros in asm/pgtable.h translate a virtual address to a physical page: pgd_offset(mm, address) – obtain the PGD entry. pmd_offset(pgd, address) – obtain the PMD entry. pte_offset(pmd, address) – obtain the PTE entry, which points to the aligned physical page.

Example code for walking the page tables can be found in mm/memory.c (function follow_page).

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-tablesoperating system fundamentals
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.