After this documentation was released in July 2003, I was approached
by Prentice Hall and asked to write a book on the Linux VM under the Bruce Peren's Open Book Series.
The book is available and called simply "Understanding The Linux Virtual
Memory Manager". There is a lot of additional material in the book that is
not available here, including details on later 2.4 kernels, introductions
to 2.6, a whole new chapter on the shared memory filesystem, coverage of TLB
management, a lot more code commentary, countless other additions and
clarifications and a CD with lots of cool stuff on it. This material (although
now dated and lacking in comparison to the book) will remain available
although I obviously encourge you to buy the book from your favourite book
store :-) . As the book is under the Bruce Perens Open Book Series, it will
be available 90 days after appearing on the book shelves which means it
is not available right now. When it is available, it will be downloadable
from http://www.phptr.com/perens
so check there for more information.
To be fully clear, this webpage is not the actual book.
Next: 13. Out Of Memory
Up: 12. Swap Management
Previous: 12.8 Swapping Out Pages
  Contents
  Index
The top-level function for reading and writing to the swap area is
rw_swap_page(). This function ensures that all operations are
performed through the swap cache to prevent lost updates.
rw_swap_page_base() is the core function which performs the real
work.
It begins by checking if the operation is a read. If it is, it clears
the uptodate flag with ClearPageUptodate(). This flag will
be set again if the page is successfully read from disk. It then calls
get_swaphandle_info() to acquire the device for the swap partition
of the inode for the file. These are needed before block IO operations may
be performed.
If the swap area is a file, bmap() is used to fill a local
array with a list of all blocks in the filesystem which contain the page
being operated on. Remember that filesystems may have their own method of
storing files and disk and it is not as simple as the swap partition where
information may be written directly to disk.
Once that is complete, a normal block IO operation takes place with
brw_page(). The function of block IO is beyond the scope of
this document.
Next: 13. Out Of Memory
Up: 12. Swap Management
Previous: 12.8 Swapping Out Pages
  Contents
  Index
Mel
2004-02-15