Linux VM Notes
IMPORTANT
These notes are superceded by my new linux mm book project where I will be trying to write a book on the subject based on a recent kernel. All future efforts in this area will be made there. See linuxmemory.org for updates on this.
Contents
-
Fundamentals - Overview of virtual memory concepts without referencing any actual code or making assumptions about prior knowledge.
-
Page Tables - Discussion about what page tables are, how they are used in linux, how they are manually traversed, the TLB and finally how page tables are allocated and freed.
-
Process Address Space - Discussion about virtual memory address space for processes - managing VMAs, process data structure construction/destruction, file/device-backed memory regions, page faulting, demand allocation, COW pages, copying to/from userland.
-
Transparent Huge Pages - Discussion about the kernel's transparent huge pages functionality.
-
Out of Memory Killer - Discussion about overcommit and how the OOM killer selects and kills victims.
-
Process Autopsy - Examining the memory allocation performed by the kernel for a simple userland application.
Introduction
NOTE: I target linux 4.6 and an x86-64 non-NUMA system.
This repo contains my notes on the linux 4.6 VM subsystem. I don't make any claim to their quality or usefulness. They are an ongoing project and as such are a constant work in progress.
This work first originated from the notes I took from the excellent Understanding the Linux Virtual Memory Manager by Mel Gorman which, while great, targets the 2.4.22 kernel (released in 2003.) The obvious next stage of study was to take notes for a recent kernel, which is what these notes are!
I am specifically targeting the 4.6 kernel since it was the mainline version at the time of writing and should remain a sane and stable basis for notes and hacks for the foreseeable future. I may update to newer kernel versions over time depending on whether it makes sense to do so (and if I succeed at this project of course!)
Hacks
Speaking of hacks linux-vm-notes
's sister repo, linux-vm-hacks, is
where I'm putting exploratory code and patches relating to my exploration of the
VM subsystem.
License
These notes are licensed under Creative Commons BY-NC-SA.