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

Hijacking page fault handler

I have a process PID that access a memory region that it's not allowed to, the CPU creates a trap into the kernel which calls do_page_fault() which will send SIGSEGV to the user process. The user process has a custom signal handler that has some…
0
votes
0 answers

How to resume the page-fault handler

So as we know when page fault occurs: (1)the hardware traps to the kernel (2) saves program counter on the stack (3)assembly-code routine saves all registers on corresponding process table entry (4)page fault handler discovers which virtual page is…
0
votes
0 answers

Does page-fault effect performance much, by forking child process?

I have a busy process which occupies 30% CPU and 1G memory usage, at Linux. The process makes a snapshot every hour, by calling fork() to create a child process which writes all data to a file. It takes about 1second. I found that the father…
Bingzheng Wu
  • 435
  • 3
  • 11
0
votes
1 answer

Can Someone Give me a high-level overview of the VSWS Algorithm used in Operating Systems?

I am trying to find videos/resources that can give me a simple, clear, concise description of the VSWS algorithm but I cannot seem to find any. Any help would be appreciated!
EdJin
  • 11
  • 1
0
votes
2 answers

Does mmap causes a page fault after we use fork?

Because of COW, linux will assign a page to a child process only once it has been written to. It will also assign a new page for the stack only once it is changed. So for example, if after a fork() syscall, we call printf in the child, since the…
Eminem
  • 143
  • 6
0
votes
0 answers

What exactly triggers a memory read access violation exception (Hardware/OS)?

Consider a custom data structure that represents a 3 byte unsigned integer. In little-endian assembly, one can simply load 4 bytes into a register via a dword pointer and, for instance, perform addition on 3 byte integers, store the lower word at…
0
votes
0 answers

thread keeps generating page fault

So i was recently trying to exploit a kernel mode driver (HEVD) and I encountered a problem which doesn't make sense to me. After i jumped to my shellcode (which resides in usermode and was made executable by VirtualProtect), the thread keeps…
Trac3r
  • 25
  • 5
0
votes
1 answer

Memory capacity saturation and minor page faults

In USE Method: Linux Performance Checklist it is mentioned that The goal is a measure of memory capacity saturation - the degree to which a process is driving the system beyond its ability (and causing paging/swapping). [...] Another metric that…
jack malkovick
  • 503
  • 2
  • 14
0
votes
0 answers

What are the semantics of VM_UFFD_MISSING?

I'm reading through the Linux kernel's page fault handler (linux-4.14.198), and noticed the following block of code: /* Deliver the page fault to userland, check inside PT lock */ if (userfaultfd_missing(vma)) { …
merlin2011
  • 71,677
  • 44
  • 195
  • 329
0
votes
1 answer

Can page fault occur if we don't use virtual memory?

I was reading about Virtual Memory and Page Fault. From what I understand, Page Fault occurs when the page CPU is looking for is not present in the Main Memory. I had a doubt that, can page fault occur if we don't not use virtual memory?
0
votes
1 answer

Is there a disk access in every page fault?

My question is (as stated) is there an access to the disk/virtual memory every time there is a page fault? If not, in what cases is there no disk access? (this is a general question about paging and not implementation dependent) Thank you
Tom
  • 69
  • 7
0
votes
1 answer

Can x86-64 return instruction cause a page fault in linux? Is the current process stack always in main memory?

I know a return instruction will transfer "program control to a return address located on the top of the stack" (page 1205). Is the stack for the current process always in memory? Assuming I return to a function in my own program (a near return?),…
wxz
  • 2,254
  • 1
  • 10
  • 31
0
votes
1 answer

Paging and non-contiguous memory allocation

I have few doubts regarding the memory management in a x86_64 Linux Operating System. If I allocate an array of 2000 bytes (statically - arr[2000]; or dynamically - malloc(2000);) from my user space code, are these going to be a contiguous memory…
0
votes
1 answer

How to measure number of allocated page tables?

As far as I know, Linux does not allocate page tables until needed (allocation happens on-demand as pages are used). I want to check how many page tables are really allocated during program execution. Could you please let me know how can I measure…
Zzingco
  • 41
  • 5
0
votes
1 answer

how to determine if a memory organization follows row major order or column major order?

How to determine if a memory organization follows a row-major order or column-major order? I learned this new concept and got to know that if we know what a memory organization follows a row-major order or column-major order , we can make our array…