Free — no signup required

Paging and Page Tables: The Map

2 min read

Breaking It Down into Chunks

How does the kernel manage this mapping without slowing everything to a crawl? It doesn't map every single byte individually — that would require a lookup table larger than RAM itself.

Instead, Linux divides both virtual memory and physical RAM into fixed-size chunks called Pages. On most x86-64 systems, a page is 4KB (4,096 bytes). Physical RAM is divided into equivalently sized chunks called page frames.

The Page Table
For every running process, the kernel maintains a Page Table — a data structure that acts as the translation dictionary between virtual and physical addresses.

  • Key: The virtual page number the process is trying to access.
  • Value: The physical page frame number where that data actually lives in RAM, plus metadata flags (is this page readable? writable? executable? currently in RAM?).

When a process tries to access memory address 0x12345, the CPU's MMU intercepts the request, consults the process's page table, finds the real physical address, and fetches the data — all in nanoseconds.

The Translation Lookaside Buffer (TLB)
Page table lookups happen on every single memory access. To avoid the cost of walking the page table each time, the CPU caches recent translations in a small, extremely fast hardware cache called the Translation Lookaside Buffer (TLB). A TLB hit means the translation is served from cache. A TLB miss means the CPU must walk the page table in RAM — significantly slower.

This is why huge pages (2MB or 1GB pages instead of 4KB) matter for performance-sensitive workloads like databases: fewer, larger pages mean fewer TLB entries are needed to cover the same amount of memory, resulting in dramatically fewer TLB misses.

Multi-level Page Tables
A flat page table for a 64-bit address space would be enormous. Linux uses a 4-level page table hierarchy (PGD → PUD → PMD → PTE) to represent sparse address spaces efficiently. Most of a process's 128TB virtual address space is empty — the multi-level structure means you only allocate page table memory for the parts actually in use.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free