← Interview Prep

Linux Kernel — The Page Cache

Caching file data in RAM: the address_space/xarray index, reads & readahead, buffered writes → dirty pages → writeback (dirty_ratio, flusher threads, fsync durability), unified buffer cache, Direct I/O (O_DIRECT) and mmap, fadvise/drop_caches, and clean-vs-dirty under reclaim.

Why reading the same file twice is nearly free, and why a "used" machine shows little free memory — the page cache keeps file data in RAM. How it's indexed, how reads and writes flow through it, and when you bypass it. Original, interview-focused notes.

The page cache holds file contents in page frames, indexed by (inode/address_space, offset). Reads are served from it (a hit avoids disk); writes land in it as dirty pages and are flushed to disk later. It's why Linux "uses all your RAM" — that memory is reclaimable cache, not waste.

What it is & how it's indexed

Reads & readahead

Writes, dirty pages & writeback

Bypassing & managing it

Under memory pressure, clean cache pages are the first thing reclaimed (no writeback needed); dirty pages must be written first. See Page Frame Reclaiming.

Likely interview questions

Kernel Internals series. Related: Process Address Space · Page Frame Reclaiming.