On Mon, 23 Apr 2001, Rik van Riel wrote: > There seems to be one more reason, take a look at the function > read_swap_cache_async() in swap_state.c, around line 240: you are right - i thought about that issue too and assumed it works like the pagecache (which first reads the page without hashing it, then tries to add the result to the pagecache and throws away the page if anyone else finished it already), but that was incorrect. i think the swapcache's behavior is actually the more correct one, and the pagecache should first hash pending reads, then start the IO. If someone else tries to read the page and the page is not uptodate and locked, then we should sleep on the page's waitqueue. End-of-page-IO or PageError should then unlock the page and wake up all waiters. [which happens already] several processes trying to read the same page is a legitimate scenario, and should not result in multiple reads done on the same disk area. Besides the (albeit small) performance win, IMO this is also a quality of implementation issue, even if the window is small. (the window might be not that small in some cases like NFS?) i've fixed the patch so that it checks Page_Uptodate() within __find_get_swapcache_page(). The only case i'm not convinced about is the case of IO errors, but otherwise this should work. I've also fixed an SMP-only bug in the new __find_get_swapcache_page() function: it must not run __find_page_nolock() with the LRU lock held. i've attached swap-speedup-2.4.3-A2 which has these fixes included. > OTOH, no matter how fast we make the current functionality, there will > always be some point at which the system is so overloaded that no > paging system can help save it from thrashing. agreed - but this should really be the last resort, and i'm still worried about potentially hiding real performance bugs. > Btw, to test this ... try running 10 copies of gnuchess playing > against itself on a machine with 64 MB of RAM. You'll go under > thrashing pretty quickly. thanks, i'll try that. (do you have any easy oneliner command line to start up gnuchess against itself?) Ingo