Index: linux-2.6.7-mm6/include/linux/swap.h =================================================================== --- linux-2.6.7-mm6.orig/include/linux/swap.h 2004-07-05 23:18:01.980100050 +1000 +++ linux-2.6.7-mm6/include/linux/swap.h 2004-07-05 23:19:20.614833487 +1000 @@ -175,7 +175,7 @@ extern int try_to_free_pages(struct zone **, unsigned int, unsigned int); extern int shrink_all_memory(int); extern int vm_swappiness; -extern int auto_swappiness; +extern int vm_autoregulate; #ifdef CONFIG_MMU /* linux/mm/shmem.c */ Index: linux-2.6.7-mm6/include/linux/sysctl.h =================================================================== --- linux-2.6.7-mm6.orig/include/linux/sysctl.h 2004-07-05 23:18:38.651379506 +1000 +++ linux-2.6.7-mm6/include/linux/sysctl.h 2004-07-05 23:19:42.367440258 +1000 @@ -167,7 +167,7 @@ VM_BLOCK_DUMP=24, /* block dump mode */ VM_HUGETLB_GROUP=25, /* permitted hugetlb group */ VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */ - VM_AUTO_SWAPPINESS=27, /* Make vm_swappiness autoregulated */ + VM_AUTOREGULATE=27, /* swappiness and inactivation autoregulated */ }; Index: linux-2.6.7-mm6/kernel/sysctl.c =================================================================== --- linux-2.6.7-mm6.orig/kernel/sysctl.c 2004-07-05 23:18:01.983099583 +1000 +++ linux-2.6.7-mm6/kernel/sysctl.c 2004-07-05 23:19:20.618832863 +1000 @@ -728,9 +728,9 @@ .extra2 = &one_hundred, }, { - .ctl_name = VM_AUTO_SWAPPINESS, - .procname = "autoswappiness", - .data = &auto_swappiness, + .ctl_name = VM_AUTOREGULATE, + .procname = "autoregulate", + .data = &vm_autoregulate, .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dointvec, Index: linux-2.6.7-mm6/mm/vmscan.c =================================================================== --- linux-2.6.7-mm6.orig/mm/vmscan.c 2004-07-05 23:18:01.984099427 +1000 +++ linux-2.6.7-mm6/mm/vmscan.c 2004-07-05 23:19:20.619832707 +1000 @@ -119,7 +119,8 @@ * From 0 .. 100. Higher means more swappy. */ int vm_swappiness = 60; -int auto_swappiness = 1; +int vm_autoregulate = 1; +static int app_percent = 1; static long total_memory; static LIST_HEAD(shrinker_list); @@ -650,7 +651,9 @@ long mapped_ratio; long distress; long swap_tendency; + struct sysinfo i; + si_meminfo(&i); lru_add_drain(); pgmoved = 0; spin_lock_irq(&zone->lru_lock); @@ -692,23 +695,21 @@ */ mapped_ratio = (sc->nr_mapped * 100) / total_memory; + /* + * app_percent is the percentage of physical ram used + * by application pages. + */ + si_meminfo(&i); #ifdef CONFIG_SWAP - if (auto_swappiness) { - int app_percent; - struct sysinfo i; - + app_percent = 100 - ((i.freeram + get_page_cache_size() - + swapper_space.nrpages) / (i.totalram / 100)); + + if (vm_autoregulate) { si_swapinfo(&i); if (likely(i.totalswap >= 100)) { int swap_centile; - /* - * app_percent is the percentage of physical ram used - * by application pages. - */ - si_meminfo(&i); - app_percent = 100 - ((i.freeram + get_page_cache_size() - - swapper_space.nrpages) / (i.totalram / 100)); /* * swap_centile is the percentage of the last (sizeof physical @@ -725,6 +726,9 @@ } else vm_swappiness = 0; } +#else + app_percent = 100 - ((i.freeram + get_page_cache_size()) / + (i.totalram / 100)); #endif /*