patch-2.1.33 linux/mm/vmscan.c

Next file: linux/net/core/dev.c
Previous file: linux/kernel/sysctl.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.32/linux/mm/vmscan.c linux/mm/vmscan.c
@@ -5,6 +5,8 @@
  *
  *  Swap reorganised 29.12.95, Stephen Tweedie.
  *  kswapd added: 7.1.96  sct
+ *  Removed kswapd_ctl limits, and swap out as many pages as needed
+ *  to bring the system back to free_pages_high: 2.4.97, Rik van Riel.
  *  Version: $Id: vmscan.c,v 1.21 1997/01/06 06:54:03 davem Exp $
  */
 
@@ -49,12 +51,6 @@
  */
 static int kswapd_awake = 0;
 
-/*
- * sysctl-modifiable parameters to control the aggressiveness of the
- * page-searching within the kswapd page recovery daemon.
- */
-kswapd_control_t kswapd_ctl = {4, -1, -1, -1, -1};
-
 static void init_swap_timer(void);
 
 /*
@@ -409,8 +405,16 @@
 		interruptible_sleep_on(&kswapd_wait);
 		kswapd_awake = 1;
 		swapstats.wakeups++;
-		/* Do the background pageout: */
-		for (i=0; i < kswapd_ctl.maxpages; i++)
+		/* Do the background pageout: 
+		 * We now only swap out as many pages as needed.
+		 * When we are truly low on memory, we swap out
+		 * synchronously (WAIT == 1).  -- Rik.
+		 */
+		while(nr_free_pages < min_free_pages)
+			try_to_free_page(GFP_KERNEL, 0, 1);
+		while((nr_free_pages + nr_async_pages) < free_pages_low)
+			try_to_free_page(GFP_KERNEL, 0, 1);
+		while((nr_free_pages + nr_async_pages) < free_pages_high)
 			try_to_free_page(GFP_KERNEL, 0, 0);
 	}
 }
@@ -436,12 +440,16 @@
 		want_wakeup = 1;
 	}
 
-	if (want_wakeup) {
-		if (!kswapd_awake && kswapd_ctl.maxpages > 0) {
+	if (want_wakeup) { 
+		if (!kswapd_awake) {
 			wake_up(&kswapd_wait);
 			need_resched = 1;
 		}
-		next_swap_jiffies = jiffies + swapout_interval;
+		/* low on memory, we need to start swapping soon */
+		if(last_wakeup_low) 
+			next_swap_jiffies = jiffies;
+		else  
+			next_swap_jiffies = jiffies + swapout_interval;
 	}
 	timer_active |= (1<<SWAP_TIMER);
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov