logo
Published on KernelTrap (http://kerneltrap.org)

Linux: Swap Pre-Fetching

By Jeremy
Created Sep 2 2005 - 08:33

Con Kolivas [interview [1]] posted a patch for the 2.6.13 kernel [story [2]] that implements cache prefetching. The patch is based on earlier work [3] by Thomas Schlichter. Con explains, "I have resuscitated and rewritten some early prefetch code Thomas Schlichter did in late 2.5 to create a configurable kernel thread that reads in swap from ram in reverse order it was written out. It does this once kswapd has been idle for a minute (implying no current vm stress)." He goes on to explain, "Note that swapped in pages are kept on backing store (swap), meaning no further I/O is required if the page needs to swap back out."

Con noted that the patch will be included in his next -ck patchset [story [4]], however, he also posted it to the lkml to guage interest in eventually merging the effort into the mainline kernel, and to encourage greater testing and feedback.


From: Con Kolivas [5] [email blocked]
To: linux kernel mailing list [email blocked]
Subject: [PATCH][RFC] vm: swap prefetch
Date:	Thu, 1 Sep 2005 23:46:32 +1000

Here is a working swap prefetching patch for 2.6.13. I have resuscitated and 
rewritten some early prefetch code Thomas Schlichter did in late 2.5 to 
create a configurable kernel thread that reads in swap from ram in reverse 
order it was written out. It does this once kswapd has been idle for a minute 
(implying no current vm stress). This patch attached below is a rollup of two 
patches the current versions of which are here:

http://ck.kolivas.org/patches/swap-prefetch/ [6]

These add an exclusive_timer function, and the patch that does the swap 
prefetching. I'm posting this rollup to lkml to see what the interest is in 
this feature, and for people to test it if they desire. I'm planning on 
including it in the next -ck but wanted to gauge general user opinion for 
mainline. Note that swapped in pages are kept on backing store (swap), 
meaning no further I/O is required if the page needs to swap back out.

Cheers,
Con Kolivas


From: Hans Kristian Rosbach [email blocked] Subject: Re: [PATCH][RFC] vm: swap prefetch Date: Thu, 01 Sep 2005 16:18:23 +0200 On Thu, 2005-09-01 at 23:46 +1000, Con Kolivas wrote: > Here is a working swap prefetching patch for 2.6.13. I have resuscitated and > rewritten some early prefetch code Thomas Schlichter did in late 2.5 to > create a configurable kernel thread that reads in swap from ram in reverse > order it was written out. It does this once kswapd has been idle for a minute > (implying no current vm stress). This patch attached below is a rollup of two > patches the current versions of which are here: > > http://ck.kolivas.org/patches/swap-prefetch/ [7] > > These add an exclusive_timer function, and the patch that does the swap > prefetching. I'm posting this rollup to lkml to see what the interest is in > this feature, and for people to test it if they desire. I'm planning on > including it in the next -ck but wanted to gauge general user opinion for > mainline. Note that swapped in pages are kept on backing store (swap), > meaning no further I/O is required if the page needs to swap back out. I would definitely use this if available. That said, I have often thought it might be good to have something like pre-writing swap, ie reverse what your patch does. In other words it'd keep as much of swappable data on disk as possible, but without removing it from memory. So when it comes time to free up some memory, the data is already on disk so no performance penalty from writing it out. Hopefully something worth thinking about. -HK
From: Con Kolivas [8] [email blocked] Subject: Re: [PATCH][RFC] vm: swap prefetch Date: Fri, 2 Sep 2005 00:18:32 +1000 On Fri, 2 Sep 2005 00:18, Hans Kristian Rosbach wrote: > On Thu, 2005-09-01 at 23:46 +1000, Con Kolivas wrote: > > > > These add an exclusive_timer function, and the patch that does the swap > > prefetching. I'm posting this rollup to lkml to see what the interest is > > in this feature, and for people to test it if they desire. I'm planning > > on including it in the next -ck but wanted to gauge general user opinion > > for mainline. Note that swapped in pages are kept on backing store > > (swap), meaning no further I/O is required if the page needs to swap back > > out. > > I would definitely use this if available. Great. > That said, I have often thought it might be good to have something like > pre-writing swap, ie reverse what your patch does. > > In other words it'd keep as much of swappable data on disk as possible, > but without removing it from memory. So when it comes time to free up > some memory, the data is already on disk so no performance penalty from > writing it out. > > Hopefully something worth thinking about. Actually to some degree this patch does that, albeit only on things that are swapped out "naturally". Anything that is swapped out and is unnaturally swapped back in using prefetching is kept on swap, and you often find much more swap sitting around ready for freeing up ram whenever there is memory pressure again. Cheers, Con
From: Thomas Schlichter <thomas.schlichter@web.de> Subject: Re: [PATCH][RFC] vm: swap prefetch Date: Thu, 1 Sep 2005 17:15:36 +0200 Hi Con! Am Donnerstag, 1. September 2005 15:46 schrieb Con Kolivas: > Here is a working swap prefetching patch for 2.6.13. I have resuscitated > and rewritten some early prefetch code Thomas Schlichter did in late 2.5 to > create a configurable kernel thread that reads in swap from ram in reverse > order it was written out. It does this once kswapd has been idle for a > minute (implying no current vm stress). This patch attached below is a > rollup of two patches the current versions of which are here: > > http://ck.kolivas.org/patches/swap-prefetch/ [9] > > These add an exclusive_timer function, and the patch that does the swap > prefetching. I'm posting this rollup to lkml to see what the interest is in > this feature, and for people to test it if they desire. I'm planning on > including it in the next -ck but wanted to gauge general user opinion for > mainline. Note that swapped in pages are kept on backing store (swap), > meaning no further I/O is required if the page needs to swap back out. I am (and some of my friends are) still interested in this functionality, so I'm definitly going to test your improved patch, of course. By the way, I'm quite happy that you came up with this new version of swap-prefetching, because I didn't and still don't have the time to develop or maintain it more... So thanks for your good work, and keep on helping Linux-Desktop-Users! :-) Thomas



Related Links:


Source URL:
http://kerneltrap.org/node/5619