LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Explanation of writepage/readpage in Linux swapping. (https://www.linuxquestions.org/questions/linux-kernel-70/explanation-of-writepage-readpage-in-linux-swapping-4175465087/)

ehabababneh 06-07-2013 04:44 AM

Explanation of writepage/readpage in Linux swapping.
 
Hello there,

I need to understand how swapped out dirty pages are written to block devices (specifically swap partition in a hard drive). where is the code that actually does that?

To make myself even clearer: I need to fill in the gap in the the sequence of function calls when reading a page as a result of page fault handling...

do_page_fault -> __do_page_fault -> handle_mm_fault -> handle_pte_fault -> do_swap_page -> swapin_readahead -> read_swap_cache_async -> swap_readpage -> ???? -> (read from disk)

also, I need to know how the page is actually read from the disk ... for example, what is exactly read from the disk? is it only the page content? or is there also some other meta data that is read as well?

* misc info: arch = amd64, Linux version = 3.X, backing store for swap is a Linux Swap partition (do not care about files or anything else).


I would love also to know the sequence of function calls for writing a dirty page as well...in a similar fashion to the above. I have read the Linux documentation and I have a good idea how the memory is managed (active/inactive lists, kswapd..etc.).

My end goal is to add support to additional types of storage devices for swapping. For example, assume I would like to swap pages out to/swap in pages from other types of storage media.

Thanks.

frankbell 06-08-2013 05:47 PM

I don't know enough to begin to answer your question, but the Interactive Kernel Map might be a good place to start.

Look in the column labeled "Storage."

syg00 06-09-2013 03:56 AM

Since before the 2.6 kernel stream the "swap" was changed to use standard disk pdflush/bdi facilities. This was when the different performance between a swap on partition and swap as a file disappeared.

So long as a block device driver exists to manage the device, I wouldn't expect you have to do anything. If mkswap and swapon are happy to talk to your device, I can't see why kswapd would care.
(all supposition - I started looking at swap management years ago, but got side-tracked).


All times are GMT -5. The time now is 06:07 AM.