PGDPUDPMDPTE2 MiBNODE 0 MEMORYTLB REACH256 KiBCPU 02 MiBNODE 1 MEMORYCPU 11madvise(p, SZ, MADV_HUGEPAGE);2memset(p, 1, SZ);3n = sum(p, SZ);VAVArdrd2 MiB2 MiB
Back: the page table levels PGD, PUD, PMD, PTEBoard: two NUMA nodes (CPU + memory), a socket link, CPU 0's TLBTokens: page-table walks, the 2 MiB page, reads across the linkAt the back, the four levels of the x86-64 page table. In the middle, a two-socket board: each socket is a NUMA node with its CPU and its own memory, joined by a link; CPU 0 has a TLB. In front, the program. Filling 2 MiB on 4 KiB pages takes 512 pages, and each TLB miss walks all four levels. One huge page needs one TLB entry and a walk that stops at the PMD. First touch puts the page in node 0; a worker on node 1 reads it over the link until it migrates. The figure draws fewer small tiles than the 512 real pages, so they stay readable.

Huge pages

  1. Every memory access uses a virtual address that must be translated to a physical one. The CPU keeps recent translations in a small cache, the TLB. A typical TLB holds 32, 64 or 128 entries, and each entry covers one page.

NUMA placement

What happens

;; step 1/10 · tlb
virtual address -> TLB -> physical address

page size   4 KiB (ordinary x86-64 page)
TLB         64 entries (OSTEP: typically 32, 64 or 128)
reach       64 x 4 KiB = 256 KiB

reach (or coverage): how much memory the TLB can
translate without a miss

Sizes are for x86-64 Linux: 4 KiB pages, 2 MiB huge pages at the PMD level and 1 GiB pages at the PUD level. RISC-V has the same 4 KiB and 2 MiB sizes. Linux can also use five-level page tables; the lesson shows the usual four. The figure draws fewer small tiles than the 512 real pages, so they stay readable.