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
1
vote
1 answer

How do I determine the page number from the virtual address?

I am looking for help with the following homework question: It is assumed that a program has a virtual space of 1200 words. Consider the following series of virtual addresses: 60; 222; 160; 910; 450; 345; 412; 10; 180; 20; 443; 766; 812. Give the…
Bulbasaur
  • 303
  • 3
  • 19
1
vote
0 answers

Difference in how the page fault handler handles read vs write access requests?

All the research I've done indicates only that a memory access has occurred, not if it was a read or a write access. Does that mean it doesn't matter? What if the page replacement algorithm which handles page faults depending on when they were last…
1
vote
1 answer

Assembly CALL instruction, write faults?

In the page fault handler of the linux kernel using some opcode disassembly I am seeing that on the x86 architecture the CALL or 0xE8 instruction occasionally throws a write fault and ESI and EDI are both NULL. I was wondering if there is a specific…
Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88
1
vote
1 answer

High amount of page faults when rendering QWidgets

I noticed a large amount of page faults in my Qt application. I reproduced it by resizing a docking widget (with a widget tree of dozens of widgets underneath) for 2 seconds and traced that operation using AQTime. I get 2000 page faults for this…
Pieter
  • 1,191
  • 1
  • 11
  • 29
1
vote
2 answers

Page Fault in Linux Kernel

I have few questions after reading Mel Gorman's book Understanding the Linux Virtual Memory Manager. Section 4.3 Process Address Space Descriptor says kernel threads never page fault or access the user space portion. The only exception is page…
Franc
  • 319
  • 9
  • 28
1
vote
0 answers

When I manually modify page table entry (pte) flag bits in the Linux kernel, why does the flag modification revert back sometimes?

Question: For context, my code is meant to take a process and intentionally cause extra page faults. I start by manually modifying its page table entries' pte_flags by turning off their present bit and then turning on my own special bit, residing in…
wxz
  • 2,254
  • 1
  • 10
  • 31
1
vote
1 answer

Prefetching in vm_fault(), Linux drivers

I'm implementing a simple device driver. The program that uses this driver takes in arguments from the user whether to use demand paging or prefetching(fetches next page only). But when the user requests for prefetching is should send this…
1
vote
1 answer

Can address be loaded in a cache but not in the main memory?

Can memory address be loaded in a cache but not in the main memory? In other words, if cache wants to write data into the main memory, can that generate page fault in x86-64 with Linux?
vens
  • 11
  • 2
1
vote
1 answer

How can I dump memory from an arbitrary virtual address, ignoring SIGSEGV

I'm looking for a way to iterate over memory and print it (or do anything with it really), but if the virtual address hasn't been allocated I'll get a segfault. How can I attempt to read arbitrary addresses in my program and not crash? This is…
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
1
vote
1 answer

Can we ever have 0 page fault rate with an infinite, or an absurd amount of it?

I have an assignment for my Operating System course. One of the questions aks me to provide an explanation as to why it is possible/not possible to have 0 page-fault rate. Can a real system have enough RAM so that it will have no page faults at…
Eduard
  • 111
  • 1
  • 10
1
vote
0 answers

Why the times of TLB miss is not equal to times of page fault

I try to learn about the the memory management if Linux kernel, and I write the code like this: //mem.c #include #include #include void main() { char *brk_end = NULL; char *p = sbrk(0); int nr = 10000, i…
Nail Jay
  • 267
  • 3
  • 9
1
vote
2 answers

Is it possible to “abort” when loading a register from memory rather the triggering a page fault?

I am thinking about 'Minimizing page faults (and TLB faults) while “walking” a large graph' 'How to know whether a pointer is in physical memory or it will trigger a Page Fault?' is a related question looking at the problem from the other side, but…
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
1
vote
3 answers

Minimizing page faults (and TLB faults) while "walking" a large graph

Problem (think of the mark phase of a GC) I have a graph of “objects” that I need to walk, visiting all objects. I can store in each object if it has been visited. All the objects are stored in memory and linked together using normal pointers. The…
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
1
vote
0 answers

Determining the address that is causing double page fault

A hardware is performing memory operation and resulting in a page-fault. How can I determine the virtual address that is causing following double fault error message so that I can pin the address? [ 52.330981] PANIC: double fault, error_code:…
Proy
  • 336
  • 2
  • 13
1
vote
0 answers

about LRU, How can the operating system know about a memory frame use when it's valid

In virtual memory, The LRU algorithm is about swapping out page frame which has been the least recently used, but how can the OS know about a frame use since it wont be raising any exception when it is valid ? Are there use counters of some sort in…
Camion
  • 1,264
  • 9
  • 22