Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Page fault
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Error from a process accessing unmapped memory}} {{More footnotes|date=February 2008}} In computing, a '''page fault''' is an [[Exception handling|exception]] that the [[memory management unit]] (MMU) raises when a [[Process (computing)|process]] accesses a [[memory page]] without proper preparations. Accessing the page requires a mapping to be added to the process's [[virtual address space]]. Furthermore, the actual page contents may need to be loaded from a back-up, e.g. a [[disk storage|disk]]. The MMU detects the page fault, but the operating system's [[Kernel (operating system)|kernel]] handles the exception by making the required page accessible in the physical memory or denying an illegal memory access. Valid page faults are common and necessary to increase the amount of memory available to programs in any operating system that uses [[virtual memory]], such as [[Windows]], [[macOS]], and the [[Linux kernel]].<ref>{{cite book |last1=Bovet |first1=Daniel |last2=Cesati |first2=Marco |title=Understanding the Linux Kernel |date=November 2005 |publisher=O'Reilly Media |isbn=0-596-00565-2 |edition=3rd |url=http://gauss.ececs.uc.edu/Courses/c4029/code/memory/understanding.pdf |access-date=9 October 2021}}</ref> == Types == === Minor page fault === If the page is loaded in memory at the time the fault is generated, but is not marked in the [[memory management unit]] as being loaded in memory, then it is called a ''minor'' or ''soft'' page fault. The page fault handler in the [[operating system]] merely needs to make the entry for that page in the memory management unit point to the page in memory and indicate that the page is loaded in memory; it does not need to read the page into memory. This could happen if the [[Shared memory (interprocess communication)|memory is shared]] by different programs and the page is already brought into memory for other programs. === Major page fault === This is the mechanism used by an operating system to increase the amount of program memory available on demand. The operating system delays loading parts of the program from disk until the program attempts to use it and the page fault is generated. If the page is not loaded in memory at the time of the fault, then it is called a ''major'' or ''hard'' page fault. The page fault handler in the OS needs to find a free location: either a free page in memory, or a non-free page in memory. This latter might be used by another process, in which case the OS needs to write out the data in that page (if it has not been written out since it was last modified) and mark that page as not being loaded in memory in its process [[page table]]. Once the space has been made available, the OS can read the data for the new page into memory, add an entry to its location in the memory management unit, and indicate that the page is loaded. Thus major faults are more expensive than minor faults and add storage access latency to the interrupted program's execution. === Invalid page fault === If a page fault occurs for a reference to an address that is not part of the virtual [[address space]], meaning there cannot be a page in memory corresponding to it, then it is called an ''invalid'' page fault. The page fault handler in the operating system will then generally pass a [[segmentation fault]] to the offending process, indicating that the access was invalid; this usually results in [[abnormal termination]] of the code that made the invalid reference. A [[null pointer]] is usually represented as a pointer to address 0 in the address space; many operating systems set up the MMU to indicate that the page that contains that address is not in memory, and do not include that page in the virtual address space, so that attempts to read or write the memory referenced by a null pointer get an invalid page fault. == Invalid conditions == Illegal accesses and invalid page faults can result in a [[segmentation fault]] or [[bus error]], resulting in an app or OS [[Crash (computing)|crash]]. [[Software bug]]s are often the causes of these problems, but hardware memory errors, such as those caused by [[overclocking]], may corrupt pointers and cause valid code to fail. Operating systems provide differing mechanisms for reporting page fault errors. [[Microsoft Windows]] uses [[Structured Exception Handling|structured exception handling]] to report invalid page faults as [[access violation]] exceptions. [[UNIX-like]] systems typically use [[Signal (computing)|signals]], such as [[SIGSEGV]], to report these error conditions to programs. If the program receiving the error does not handle it, the operating system performs a default action, typically involving the termination of the running [[process (computing)|process]] that caused the error condition, and notifying the user that the program has malfunctioned. Windows often reports such crashes without going to any details. An experienced user can retrieve detailed information using [[WinDbg]] and the [[minidump]] that Windows creates during the crash. UNIX-like operating systems report these conditions with such error messages as "segmentation violation" or "bus error", and may produce a [[core dump]]. == Performance impact == Page faults degrade system performance and can cause [[thrashing (computer science)|thrashing]]. Major page faults on a conventional computer using [[hard disk drive]]s can have a significant impact on their performance, as a typical hard disk drive had an average [[rotational latency]] of 3 ms, a [[seek time]] of 5 ms and a transfer time of 0.05 ms/page. Therefore, the total time for paging is near 8 ms (8,000 μs). If the memory access time is 0.2 μs, then the page fault would make the operation about 40,000 times slower. With a more modern system using a fast [[solid-state drive]] with a page read latency of 0.030 ms (30 μs)<ref>{{Cite web |last=W1zzard |last2= |date=2023-08-08 |title=Samsung 990 Pro 2 TB Review |url=https://www.techpowerup.com/review/samsung-990-pro-2-tb/5.html |access-date=2025-05-19 |website=TechPowerUp |language=en |publication-date=}}</ref> and a memory access latency of 70 ns (0.070 μs),<ref>{{Cite web |last=W1zzard |last2= |last3= |first3= |date=2024-08-07 |title=AMD Ryzen 5 9600X Review - The Best Sub-$300 Gaming CPU |url=https://www.techpowerup.com/review/amd-ryzen-5-9600x/6.html |access-date=2025-05-19 |website=TechPowerUp |language=en}}</ref> a hard page fault is still over 400 times slower. Performance [[Optimization (computer science)|optimization]] of programs or operating systems often involves efforts to reduce the number of page faults. Two primary focuses of the optimization are reducing overall memory usage and improving [[memory locality]]. To reduce the page faults, OS developers must use an appropriate [[page replacement algorithm]] that maximizes the page hits. Many have been proposed, such as implementing [[heuristic algorithm]]s to reduce the incidence of page faults. Larger physical memory also reduces the likelihood of page faults. Chunks of [[Memory-mapped file|memory-mapped files]] can remain in memory longer and avoid slow re-reads from storage. Similarly, lower memory pressure lessens the need for frequent [[Memory paging|swapping out]] of memory pages to a backing storage device used for swap. == See also == * [[Bélády's anomaly]] * [[Memory hierarchy]] == References == {{Reflist}} {{Refbegin}} * John L. Hennessy, David A. Patterson, ''Computer Architecture, A Quantitative Approach'' ({{ISBN|1-55860-724-2}}) * Tanenbaum, Andrew S. ''Operating Systems: Design and Implementation (Second Edition)''. New Jersey: Prentice-Hall 1997. * ''Intel Architecture Software Developer's Manual''–Volume 3: System Programming {{Refend}} == External links == * "[https://web.archive.org/web/20061016080158/http://www.osronline.com/article.cfm?article=222 So What Is A Page Fault?]"{{subscription required}} from OSR Online (a Windows-specific explanation) * "[https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Introduction_To_System_Administration/s1-memory-virt-details.html Virtual Memory Details]" from the Red Hat website. * "[http://msdn2.microsoft.com/en-us/library/ms681401.aspx UnhandledExceptionFilter (Windows)]" from [http://msdn.microsoft.com/library MSDN Online]. * "[https://plus.google.com/+LinusTorvalds/posts/YDKRFDwHwr6 Page fault overhead]" for information about how page faults can crucially affect processing time. [[Category:Virtual memory]] [[Category:Memory management]] [[Category:Computer errors]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:ISBN
(
edit
)
Template:More footnotes
(
edit
)
Template:Refbegin
(
edit
)
Template:Refend
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Subscription required
(
edit
)