There is just one case in which the kernel wants to read a page from a swap area without putting it in the swap cache. This happens when servicing the swapon( ) system call: the kernel reads the first page of a swap area, which contains the swap_header union, and then immediately discards the page frame. Since the kernel is activating the swap area, no process can swap in or swap out a page on it, so there is no need to protect the access to the page slot.
The rw_swap_page_nolock ( ) function receives as parameters the type of I/O operation (read or write), a swapped-out page identifier, and the address of a page frame (already locked). It performs the following operations:
1. Gets the page descriptor of the page frame passed as a parameter.
2. Initializes the swapping field of the page descriptor with the address of the swapper_space object; this is done because the sync_page method is executed in Step 4.
3. Invokes rw_swap_page_base( ) to start the I/O swap operation.
4. Waits until the I/O data transfer completes by invoking wait_on_page( ).
5. Unlocks the page.
6. Sets the mapping field of the page descriptor to null and returns.
I [email protected] RuBoard wmam
Was this article helpful?