1

From manpage of top

nMaj  --  Major Page Fault Count
           The number of major page faults that have occurred for a task.  A
           page fault occurs when a process attempts to read from or write
           to a virtual page that is not currently present in its address
           space.  **A major page fault is when auxiliary storage access is
           involved in making that page available.**

nMin  --  Minor Page Fault count
           The number of minor page faults that have occurred for a task.  A
           page fault occurs when a process attempts to read from or write
           to a virtual page that is not currently present in its address
           space.  **A minor page fault does not involve auxiliary storage
           access in making that page available.**

If I am correct, handling page fault is to transfer needed data missing in the physical memory from the swap to the physical memory. Swap is part of the storage e.g. hard drive or SSD. So what does it mean that a page fault may or may not involve auxillary storage access in making that page available?

Thanks.

2 Answers 2

5

Only major page faults involve auxiliary storage (i.e. reading from disk, either from swap or elsewhere, e.g. when paging in a binary).

Minor page faults are faults which can be satisfied without reading from disk:

  • page faults involving data which is already mapped elsewhere in memory (e.g. memory which can be shared between processes)
  • page faults for newly-allocated memory (using on an all-zero page and copy-on-write allocation)
  • in some cases, data which has been marked for paging out but hasn't yet been paged out

(this isn't exhaustive).

3
  • thanks. for minor page faults, (1) do the first two examples in the list involve data transfer between different locations within RAM only, not between RAM and auxiliary storage e.g. disk? (2) in the third example, does "paging out" mean to transfer data from the RAM to the swap on the disk? If yes, doesn't this example of minor page fault involve auxiliary storage access?
    – Tim
    Commented Jun 14, 2016 at 11:58
  • In all three cases, servicing the page fault itself only involves transfers in memory (or even just remapping memory). In the third case, paging out would indeed involve accessing the disk, but that's another operation which doesn't have anything to do with the page fault: there's a marking operation, a separate paging out operation (which hasn't happened yet), and the page fault which causes the memory to be retrieved (so the page-out probably won't happen at all). Even in (3), servicing the page fault doesn't involve touching the disk (the data isn't there yet), so it's a minor page fault. Commented Jun 14, 2016 at 12:08
  • 1. why does "the page fault which causes the memory to be retrieved (so the page-out probably won't happen at all)"? 2. does auxiliary storage access that distinguish major from minor page fault only refer to data transfer from auxiliary storage to ram, not data transfer from ram to auxiliary storage e.g. to free up the page to let it accept new data?
    – Tim
    Commented Jun 14, 2016 at 14:28
3

A minor page fault happens for instance, when the data or code is in memory, but not mapped to the process.

Think of a share library, utilised by another process. Your process wants to load the same lib, so the ld (i think via libc/glibc?) issues generates a page fault. The kernel knows the data is already in mem, and maps it to the process. No need to load it from disk...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .