next up previous contents
Next: Processes Up: Linux Virtual Memory Algorithms Previous: Swapping Out Shared Pages

Swapping Pages In (Demand Paging)

    When a process attempts to access data in page which is not in physical memory a page fault will occur. How this is reported by the CPU is architecture specific and system specific code is used to package the event and hand it off to architecture independent portion of the Linux kernel. Whatever architecture Linux is running on, the page fault handler is called.

The relevant Page Table Entry is examined and if it is an invalid entry there are three possible ways of dealing with it:

Page in swap
If the PTE is marked as ``page in swap'' gif then the page must be read from the swap file and the swap_cache  and PTE updated. DAR: Extend - how is the dirty bit set and why, sometimes the swap cache entry is deleted

Shared Page in swap
Shared pages in the swap file are handled separately from non-shared pages.

A physical page is allocated and the page is read into it from the swap file using the swap file information in the PTE and the information held in the swap_info_struct  tree for the swap file. As the page is a shared page, the page tables for all of the processes sharing that virtual memory must be updated to show that the page now exists in physical memory again.

Executable Image Page
If the PTE is not marked as being in swap, the appropriate page from the executable image is brought into memory and the PTE updated to reflect the newly allocated and filled physical page. However the page is brought into memory, a new PTE is created for that page and the TLB is updated to reflect the page table changes that have been made.


next up previous contents
Next: Processes Up: Linux Virtual Memory Algorithms Previous: Swapping Out Shared Pages

David A. Rusling
david.rusling@reo.mts.dec.com