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
0
votes
1 answer

Unable to read eBPF function argument correctly

I have a eBPF function that is attached to the page_fault_user tracepoint. struct trace_event_raw_x86_exceptions { struct trace_entry ent; long unsigned int address; long unsigned int ip; long unsigned int error_code; char…
WU ZHENWEI
  • 36
  • 4
0
votes
0 answers

Why does copy_to_user fail after process forked?

I'm writing a kernel module that would write some data to user space buffer via copy_to_user. However, I found that copy_to_user always fails (returns non-zero) after the process forks. (copy_to_user works fine if I don't fork the process.)…
0
votes
0 answers

Concurrent mmap page faults failing to use NVMe IO queue on Linux?

I have a database-like service that serves queries from an embedded key-value store (LMDB), where the data is 1. orders-of-magnitude larger than main memory; 2. rarely written to/updated (once per hour or less), 3. heavily read by many concurrent…
tsutsu
  • 63
  • 3
0
votes
0 answers

page fault error with SIMD strlen (using SWAR in integer registers, not SSE)

The asm function strlen receives the link to an string as a char - Array. To to so, the functions may use SIMD on general purpose register, but without using xmm register or SSE instructions. The functions checks with bit manipulation in 8 Byte…
HeapUnderStop
  • 378
  • 1
  • 9
0
votes
0 answers

Can't write a simple program to force hard page faults

I want to experiment with hard page faults so I need a program to produce them and some tools to profile what is happening. However, every program I find/write produces no hard faults. This is a typical program that should do the trick. Alloc a lot…
0
votes
0 answers

Receiving a page fault after interrupt fired by 8259A PIC

I'm learning how to use 8259A PIC. however, when I press the key board, the page fault handler is triggered, the correct handler is not being called. With my source code snippet and screenshot below: //file: main.c void Start_Kernel(void) { …
Raymond
  • 31
  • 1
  • 4
0
votes
0 answers

Implementing FIFO Page Replacement Algorithm in Java - Incorrect Output

I am implementing a page replacement algorithm for a computer operating system. Specifically, I am trying to implement the First-In-First-Out (FIFO) algorithm. The algorithm works by maintaining a list of pages currently in memory, as well as a…
Moeez
  • 23
  • 4
0
votes
0 answers

Is servicing page faults accounted as system CPU time in Linux?

In other words, the time spent servicing page faults does end up in ru_utime or ru_stime when calling getrusage?
Benedetto
  • 711
  • 6
  • 17
0
votes
3 answers

How do the Windows DDK samples deal with being paged out? I don't see much code dealing with it in the samples

How come the Windows DDK samples do not deal with being paged out? Are they non-pageable?
unixman83
  • 9,421
  • 10
  • 68
  • 102
0
votes
0 answers

page fault doens't occur though I flushed cache before access memory(file-mmaped memory)

I wrote simple code which occur page-fault via python. the process is as below. i) make a temp file and mmap via np.memmap() api ii) fill the memory iii) flush memory iv) access memory by index I expected page fault in the iv) step. I used perf…
이두솔
  • 1
  • 1
0
votes
1 answer

When is EIP register equal to CR2 in 80X86?

If CPU fetchs a instruction, is it possible that EIP == CR2 ? I just wonder it, but after many searches it seems that nobody cares about it .
zhao bao
  • 3
  • 2
0
votes
0 answers

Do Page Faults automatically invoke the Operating System?

When a user-space application incurs a page fault, is the Operating System (OS) automatically invoked upon detection of the fault or must the OS be invoked manually? For Linux and x86, I understand there are checks for privilege level of process…
ballsmahoney
  • 141
  • 1
  • 6
0
votes
1 answer

Why does the page fault not cause the thread to finish its execution later?

I have the below code where I'm intentionally creating a page fault in one of the threads in file.c util.c #include "util.h" // to use as a fence() instruction extern inline __attribute__((always_inline)) CYCLES rdtscp(void) { CYCLES cycles; …
0
votes
0 answers

Tens of millions of page faults

I wrote a C++ program that lists all top-level windows and gives user an ability to live capture any of them using GDI. Basically, there runs a Windows timer with 0 delay pointed (of course, there no zero delay) - it gets specified window's DC,…
Ngdgvcb
  • 155
  • 6
0
votes
0 answers

corrupted double link list detected

So here is the setup, I have two nodes Node-A & Node-B. Node-A is incapable of executing some functions, whereas Node-B is dedicated for executing such Node-A's incapable functions. So the idea is when Node-A when wants to execute such functions…