Swapping
kswapd (the kernel swap daemon)
- Periodically frees page frames by flushing dirty pages to disk
- Swaps pages from the tail of the inactive list
- First determines if the page has a valid entry in the swap cache
- Enables clean pages to be freed immediately
- Cannot free a page frame if
- Page is shared
- kswapd must unmap multiple references to the page
- Reverse mapping improves efficiency
- Page is dirty
- kswapd must flush it to disk
- Performed asynchronously by pdflush
- Page is locked (e.g., currently under I/O)
- kswapd must wait until page is unlocked