Difference between minor page faults vs major page faults

We have seen about page faults in few of the previous articles. In this article we will be looking at two different kind of page faults that can happen. So lets have a look at major and minor page faults.

Difference between minor page faults vs major page faults

TLDR – Minor page faults occurs when the page is present in the memory but is not mapped properly either because of invalid mapping or data is not cleared from the page by its previous process whereas the Major Page Fault occurs because of the absence of the required page from the RAM and bringing it in costs heavy penalty in terms of cpu cycles occurred due to swap in ,swap out and restarting of the process altogether.

What is a page Fault

In very easy terms we can describe a page fault as a condition when a process undergoing execution in cpu can’t find a page (unit of fixed sized blocks in partitioning scheme “PAGING”) of the process or when a page doesn’t have a valid mapping in the address space of a process , both are the same things said differently.

Why Page Faults are bad ?

Basically page faults are the second worst thing that can happen to the performance of a system after I/O requiring human intervention in terms of system performance .

So yes, if you are a person who loves a high performance , you should always try to minimize the probability of page faults occurring. So getting back to page faults are the worst and which of them is more worse .

Yes , if you put your bid on Major Page Fault , CONGRATS!!!


Some terminology with which you should be familiar with are

Fixed size block in RAM(Physical Address Space)  -  Frame
Fixed size block created by CPU(Logical Address Space) - Page

PAGE TABLE – has mapping of address in RAM of pages and a validation bit which tells either the page is present ‘1’ on that address or not ‘0’

In paging memory scheme:-

Page size = Frame size

Minor Page Fault 

 It occurs when a process doesn’t have a logical mapping to a page , yet the page is present in a frame in RAM.

There are generally 2 major reasons behind it.

A process may refer to a shared library that is in memory, but the process doesn’t have a mapping to it in its page table , in this case the kernel only updates the page table to refer to the required page.

When a page is reclaimed from the process and put on free-frame list , but the page is not yet cleared of its data from previous process , in this case  first the page is cleared out of data and then allocated to our process by kernel . Usually occurs when a program tries to allocate space on heap.

It costs a very small performance penalty as compared to major page faults.

Major Page Fault 

This fault occurs when a page is referenced and it is not present in the RAM, and this is worse because now to get the page to the logical address space will cause heavy penalty in performance of system .

First when the process couldn’t find the page for execution the user process stops and gives a trap to the kernel, volatile information on cpu is saved, frames on RAM are checked for the page but since its not present there now starts the heavy lifting of bringing in the page from the secondary storage (DISK) to the RAM and mapping of it in the page table, but wait it gets even worse if no frames are empty on RAM because now the required page will not go to the free-frame list as it no longer has space. Now the page needs to be replaced for a page already present in one of the frames of RAM , but wait it can go downhill from here also, what if the replaced page is dirty ,then it needs to be saved on the disk, after saving the page now we can replace it on the frame and also update the page table .

Major page fault incurs high no. of cpu cycles as penalty but what is worse is that the OS stops the process and cleans out the registers to schedule another process in its place.

A good example of high major page faults occurs in Demand Paging in its initial stages.

To see no. of minor and major page faults of processes in Linux System :-

ps -eo min_flt,maj_flt,cmd

This is all for this article please share and subscribe if you like the article.



Abhay Yadav

DevOps Engineer. Enthusiastic about FOSS and dedicated to learning and developing technology. Fan of attack of titans and you can find him running around football sometimes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.