In this lesson, you will learn how to determine the impact of paging on process execution performance by measuring how often your applications request data that isn't currently in physical memory.
Understanding Page Faults
When a process tries to access a memory address, the Linux kernel checks if that memory is currently residing in physical RAM. If it isn’t, the CPU triggers a page fault. The kernel must then pause the process, locate the data (often on the disk), load it into a physical page frame, and update the process's page table.
While "minor" page faults are routine, "major" page faults—where the kernel must wait for slow disk I/O—can significantly degrade performance. If a process experiences a high frequency of these faults, it spends more time waiting for the hardware than actually executing instructions, leading to what we call "paging thrashing."
Tracing the Impact
To see how this affects your process, you can look at the /proc/[pid]/stat file. This file provides specific counters for the number of minor and major faults a process has accumulated since it started.
You can view these values quickly using the ps utility:
# Display minor faults (minflt) and major faults (majflt) for a PID
ps -o minflt,majflt -p <PID>
- Minor Faults (
minflt): The process accessed a page that wasn't mapped, but it was already in memory (e.g., shared libraries). These are usually inexpensive. - Major Faults (
majflt): The process accessed a page that required disk I/O to retrieve. If this number is increasing rapidly, your process is likely "paging," and you should investigate if your system is suffering from memory pressure.
By monitoring these counters over time, you can correlate spikes in latency with disk-heavy memory access patterns. If you see high majflt counts during a performance dip, your process is likely being throttled by the speed of your storage rather than the speed of your CPU.
Key Takeaway: Monitoring major page faults allows you to identify when a process’s performance is being bottlenecked by disk-based memory retrieval rather than raw computational throughput.