The Myth of the Page Fault: Minor vs Major Faults in Linux
Ask most software engineers what happens during a Page Fault, and the textbook answer is immediate:
"The requested memory address is missing from RAM, so the operating system suspends the process and reads the page from the hard drive or swap partition."
While this describes a Major (Hard) Page Fault, it represents a tiny minority of real-world events.
In production Linux systems, over 95% of all page faults involve zero disk I/O. They are Minor (Soft) Page Faults.
1. The Hardware Definition of a Page Fault
A Page Fault is not a storage subsystem command. It is a CPU architectural interrupt (Interrupt 14 on x86-64).
When an instruction dereferences a virtual address, the Memory Management Unit (MMU) checks the Page Table Entry (PTE):
- If the Present Bit is 0, the MMU cannot translate the address into a physical frame.
- The CPU saves the faulting address in the
CR2register and triggers a Page Fault Exception to transfer control to the kernel.
2. Minor Page Faults (Soft Faults)
A Minor Page Fault occurs when the required physical page is already present in RAM, but the process's page table has not yet been linked to it.
Common Minor Fault Scenarios:
- Shared Libraries (
libc.so): When 200 processes run on a server, Linux does not load 200 copies of C standard libraries. It maintains a single physical copy in RAM. When a new process accessesprintf(), it triggers a minor fault; the kernel simply maps the existing physical frame into the process's page table. - The Page Cache: If another application recently read file data from disk, that data resides in the Linux Page Cache. A minor fault links the page in microseconds.
- Anonymous Zero-Fill on Demand: When
malloc(1024 * 1024)is called, the kernel doesn't allocate 1 MB of physical RAM. It points virtual pages to a single global Zero Page with read-only permissions. The first write triggers a Copy-on-Write minor fault.
3. Major Page Faults (Hard Faults)
A Major Page Fault occurs only when the page is completely absent from RAM and must be retrieved from persistent storage (SSD, HDD, or network filesystem).
- The kernel transitions the thread to
BLOCKED. - Issues an asynchronous DMA I/O request.
- Cost:
5ms - 10mson HDDs (100µson NVMe SSDs)—representing thousands to millions of lost CPU cycles.
Monitoring on Linux:
/usr/bin/time -v ./your_program Outputs:
Minor (reclaiming a frame) page faults: 1420Major (requiring I/O) page faults: 0
Explore virtual memory internals and page fault lifecycles at Binary Dose.
![[Herdr in Practice] Build Your Own Herdr Mod: Create a "Pending Review" Queue with Labels to Instantly Track Unread Reports](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flasxwu5u1is3pu1fn6gi.png)