Questions tagged [page-fault]

An interrupt that occurs when a program requests data that is not currently in main memory. The interrupt triggers the operating system to fetch the data from a virtual memory and load it into RAM.

A page fault (sometimes #pf or pf) is a trap to the software raised by the hardware when a program accesses a page that is mapped in the virtual address space, but not loaded in physical memory. In the typical case the operating system tries to handle the page fault by making the required page accessible at a location in physical memory or terminates the program in the case of an illegal access. The hardware that detects a page fault is the memory management unit in a processor. The exception handling software that handles the page fault is generally part of the operating system. -- source wikipedia.

Types of page-faults:

MINOR: 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.

MAJOR: 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.

INVALID: 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. --source wikipedia

Handling illegal accesses and invalid page faults:

  • 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 that caused the error condition, and notifying the user that the program has malfunctioned.

  • Page faults, by their very nature, degrade the performance of a program or operating system and in the degenerate case can cause thrashing. Optimization of programs and the operating system that reduce the number of page faults improve the performance of the program or even the entire system.
187 questions
2
votes
1 answer

Instruction pointer value after the page fault trap has been handled

Honestly, I am really confused with this particular virtual memory related concept. Q1) When a page fault occurs, does the processor first finishes the execution of the current instruction and then moves the IP register contents (address of…
Bhavyanshu
  • 536
  • 7
  • 25
2
votes
1 answer

page faults while reading a large file

I am working on a system with 4GB ram . I created a large file of 4GB and initialized it with zeros. I started reading the large file integer by integer. I find that the number of page faults (major) is zero, no matter how big is the file. I read…
2
votes
1 answer

Page faults in LRU algorithm

I'm having trouble with understanding something from my programming lecture. I know that page replacement algorithms have page faults. In the LRU algorithm, when does a page fault occur? Is it when there are no more free frames left? Is it when a…
user3211186
  • 115
  • 2
  • 13
2
votes
0 answers

Mongodb: slow range queries and too many page faults

I've started mongodb instance on single server with 96Gb of RAM. CollStats of the largest collection: "count" : 513025635, "size" : 131860720528, //≈123Gb "avgObjSize" : 257.02559781052656, "storageSize" : 141246233632, "numExtents"…
Borodin.Mik
  • 332
  • 1
  • 4
  • 11
2
votes
1 answer

MongoDB, NUMA hardware, page faults but enough RAM for working set, touch command or vmtouch/dd does not load into memory

MongoDB 2.46 & 2.4.8 Use case: Load up 100.000 documents on a collection with 2 indexes. Resident memory increases (mongostat), and no page faults happen. Restart mongod. Resident memory is low (this is expected) Try to 'preheat' mongo, with touch…
ialex
  • 471
  • 1
  • 5
  • 10
2
votes
1 answer

Relation between pagesize and pagefault

I studied from book william stalling ,it was written there if we increase the size of page then pagefault first increases and then when pagesize become size of process then pagefault decreases. I am not able to understand why pagefault increases as…
KJS
  • 43
  • 2
  • 7
2
votes
2 answers

What's causing the 135k/sec page faults in this python code? (trial-division prime sieve)

The following code executes in a work thread, and just happily spins away, receiving pause/report commands, etc. I assume they're soft faults since I'm not having RAM use issues and my hard drive didn't melt over the weekend, and that it's got…
Redsplinter
  • 163
  • 1
  • 8
1
vote
1 answer

Avoiding minor page faults in a C++ program with g++

I am trying to solve this puzzle: Shipping Coding Puzzle. This is the code I have come up so far: #include #include #include #include #include #include #include using namespace…
Asha
  • 11,002
  • 6
  • 44
  • 66
1
vote
0 answers

How to check/detect for page faults in application level functions?

Suppose I am running a virtual machine or container, and I am allowed to run e.g. Java programs inside. Is there a way to detect page faults that occur when accessing the guest memory at the application level (i.e. from the Java program), perhaps…
Ymi
  • 609
  • 6
  • 18
1
vote
2 answers

Userfaultfd write protection appears unsupported when checking through the UFFDIO_API ioctl

I am trying to use the write protection feature of Linux's userfaultfd, but it does not appear to be enabled in my kernel even though I am using version 5.13 (write protection should be fully supported in 5.10+). When I run #define…
Zach
  • 4,652
  • 18
  • 22
1
vote
0 answers

Can page faults be triggered by NUMA access?

I have some multithreaded code where the threads spend a significant amount time in the page fault handler of the kernel (Linux 5.4). But this only happens on a two Socket NUMA machine, but not on on a machine without NUMA. So my question is, can an…
Unlikus
  • 1,419
  • 10
  • 24
1
vote
2 answers

Erlang causes page faults

When I run the script described here with my user, everything is well: lorenzo@enzo:~/erlang/pei$ time erl -noshell -smp enabled -S 4 -s fib4 main 10000000 real 0m54.952s user 1m16.090s sys 0m0.070s When I run it as root, it…
Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
1
vote
1 answer

Page Table Entry, Present Bit?

Quoting from: http://www.cburch.com/books/vm/index.html The final bit (labeled P) indicates whether the page is present in RAM. If this bit is 0, then any access to the page will trigger a page fault. My professor doesn't agree, he said the bit…
1
vote
1 answer

Pagefaults when starting application from Visual Studio

I'm using Visual Studio 2010 to write and debug a small program. The problem is, whenever I start the application through Visual Studio 2010 the process of my application produces page-faults in the range of 100000 per second and that slows down the…
Darcara
  • 1,598
  • 1
  • 13
  • 33
1
vote
1 answer

lazy overcommit allocation and calloc

Can someone in the know please explain how lazy-backed heap storage interacts with the memory-zeroing guarantees of calloc/realloc? Specifically, I would like to know: if/when the zero writes would cause storage to be faulted in…
l.k
  • 199
  • 8