Skip to contentSkip to conversation

mm: swap prefetch increase aggressiveness and tunability

PATCH New Con Kolivas 1 participant 1 message May 26, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: swap prefetch increase aggressiveness and tunability

Swap prefetch is currently too lax in prefetching with extended idle periods unused. Increase its aggressiveness and tunability.

Make it possible for swap_prefetch to be set to a high value ignoring load and prefetching regardless.

Add tunables to modify the swap prefetch delay and sleep period on the fly, and decrease both periods to 1 and 5 seconds respectively. Extended periods did not decrease the impact any further but greatly diminished the rate ram was prefetched.

Remove the prefetch_watermark that left free ram unused. The impact of using the free ram with prefetched pages being put on the tail end of the inactive list would be minimal and potentially very beneficial, yet testing the pagestate adds unnecessary expense.

Put kprefetchd to sleep if the low watermarks are hit instead of delaying it.

Increase the maxcount as the lazy removal of swapped entries means we can easily have many stale entries and not enough entries for good swap prefetch.

Do not delay prefetch in cond_resched() returning positive. That was pointless and frequently put kprefetchd to sleep for no reason.

Update comments and documentation.

---
 Documentation/sysctl/vm.txt   |   33 +++++++-
 include/linux/swap-prefetch.h |    3 
 kernel/sysctl.c               |   16 ++++
 mm/swap_prefetch.c            |  164 +++++++++++++++++-------------------------
 4 files changed, 117 insertions(+), 99 deletions(-)
include/linux/swap-prefetch.h +3 -0
Index: linux-2.6.22-rc2-mm1/include/linux/swap-prefetch.h
===================================================================
@@ -4,6 +4,9 @@
 #ifdef CONFIG_SWAP_PREFETCH
 /* mm/swap_prefetch.c */
 extern int swap_prefetch;
+extern int swap_prefetch_delay;
+extern int swap_prefetch_sleep;
+
 struct swapped_entry {
 	swp_entry_t		swp_entry;	/* The actual swap entry */
 	struct list_head	swapped_list;	/* Linked list of entries */
kernel/sysctl.c +16 -0
Index: linux-2.6.22-rc2-mm1/kernel/sysctl.c
===================================================================
@@ -978,6 +978,22 @@ static ctl_table vm_table[] = {
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "swap_prefetch_delay",
+		.data		= &swap_prefetch_delay,
+		.maxlen		= sizeof(swap_prefetch_delay),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
+	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "swap_prefetch_sleep",
+		.data		= &swap_prefetch_sleep,
+		.maxlen		= sizeof(swap_prefetch_sleep),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
 #endif
 	{ .ctl_name = 0 }
 };
mm/swap_prefetch.c +70 -94

285 lines not on this page · raw message

Documentation/sysctl/vm.txt +28 -5
Index: linux-2.6.22-rc2-mm1/Documentation/sysctl/vm.txt
===================================================================
@@ -33,6 +33,8 @@ Currently, these files are in /proc/sys/
 - panic_on_oom
 - numa_zonelist_order
 - swap_prefetch
+- swap_prefetch_delay
+- swap_prefetch_sleep
 
 ==============================================================
 
@@ -270,10 +272,31 @@ this is causing problems for your system
 swap_prefetch
 
 This enables or disables the swap prefetching feature. When the virtual
-memory subsystem has been extremely idle for at least 5 seconds it will start
-copying back pages from swap into the swapcache and keep a copy in swap. In
-practice it can take many minutes before the vm is idle enough. A value of 0
-disables swap prefetching, 1 enables it unless laptop_mode is enabled, and 2
-enables it even in the presence of laptop_mode.
+memory subsystem has been extremely idle for at least swap_prefetch_sleep
+seconds it will start copying back pages from swap into the swapcache and keep
+a copy in swap. Valid values are 0 - 3. A value of 0 disables swap
+prefetching, 1 enables it unless laptop_mode is enabled, 2 enables it in the
+presence of laptop_mode, and 3 enables it unconditionally, ignoring whether
+the system is idle or not. If set to 0, swap prefetch wil not even try to keep
+record of ram swapped out to have the most minimal impact on performance.
 
 The default value is 1.
+
+==============================================================
+
+swap_prefetch_delay
+
+This is the time in seconds that swap prefetching is delayed upon finding
+the system is not idle (ie the vm is busy or non-niced cpu load is present).
+
+The default value is 1.
+
+==============================================================
+
+swap_prefetch_sleep
+
+This is the time in seconds that the swap prefetch kernel thread is put to
+sleep for when the ram is found to be full and it is unable to prefetch
+further.
+
+The default value is 5.
Signature · 7 lines
-ck

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>