4.1.15 · D3Computer Architecture (Deep)

Worked examples — TLB — structure, TLB miss handling

3,880 words18 min readBack to topic

Symbols & vocabulary used on this page

Everything below is used before you meet it in an example — so it lives here, defined in plain words, so you never hit an unexplained symbol.


The scenario matrix

Before working problems, let us map the entire space of situations. Each row is a class of question; each example below fills one or more cells.

# Cell (scenario class) What is tricky about it Covered by
A Plain address split (VA → VPN + offset) getting bit-counts right Ex 1
B Form the physical address on a HIT shift-and-OR, hex arithmetic Ex 2
C Degenerate: offset = 0 / access at page boundary the byte that sits exactly at a page start Ex 3
D TLB MISS but PTE valid (walk, then hit) counting memory accesses Ex 4
E MISS that becomes a PAGE FAULT (PTE invalid) ns vs ms; who does what Ex 5
F EMAT numeric (given h, t, k) plugging the boxed formula Ex 6
G Limiting behaviour (, ) forecast before computing Ex 6
H Context switch / ASID (same VA, two processes) why entries don't collide Ex 7
I Huge page / TLB reach (real-world word problem) reach = entries × page size Ex 8
J Exam twist: reverse-engineer (given PA & VA, find page size) working backwards Ex 9
K Set-associative TLB indexing (which set?) index bits vs tag bits Ex 10

We will now hit every cell.


Example 1 — Plain address split (Cell A)


Example 2 — Form the physical address on a HIT (Cell B)

Figure — Ex 2 (shift-and-OR): the cyan boxes are the page-number fields (VPN on top, PFN on the bottom — these get swapped); the amber box is the offset. Follow the amber arrow down the right edge: the offset 0xEEF drops straight through untranslated, while the top field changes from DEADB to the frame 01234.

Figure — TLB — structure, TLB miss handling

Example 3 — Degenerate: byte at a page boundary (Cell C)


Example 4 — TLB MISS, PTE valid, then hit (Cell D)


Example 5 — MISS becomes a PAGE FAULT (Cell E)


Example 6 — EMAT numeric and limiting behaviour (Cells F & G)

Figure — Ex 6 (EMAT vs hit ratio): the cyan curve is EMAT as sweeps from 0 to 1. Watch the three amber dots: the right end () sits at the 101 ns floor, the left end () at the 501 ns ceiling, and our worked point sits just above the floor at 121 ns.

Figure — TLB — structure, TLB miss handling

Example 7 — Context switch & ASID (Cell H)


Example 8 — Huge pages & TLB reach (Cell I, word problem)


Example 9 — Exam twist: reverse-engineer the page size (Cell J)


Example 10 — Set-associative TLB indexing (Cell K)


Recall Quick self-test — cover the answers

What does VPN stand for, and which part of the address is it? ::: Virtual Page Number — the high bits naming which page What does PFN stand for? ::: Physical Frame Number — the high bits naming which frame in RAM A plain TLB miss with a 4-level walk costs how many DRAM accesses (incl. data)? ::: 5 (4 walk + 1 data) Same VA in two processes stays correct in the TLB because of what field? ::: ASID/PCID tag Reach of a 64-entry TLB with 2 MB pages? ::: 128 MB As with , EMAT tends to? ::: 101 ns Byte 0x6FFF and 0x7000 (4 KB pages) share a page? ::: No — different VPNs (0x6 vs 0x7) A 256-set TLB, page 4 KB, VA 0x9ABCD000 probes which set? ::: Set 205 (0xCD), tag 0x9AB