public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm - swap prefetch magnify
@ 2005-10-22  1:20 Con Kolivas
  2005-10-22  1:47 ` Con Kolivas
  0 siblings, 1 reply; 4+ messages in thread
From: Con Kolivas @ 2005-10-22  1:20 UTC (permalink / raw)
  To: linux kernel mailing list; +Cc: Andrew Morton, ck list

[-- Attachment #1: Type: text/plain, Size: 72 bytes --]

Testing has confirmed much larger prefetch values work well.

Con
---



[-- Attachment #2: mm-swap_prefetch_magnify.patch --]
[-- Type: text/x-diff, Size: 1741 bytes --]

The current number of pages prefetched by swap_prefetch is very gentle, and
we are very cautious about whether prefetching is appropriate or not so we
can increase the size substantially.

Make the prefetch size magnitudes larger, being proportional to memory size
instead of the square root of it.

Fix the last_free calculation to work better with larger prefetch sizes.

Signed-off-by: Con Kolivas <kernel@kolivas.org>

Index: linux-2.6.14-rc5-ck1/mm/swap_prefetch.c
===================================================================
--- linux-2.6.14-rc5-ck1.orig/mm/swap_prefetch.c	2005-10-22 10:14:26.000000000 +1000
+++ linux-2.6.14-rc5-ck1/mm/swap_prefetch.c	2005-10-22 10:36:30.000000000 +1000
@@ -24,7 +24,7 @@
 #define PREFETCH_INTERVAL (HZ)
 
 /* sysctl - how many SWAP_CLUSTER_MAX pages to prefetch at a time */
-int swap_prefetch = 1;
+int swap_prefetch;
 
 struct swapped_root {
 	unsigned long		busy;		/* vm busy */
@@ -71,9 +71,7 @@ void __init prepare_prefetch(void)
 	mapped_limit = mem / 3 * 2;
 
 	/* Set initial swap_prefetch value according to memory size */
-	mem /= SWAP_CLUSTER_MAX * 1000;
-	while ((mem >>= 1))
-		swap_prefetch++;
+	swap_prefetch = mem / 10000;
 }
 
 /*
@@ -307,10 +305,9 @@ static int prefetch_suitable(void)
 	 * (eg during file reads)
 	 */
 	if (last_free) {
-		if (temp_free + SWAP_CLUSTER_MAX + prefetch_pages() <
-			last_free) {
-				last_free = temp_free;
-				goto out;
+		if (temp_free + SWAP_CLUSTER_MAX < last_free) {
+			last_free = temp_free;
+			goto out;
 		}
 	} else
 		last_free = temp_free;
@@ -375,6 +372,7 @@ static enum trickle_return trickle_swap(
 		case TRICKLE_FAILED:
 			break;
 		case TRICKLE_SUCCESS:
+			last_free--;
 			pages++;
 			break;
 		case TRICKLE_DELAY:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm - swap prefetch magnify
  2005-10-22  1:20 [PATCH] mm - swap prefetch magnify Con Kolivas
@ 2005-10-22  1:47 ` Con Kolivas
  2005-10-22  9:41   ` Paolo Ciarrocchi
  0 siblings, 1 reply; 4+ messages in thread
From: Con Kolivas @ 2005-10-22  1:47 UTC (permalink / raw)
  To: linux kernel mailing list; +Cc: Andrew Morton, ck list

[-- Attachment #1: Type: text/plain, Size: 231 bytes --]

On Sat, 22 Oct 2005 11:20, Con Kolivas wrote:
> Testing has confirmed much larger prefetch values work well.

Bah.. Sorry take this one instead. Just make sure that no matter how little 
ram we have prefetch is enabled.

Con
---



[-- Attachment #2: mm-swap_prefetch_magnify-1.patch --]
[-- Type: text/x-diff, Size: 1747 bytes --]

The current number of pages prefetched by swap_prefetch is very gentle, and
we are very cautious about whether prefetching is appropriate or not so we
can increase the size substantially.

Make the prefetch size magnitudes larger, being proportional to memory size
instead of the square root of it.

Fix the last_free calculation to work better with larger prefetch sizes.

Signed-off-by: Con Kolivas <kernel@kolivas.org>

Index: linux-2.6.14-rc5-ck1/mm/swap_prefetch.c
===================================================================
--- linux-2.6.14-rc5-ck1.orig/mm/swap_prefetch.c	2005-10-22 10:14:26.000000000 +1000
+++ linux-2.6.14-rc5-ck1/mm/swap_prefetch.c	2005-10-22 10:36:30.000000000 +1000
@@ -24,7 +24,7 @@
 #define PREFETCH_INTERVAL (HZ)
 
 /* sysctl - how many SWAP_CLUSTER_MAX pages to prefetch at a time */
-int swap_prefetch = 1;
+int swap_prefetch;
 
 struct swapped_root {
 	unsigned long		busy;		/* vm busy */
@@ -71,9 +71,7 @@ void __init prepare_prefetch(void)
 	mapped_limit = mem / 3 * 2;
 
 	/* Set initial swap_prefetch value according to memory size */
-	mem /= SWAP_CLUSTER_MAX * 1000;
-	while ((mem >>= 1))
-		swap_prefetch++;
+	swap_prefetch = mem / 10000 ? : 1;
 }
 
 /*
@@ -307,10 +305,9 @@ static int prefetch_suitable(void)
 	 * (eg during file reads)
 	 */
 	if (last_free) {
-		if (temp_free + SWAP_CLUSTER_MAX + prefetch_pages() <
-			last_free) {
-				last_free = temp_free;
-				goto out;
+		if (temp_free + SWAP_CLUSTER_MAX < last_free) {
+			last_free = temp_free;
+			goto out;
 		}
 	} else
 		last_free = temp_free;
@@ -375,6 +372,7 @@ static enum trickle_return trickle_swap(
 		case TRICKLE_FAILED:
 			break;
 		case TRICKLE_SUCCESS:
+			last_free--;
 			pages++;
 			break;
 		case TRICKLE_DELAY:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm - swap prefetch magnify
  2005-10-22  1:47 ` Con Kolivas
