← Interview Prep

Linux Kernel — Memory Addressing

How x86-64 turns a virtual address into physical RAM: segmentation (flat model) vs paging, the 4-level page-table walk & PTE flags, per-process page tables & isolation, the TLB (flushes, shootdowns, huge pages), the user/kernel address-space split & KPTI, and NUMA nodes/zones.

How the CPU turns an address in your program into a physical byte in RAM — the foundation everything else (paging, process isolation, the page cache) builds on. This is an original, interview-focused tour of x86-64 memory addressing as Linux uses it.

Three address spaces: a logical/virtual address (what your code sees) → the MMU walks page tables → a physical address in RAM. The TLB caches recent translations so this isn't done from scratch every access.

Segmentation vs paging

Paging & the page-table walk

On x86-64, a 48-bit virtual address is translated through a 4-level page table (5 levels with LA57). Each level indexes a table; the final entry (PTE) gives the physical frame + flags:

virtual addr → PGD → PUD → PMD → PTE → physical frame + offset
   (Linux names: pgd → p4d → pud → pmd → pte)
PTE flags: Present, R/W, User/Supervisor, Accessed, Dirty, NX (no-execute), Global

The TLB

Walking 4 levels per access would be ruinous, so the MMU caches translations in the TLB. A hit is ~1 cycle; a miss triggers the walk. Consequences you should know:

The address-space split

Regionx86-64
User spaceLower canonical half (per-process, isolated)
Kernel spaceUpper canonical half — includes a direct map of all physical RAM (fast phys↔virt), vmalloc area, etc.

Every process shares the same kernel mapping (so a syscall doesn't switch page tables), but user mappings are private. KPTI (Meltdown mitigation) partly breaks that sharing by unmapping most of the kernel while in user mode.

Physical memory: nodes & zones

Likely interview questions

Kernel Internals series. Related: Processes · SRE Linux Q&A.