All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Understanding Linux Memory Management: Page Faults, mmap, and userfaultfd

By

shayonj

2mo ago· 25 min readenInsight

Summary

This technical article explores Linux memory management concepts including page faults, mmap system calls, and userfaultfd. The author explains how Linux uses demand paging to lazily allocate physical memory, how mmap creates virtual-to-physical mappings, and how userfaultfd allows userspace programs to handle page faults. The practical motivation was optimizing VM snapshot restoration by lazily populating guest memory, but the article focuses on the underlying Linux memory model that enables such optimizations.

Key quotes

· 4 pulled
The motivation was a specific problem, which was making Virtual Machine (VM) snapshot restore fast by lazily populating guest memory.
But the underlying mechanisms are general Linux concepts that I think are worth understanding on their own.
This post is less about any specific Virtual Machine Monitor (VMM) and more about the Linux memory model that makes lazy restore possible.
How Linux demand-pages memory, what mmap does to physical pages, why replacing a mapping breaks direct memory access and shared memory, and how userfaultfd lets you lazily populate memory without destroying the mapping.
Snippet from the RSS feed
How Linux demand-pages memory, what mmap does to physical pages, why replacing a mapping breaks direct memory access and shared memory, and how userfaultfd lets you lazily populate memory without destroying the mapping.

You might also wanna read