Swapping in Pages
Swap in must take place when a process attempts to address a page within its address space that has been swapped out to disk. The Page Fault exception handler triggers a swap-in operation when the following conditions occur (see Section 8.4.2):
The page including the address that caused the exception is a valid one—that is, it belongs to a memory region of the current process.
The page is not present in memory—that is, the
Presentflag in the Page Table entry is cleared.The Page Table entry associated with the page is not null, which means it contains a swapped-out page identifier.
As described in Section 8.4.3, the
handle_pte_fault( ) function, invoked by the
do_page_fault( ) exception handler, checks whether
the Page Table entry is non-null. If so, it invokes a quite handy
do_swap_page( ) function to swap in the page
required.
The do_swap_page( ) Function
This do_swap_page( ) function acts on the
following parameters:
-
mm Memory descriptor address of the process that caused the Page Fault exception
-
vma Memory region descriptor address of the region that includes
address-
address Linear address that causes the exception
-
page_table Address of the Page Table entry that maps
address-
orig_pte Content of the Page Table entry that maps
address-
write_access Flag denoting whether the attempted access was a read or a write
Contrary to other functions, do_swap_page( ) never returns 0. It returns 1 if the page is already in the swap cache (minor fault), 2 if the page ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access