The problem
On a 32-bit machine with 4 KiB pages, a flat page table needs one 4-byte entry for each of about a million pages: 4 MiB for every process. Most programs use only a few pages, so nearly all those entries are empty.
Cut the flat table into page-sized pieces of 1024 entries. A piece with no used pages is simply never built. A small page directory, itself one page, lists where each built piece lives, or marks it not present.
Walking the tree
The program reads address 0x00C05123. The memory unit splits its 32 bits into three fields: the top 10 bits pick a directory entry (3), the next 10 pick a table entry (5), and the low 12 are the offset inside the page (0x123).
Every walk starts at a CPU register. On x86 it is CR3, which holds where this process's page directory is: frame 0x50. The kernel loads CR3 on each context switch, so each process walks its own tree.
The memory unit reads directory entry 3. It is present and holds a frame number, 0x52: the page of the page table that covers this 4 MiB slice of memory. That is the first read from memory.
Next it reads entry 5 of that page table. This entry is present too, and gives the frame where the page really lives: 0x2A7. That is the second read from memory.
The offset is never translated. Joining frame 0x2A7 with offset 0x123 gives the physical address 0x2A7123. Now the real read happens, and the program gets its byte: 42.
Gaps and trade-offs
Now the program touches 0x00400000. Its top bits pick directory entry 1, which is not present: no page table was ever built there. The walk stops and the CPU raises a page fault, so the kernel decides what happens.
This process uses three slices: code, data and stack. So it needs the directory plus three page tables: 16 KiB, instead of 4 MiB for the flat table. That is 256 times less. A program using more memory gets more tables.
Each level is one more memory read. Without help, every load costs three reads instead of two with a flat table. The TLB (see Managing the TLB) keeps recent translations, so most accesses skip the walk; only a TLB miss pays for it.
With 64-bit addresses one directory would be far too big, so the same trick repeats. x86-64 walks four levels, 9 bits each, on 48-bit addresses; newer chips can use five. Linux names its levels PGD, P4D, PUD, PMD and PTE.
What happens
;; step 1/11 · one-table
address space 2^32 bytes = 4 GiB
page size 2^12 bytes = 4 KiB
pages 2^32 / 2^12 = 2^20 = 1,048,576
entry size 4 bytes
flat table 2^20 x 4 = 4,194,304 bytes = 4 MiB
one per process, and it must sit in one piece
The frame numbers (0x50, 0x51, 0x52, 0x53, 0x2A7) and the byte 42 are example data: a real kernel picks whichever frames are free. The sizes and the 10 | 10 | 12 split are those of classic 32-bit x86 paging. A real entry holds more than a frame number: the low bits carry flags such as present, writable and user-allowed. The figure shows only the frame number, and a dash for an entry that is not present.