[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on swapping



Hi Martin,

On going thru the code, I could think of this answer to your 
question.(unfortunately my kernel version is 2.4.2 but I guess 
logic may still hold good; anyway) The function try_to_swap_out 
gets called ultimately from refill_inactive() which goes thru the 
list of inactive pages and flushes them to swap. refill_inactive() 
is called from do_try_to_free_pages() but before that page_launder 
is invoked. page launder makes sure that the pages in inactive 
clean list, swap cache and disk are in sync. So after that when 
try_to_swap_out() gets called, it need not bother about dirty 
pages.

But I have my own doubts on swapping which I would like to get 
cleared. I am unable to get the reason why at all a shared page 
gets transferred to the disk as long as it is in use.

Why won't the following steps work:
(i) In case the page is shared and the 1st time try_to_swap_out() 
is called : the page is transferred to swap cache and 
__free_page() is called the page count is not zero. Then do not 
transfer the page to disk.
(ii) When the last process that shared the page calls 
try_to_swap_out: the pagecount hits 0. Then transfer the page to 
disk.
This way for shared pages only one disk transer(which is 
expensive) gets done for shared pages.

My 2 bits
Raghav

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/