@ 2005-10-22  9:41   ` Paolo Ciarrocchi
  2005-10-22 15:21     ` Con Kolivas
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Ciarrocchi @ 2005-10-22  9:41 UTC (permalink / raw)
  To: Con Kolivas; +Cc: linux kernel mailing list, Andrew Morton, ck list

On 10/22/05, Con Kolivas <kernel@kolivas.org> wrote:
> On Sat, 22 Oct 2005 11:20, Con Kolivas wrote:
> > Testing has confirmed much larger prefetch values work well.
>
> Bah.. Sorry take this one instead. Just make sure that no matter how little
> ram we have prefetch is enabled.

Con,
would you be so kind to post more information about the test you've done ?

--
Paolo
Pleas click here: http://heracleum.altervista.org/top/site.php?vote=488
to support http://technologynews.altervista.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm - swap prefetch magnify
  2005-10-22  9:41   ` Paolo Ciarrocchi
@ 2005-10-22 15:21     ` Con Kolivas
  0 siblings, 0 replies; 4+ messages in thread
From: Con Kolivas @ 2005-10-22 15:21 UTC (permalink / raw)
  To: Paolo Ciarrocchi; +Cc: linux kernel mailing list, Andrew Morton, ck list

On Sat, 22 Oct 2005 19:41, Paolo Ciarrocchi wrote:
> On 10/22/05, Con Kolivas <kernel@kolivas.org> wrote:
> > On Sat, 22 Oct 2005 11:20, Con Kolivas wrote:
> > > Testing has confirmed much larger prefetch values work well.
> >
> > Bah.. Sorry take this one instead. Just make sure that no matter how
> > little ram we have prefetch is enabled.
>
> Con,
> would you be so kind to post more information about the test you've done ?

My concern was to not cause a detriment to performance in any noticeable way. 
The prefetch sizes were tested on a number of machines with different speed 
hard drive / ram size combinations to ensure none of the default values ever 
caused any significant I/O wait, or that heavy memory requiring compiles took 
any longer to complete as these constantly need new ram allocations and I 
wanted to ensure that prefetching into ram didn't slow down those 
allocations. Furthermore, the time taken to actually prefetch the application 
is now more than 5 times faster because of the larger default prefetch 
values.

Cheers,
Con

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-22 15:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-22  1:20 [PATCH] mm - swap prefetch magnify Con Kolivas
2005-10-22  1:47 ` Con Kolivas
2005-10-22  9:41   ` Paolo Ciarrocchi
2005-10-22 15:21     ` Con Kolivas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox