Allocation, reclaim and writeback
Quick answer
The kernel manages physical pages and smaller kernel objects. Reclaim makes memory available again; writeback transfers dirty cached data toward backing storage.
Clean cached pages can often be reclaimed without writing them back; dirty pages need appropriate persistence handling before reuse. Observe reclaim and writeback alongside workload latency rather than assuming that a large cache is a memory leak.
Prepare the practice environment
Run python3 lab-fixtures/kernel/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not write kernel attributes, load modules, or change boot settings. Supplied records are fictional; read only the selected non-sensitive live fields. Review the lab guide.
Prerequisites
Review: Virtual memory and page faults.
How it works
The page allocator manages physical pages; slab allocators cache allocations for kernel objects. File-backed page cache speeds access. Clean file pages can often be reclaimed and reread, while dirty file pages generally require writeback before reuse. Anonymous pages may need swap or another valid reclaim mechanism; pinned and unreclaimable memory are different. Background reclaim and direct reclaim can affect latency. Dirty and Writeback in meminfo describe different states, not a guarantee that data is durable. Buffered write success is not fsync success; application durability also depends on filesystem and device semantics. MemAvailable is an estimate, not a count of unused bytes. Inspect trends and pressure rather than clearing caches.
Try the examples
awk '/^(MemAvailable|Dirty|Writeback):/ {print $1, $2, $3}' meminfo.sampleThis is a synthetic snapshot in KiB as represented by Linux meminfo kB units.
Expected stdout:
MemAvailable: 512000 kBDirty: 12000 kBWriteback: 4000 kBThe teaching model omits references, pinning and policy details.
Expected stdout:
clean file: reclaim candidatedirty file: writeback neededanonymous: backing requiredfree -k | grep -q available && printf 'available column present\n'This confirms the installed free output has the field, not system memory pressure.
Expected stdout:
available column presentCommon mistakes
Never clear caches or change VM sysctls as a generic fix. Dirty data and writeback are not evidence of durable storage.
Practice
Compare the synthetic counters and describe why clean and dirty pages have different reclaim costs.
Related references
Study: free. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Allocation, reclaim and writeback — Knowledge Check
Apply kernel concepts to read-only observations and synthetic models.
Which often needs writeback before reclamation?
What is MemAvailable?
Does buffered write success guarantee durability?
What do slab allocators serve?