patch-2.0.33 linux/mm/vmscan.c

Next file: linux/net/ipv4/ip_forward.c
Previous file: linux/mm/vmalloc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.32/linux/mm/vmscan.c linux/mm/vmscan.c
@@ -328,6 +328,11 @@
 			shfrv =  8;
 			break;
 	}
+	/*
+	 * kswapd should be more friendly to other processes.
+	 */
+	if (kswapd_awake)
+		shfrv = 10;
 #endif
 
 	counter = ((PAGEOUT_WEIGHT * nr_tasks) >> shfrv) >> priority;
@@ -453,7 +458,7 @@
  */
 int kswapd(void *unused)
 {
-	int i, j;
+	int i, reserved_pages;
 	
 	current->session = 1;
 	current->pgrp = 1;
@@ -491,12 +496,15 @@
 		swapstats.wakeups++;
 		/* Protect our reserved pages: */
 		i = 0;
-		j = (min_free_pages >= 48 ? min_free_pages-12 : min_free_pages);
-		if (nr_free_pages <= j)
-			i = (1+j) - nr_free_pages;
+		reserved_pages = min_free_pages;
+		if (min_free_pages >= 48)
+			reserved_pages -= (12 + (reserved_pages>>3));
+		if (nr_free_pages <= reserved_pages)
+			i = (1+reserved_pages) - nr_free_pages;
 		/* Do the background pageout: */
 		for (i += kswapd_ctl.maxpages; i > 0; i--)
-			try_to_free_page(GFP_KERNEL, 0, (nr_free_pages <= j));
+			try_to_free_page(GFP_KERNEL, 0,
+					 (nr_free_pages <= min_free_pages));
 	}
 }
 

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