A deep dive into how Linux manages process memory on x86-64. Covers virtual memory areas (VMAs), page tables, and the lazy allocation model where pages are only created on first touch. Explains mmap semantics (anonymous vs file mappings, MAP_PRIVATE vs MAP_SHARED, MAP_FIXED pitfalls), copy-on-write behavior with fork(), mprotect and TLB invalidation costs, transparent huge pages (THP and mTHP), and how to inspect memory via /proc/maps, smaps, and pagemap. Also covers Page Table Isolation (PTI) as the Meltdown mitigation, dirty-tracking with PAGEMAP_SCAN and userfaultfd, and a practical troubleshooting checklist for common memory errors like SIGBUS, ENOMEM, and CoW RSS growth.
Table of contents
IntroThe floor plan you never seeA quick glance at your own housemmap , without the fogThe first touchCopy on write with fork() and MAP_PRIVATEChanging rights, and the little pause you feelSeeing what’s really mappedWhen your page suddenly gets biggerDirty‑tracking in userspace, without racing the kernelThe TLB, and why mprotect costs a littleMeltdown, and why the kernel sometimes switches maps on entryHow the kernel changes mappings safelyA tiny x86 aside: stacks and calls, without the hazeWhen things go sideways (and what that usually means)A small checklist to keep nearby3 Impressions