Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a page fault causes the faulting process to reschedule?

In Linux, when a process try to access a page that doesn't have a current physical mapping (missing page table entry), a page fault is generated (by CPU). This causes Linux's page fault handler to be invoked. If this fault is "major", meaning Linux has to read the page from the swap device, the handler has to read from the actual disk in this case. Since reading from a disk is asynchronous (submit_bio), does this cause the process to reschedule? (And wake up when I/O is complete?)

If reschedule does happen, where is the call to "schedule()"? Reading the code in mm/swap_state.c doesn't give me a clue as to when (or if) this happens.

like image 840
dividebyzero Avatar asked Nov 18 '12 15:11

dividebyzero


1 Answers

If a page is not in the physical memory the process blocks until the page is read, I think you're looking in the wrong place schedule should be in the page fault handler or whatever function it calls. There are more information in section 9.4. "Page Fault Exception Handler" of "Understanding the Linux Kernel" book, I quote:

The handle_mm_fault( ) function returns VM_FAULT_MINOR or VM_FAULT_MAJOR if it succeeded in allocating a new page frame for the process. The value VM_FAULT_MINOR indicates that the Page Fault has been handled without blocking the current process; this kind of Page Fault is called minor fault. The value VM_FAULT_MAJOR indicates that the Page Fault forced the current process to sleep

like image 126
iabdalkader Avatar answered Oct 16 '22 23:10

iabdalkader