Index: linux-2.6.7-ck7/include/linux/swap.h
===================================================================
--- linux-2.6.7-ck7.orig/include/linux/swap.h	2004-06-16 15:18:55.000000000 +1000
+++ linux-2.6.7-ck7/include/linux/swap.h	2005-04-18 11:57:26.000000000 +1000
@@ -174,7 +174,8 @@ extern void swap_setup(void);
 /* linux/mm/vmscan.c */
 extern int try_to_free_pages(struct zone **, unsigned int, unsigned int);
 extern int shrink_all_memory(int);
-extern int vm_swappiness;
+extern int vm_mapped;
+extern int vm_hardmaplimit;
 
 #ifdef CONFIG_MMU
 /* linux/mm/shmem.c */
Index: linux-2.6.7-ck7/include/linux/sysctl.h
===================================================================
--- linux-2.6.7-ck7.orig/include/linux/sysctl.h	2005-04-18 11:56:09.000000000 +1000
+++ linux-2.6.7-ck7/include/linux/sysctl.h	2005-04-18 11:57:26.000000000 +1000
@@ -159,13 +159,14 @@ enum
 	VM_OVERCOMMIT_RATIO=16, /* percent of RAM to allow overcommit in */
 	VM_PAGEBUF=17,		/* struct: Control pagebuf parameters */
 	VM_HUGETLB_PAGES=18,	/* int: Number of available Huge Pages */
-	VM_SWAPPINESS=19,	/* Tendency to steal mapped memory */
+	VM_MAPPED=19,		/* percent mapped min while evicting cache */
 	VM_LOWER_ZONE_PROTECTION=20,/* Amount of protection of lower zones */
 	VM_MIN_FREE_KBYTES=21,	/* Minimum free kilobytes to maintain */
 	VM_MAX_MAP_COUNT=22,	/* int: Maximum number of mmaps/address-space */
 	VM_LAPTOP_MODE=23,	/* vm laptop mode */
 	VM_BLOCK_DUMP=24,	/* block dump mode */
 	VM_HUGETLB_GROUP=25,	/* permitted hugetlb group */
+	VM_HARDMAPLIMIT=26,	/* Make mapped a hard limit */
 };
 
 
Index: linux-2.6.7-ck7/kernel/sysctl.c
===================================================================
--- linux-2.6.7-ck7.orig/kernel/sysctl.c	2005-04-18 11:56:09.000000000 +1000
+++ linux-2.6.7-ck7/kernel/sysctl.c	2005-04-18 11:57:26.000000000 +1000
@@ -733,16 +733,24 @@ static ctl_table vm_table[] = {
 		.proc_handler	= &proc_dointvec,
 	},
 	{
-		.ctl_name	= VM_SWAPPINESS,
-		.procname	= "swappiness",
-		.data		= &vm_swappiness,
-		.maxlen		= sizeof(vm_swappiness),
+		.ctl_name	= VM_MAPPED,
+		.procname	= "mapped",
+		.data		= &vm_mapped,
+		.maxlen		= sizeof(vm_mapped),
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec_minmax,
 		.strategy	= &sysctl_intvec,
 		.extra1		= &zero,
 		.extra2		= &one_hundred,
 	},
+	{
+		.ctl_name	= VM_HARDMAPLIMIT,
+		.procname	= "hardmaplimit",
+		.data		= &vm_hardmaplimit,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+	},
 #ifdef CONFIG_HUGETLB_PAGE
 	 {
 		.ctl_name	= VM_HUGETLB_PAGES,
Index: linux-2.6.7-ck7/mm/vmscan.c
===================================================================
--- linux-2.6.7-ck7.orig/mm/vmscan.c	2004-06-16 15:18:58.000000000 +1000
+++ linux-2.6.7-ck7/mm/vmscan.c	2005-04-18 11:57:26.000000000 +1000
@@ -39,10 +39,8 @@
 
 #include <linux/swapops.h>
 
-/*
- * From 0 .. 100.  Higher means more swappy.
- */
-int vm_swappiness = 60;
+int vm_mapped = 66;
+int vm_hardmaplimit = 1;
 static long total_memory;
 
 #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
@@ -695,11 +693,15 @@ refill_inactive_zone(struct zone *zone, 
 	 * ratio is downgraded - just because there's a lot of mapped memory
 	 * doesn't necessarily mean that page reclaim isn't succeeding.
 	 *
-	 * The distress ratio is important - we don't want to start going oom.
+ 	 * The distress ratio is important - we don't want to start going oom.
+	 * This distress value is ignored if we apply a hardmaplimit except
+	 * in extreme distress.
 	 *
-	 * A 100% value of vm_swappiness overrides this algorithm altogether.
+	 * A 0% value of vm_mapped overrides this algorithm altogether.
 	 */
-	swap_tendency = mapped_ratio / 2 + distress + vm_swappiness;
+	swap_tendency = mapped_ratio * 100 / (vm_mapped + 1);
+	if (!vm_hardmaplimit || distress == 100)
+		swap_tendency += distress;
 
 	/*
 	 * Now use this metric to decide whether to start moving mapped memory
@@ -1009,12 +1011,22 @@ static int balance_pgdat(pg_data_t *pgda
 			 */
 			for (i = pgdat->nr_zones - 1; i >= 0; i--) {
 				struct zone *zone = pgdat->node_zones + i;
+				unsigned long watermark = zone->pages_high;
 
 				if (zone->all_unreclaimable &&
 						priority != DEF_PRIORITY)
 					continue;
 
-				if (zone->free_pages <= zone->pages_high) {
+				/*
+				 * The watermark is relaxed depending on the
+				 * level of "priority" till it drops to
+				 * pages_high.
+				 */
+				watermark += (zone->pages_high * priority /
+					DEF_PRIORITY);
+
+
+				if (zone->free_pages <= watermark) {
 					end_zone = i;
 					goto scan;
 				}

