Purpose of the Modify Bit in a Page Table
In virtual memory, each page table entry contains not only an address mapping but also control and status metadata such as the present bit, protection bits, accessed bit, and the modify bit—also called the dirty bit. Its primary purpose is to record whether a page has been changed while resident in main memory.2
This bit is crucial because the operating system must know whether an evicted page needs to be written back to its backing store before reuse of the physical frame. If the page has not been modified, the copy already on disk is still valid, so the OS can discard the in-memory copy without an expensive disk write.3
In short, the modify bit exists to optimize page replacement, reduce unnecessary I/O, and preserve correctness during eviction.2
A useful way to frame its role is this:
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩ ↩2 ↩3 ↩4
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩ ↩2
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩ ↩2 ↩3
-
Valid Bit and Dirty Bit in page tables - Stack Overflow - Concise explanation of why dirty bits prevent needless write-back and expensive comparisons. ↩
Dirty Bit and Page Replacement in Virtual Memory
Core Idea
The modify bit tells the OS whether a resident page differs from its disk copy. That single bit prevents many unnecessary disk writes during page replacement.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
Where the Modify Bit Fits in a Page Table Entry
A page table maps a virtual page number to a physical frame number and stores status fields that guide access and memory-management policy.2 Common fields include:
| Field | Purpose |
|---|---|
| Present/Valid bit | Indicates whether the page is currently in physical memory. |
| Read/Write/Execute bits | Enforce access permissions.2 |
| Accessed/Referenced bit | Records whether the page has been touched recently.2 |
| Modify/Dirty bit | Records whether the page has been written since load.2 |
The modify bit is typically set when a store operation targets the page. On many architectures, the hardware memory-management unit or related translation mechanism updates this status automatically when a write occurs.3 Linux kernel documentation similarly describes the dirty bit as indicating that the page has been modified since it was loaded into memory.
This distinction matters because a page can be:
- Present and clean: in RAM, unchanged relative to disk.2
- Present and dirty: in RAM, modified, so disk is stale.2
- Not present: not currently in RAM, requiring a page fault to access.
The modify bit therefore acts as a compact synchronization signal between RAM and disk-backed state.2
Footnotes
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7
-
Page Table Management - Reviews page table entry fields, including protection and status bits such as dirty and accessed. ↩ ↩2
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩ ↩2 ↩3
-
Organization of Computer Systems: Processor & Datapath - Explains how reference and dirty bits are updated in TLB/page-table workflows. ↩ ↩2
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩ ↩2 ↩3 ↩4
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩ ↩2
How the Modify Bit Is Used During Page Replacement
- 1Step 1
A page is brought from disk into physical memory after a page fault or initial demand load. At this moment, its in-memory contents match backing storage, so the modify bit starts clear.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩
-
- 2Step 2
Reads do not make the disk copy stale. The page may become referenced, but it is still considered clean if no write occurs.2
Footnotes
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩
-
Organization of Computer Systems: Processor & Datapath - Explains how reference and dirty bits are updated in TLB/page-table workflows. ↩
-
- 3Step 3
When the processor stores data into the page, hardware sets the modify bit. This marks that the RAM copy now differs from the copy on disk.3
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩
-
Organization of Computer Systems: Processor & Datapath - Explains how reference and dirty bits are updated in TLB/page-table workflows. ↩
-
- 4Step 4
If memory pressure requires a victim page, the OS examines metadata in the page table entry, including the accessed bit and the modify bit.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
-
- 5Step 5
If the bit is clear, the page can be discarded because backing storage already has a correct copy. If the bit is set, the OS must write the page back before reusing the frame.3
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
-
- 6Step 6
After either discard or write-back, the physical frame can be assigned to another page. This lowers memory pressure while preserving correctness.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
-
Why It Matters for Performance
Disk writes are far more expensive than checking one bit in a page table entry. Without a modify bit, the OS would either write back pages unnecessarily or need costly comparisons against disk state.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
Why the Modify Bit Improves Efficiency
The main optimization is avoidance of unnecessary write-back traffic.2 Suppose a page is loaded from disk, read several times, and then evicted without ever being written. Writing it back would waste time and I/O bandwidth because the disk already contains the same content.2
This is especially important because page-fault handling may already require significant latency. If the victim page is dirty, replacement may require both:
That can effectively add an extra I/O step to page replacement. Therefore, systems often prefer clean pages as eviction victims when possible.
A conceptual cost table is:
| Victim page state | Need disk write before eviction? | Reason |
|---|---|---|
| Clean | No | Disk copy is already current.2 |
| Dirty | Yes | RAM copy differs from disk and must be preserved.3 |
This optimization aligns with a write-back policy rather than write-through. Virtual memory systems commonly rely on write-back behavior and use the dirty bit to make it safe.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩ ↩2 ↩3 ↩4
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Valid Bit and Dirty Bit in page tables - Stack Overflow - Concise explanation of why dirty bits prevent needless write-back and expensive comparisons. ↩
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩ ↩2
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩
Eviction Work by Page State
Conceptual comparison of page replacement overhead
Relationship Between Modify Bit and Other Bits
The modify bit should not be confused with the valid bit or the accessed bit.3
- The valid/present bit answers: “Is this page currently in RAM?”
- The accessed/reference bit answers: “Has this page been used recently?”2
- The modify/dirty bit answers: “Has this page been written since it was loaded?”2
These bits support different operating-system decisions:
| Bit | Primary question answered | Typical OS use |
|---|---|---|
| Valid/Present | Is translation currently usable? | Detect page faults and residency. |
| Accessed/Referenced | Was the page recently touched? | Approximate LRU and replacement heuristics.2 |
| Modify/Dirty | Was the page changed? | Decide whether write-back is required.3 |
A page may be accessed many times but remain clean if all accesses are reads. Conversely, a single write is enough to make the page dirty.2
Footnotes
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩ ↩2 ↩3 ↩4
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Organization of Computer Systems: Processor & Datapath - Explains how reference and dirty bits are updated in TLB/page-table workflows. ↩ ↩2 ↩3 ↩4
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩ ↩2 ↩3
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩ ↩2
Common Questions and Edge Cases
Lifecycle of a Page with Respect to the Modify Bit
Page-in
Stage 1The page is fetched from disk into RAM. It begins clean because RAM and backing storage match.2"
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩
Read activity
Stage 2The page may be accessed many times without becoming dirty if all operations are reads.2"
Footnotes
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩
-
Organization of Computer Systems: Processor & Datapath - Explains how reference and dirty bits are updated in TLB/page-table workflows. ↩
Write activity
Stage 3A store instruction changes the page, and the modify bit is set to indicate divergence from disk.2"
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩
Replacement decision
Stage 4When memory is scarce, the OS evaluates victim pages and consults the modify bit.2"
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
Write-back or discard
Stage 5Clean pages can be discarded; dirty pages must be written back before frame reuse.3"
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩
The modify bit answers one practical question: did RAM change this page after it was loaded? If not, the OS can throw the page away when needed. If yes, the OS must save it first.2
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
A Precise Answer to the Question
The purpose of the modify bit in a page table is to indicate whether a page in physical memory has been altered since it was loaded from disk or other backing storage.2 The operating system uses this information during page replacement:
- if the bit is 0, the page is clean and can usually be discarded without writing it back;2
- if the bit is 1, the page is dirty and must be written back before eviction so that modifications are not lost.3
Therefore, the modify bit serves both correctness and performance:
- correctness, because modified data must not be lost;2
- performance, because unmodified pages should not trigger needless disk writes.3
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩ ↩2 ↩3 ↩4 ↩5
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩ ↩2 ↩3
-
Page Table Design - CS 61C Course Notes - Explains valid bits, dirty bits, and write-back behavior in virtual memory. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩ ↩2
-
Valid Bit and Dirty Bit in page tables - Stack Overflow - Concise explanation of why dirty bits prevent needless write-back and expensive comparisons. ↩
Exam Shortcut
If a question asks about the modify bit, the safest concise answer is: it tells the OS whether an evicted page must be written back to disk.3
Footnotes
-
Dirty bit - Wikipedia - Defines the dirty/modified bit and explains its role in page replacement and write-back decisions. ↩
-
Operating Systems: Virtual Memory - Describes how the modify bit reduces page replacement cost and why clean pages are attractive eviction targets. ↩
-
Page Tables — The Linux Kernel documentation - Notes that the dirty bit is set when a page is written and indicates modification since load. ↩
Knowledge Check
What is the primary purpose of the modify bit in a page table?
Explore Related Topics
Address Translation in Paging and Why Page Size Is Usually a Power of Two
Inverted Page Table
Fixed Partition vs Variable Partition in Operating Systems, and the Need for Compaction
Fixed and variable partitioning are contiguous memory allocation schemes that differ in when partitions are created and the type of fragmentation they produce, prompting the use of compaction.
- Fixed partitioning: static predefined partitions, simple implementation, limited multiprogramming, suffers internal fragmentation (e.g., a process in a partition).
- Variable partitioning: dynamic partitions sized to each process, higher memory utilization, but creates external fragmentation requiring placement algorithms.
- Compaction moves processes to coalesce free holes, turning scattered space such as into a single block for a request.
- Compaction is expensive because it involves process relocation and address updates.
