diff -Naurp linux-2.6.0-test9-base/kernel/sysctl.c linux-2.6.0-test9-am-4/kernel/sysctl.c --- linux-2.6.0-test9-base/kernel/sysctl.c 2003-10-26 07:56:47.000000000 +1100 +++ linux-2.6.0-test9-am-4/kernel/sysctl.c 2003-11-03 00:57:34.000000000 +1100 @@ -659,17 +659,6 @@ static ctl_table vm_table[] = { .mode = 0444 /* read-only*/, .proc_handler = &proc_dointvec, }, - { - .ctl_name = VM_SWAPPINESS, - .procname = "swappiness", - .data = &vm_swappiness, - .maxlen = sizeof(vm_swappiness), - .mode = 0644, - .proc_handler = &proc_dointvec_minmax, - .strategy = &sysctl_intvec, - .extra1 = &zero, - .extra2 = &one_hundred, - }, #ifdef CONFIG_HUGETLB_PAGE { .ctl_name = VM_HUGETLB_PAGES, diff -Naurp linux-2.6.0-test9-base/mm/vmscan.c linux-2.6.0-test9-am-4/mm/vmscan.c --- linux-2.6.0-test9-base/mm/vmscan.c 2003-10-26 07:56:34.000000000 +1100 +++ linux-2.6.0-test9-am-4/mm/vmscan.c 2003-11-03 01:12:53.673290365 +1100 @@ -44,10 +44,6 @@ */ #define DEF_PRIORITY 12 -/* - * From 0 .. 100. Higher means more swappy. - */ -int vm_swappiness = 60; static long total_memory; #ifdef ARCH_HAS_PREFETCH @@ -600,7 +596,9 @@ refill_inactive_zone(struct zone *zone, LIST_HEAD(l_active); /* Pages to go onto the active_list */ struct page *page; struct pagevec pvec; + struct sysinfo i; int reclaim_mapped = 0; + int vm_swappiness; long mapped_ratio; long distress; long swap_tendency; @@ -642,13 +640,19 @@ refill_inactive_zone(struct zone *zone, mapped_ratio = (ps->nr_mapped * 100) / total_memory; /* + * Autoregulate vm_swappiness to be equal to the percentage of + * pages in physical ram that are application pages. -ck + */ + si_meminfo(&i); + vm_swappiness = 100 - (((i.freeram + get_page_cache_size() - + swapper_space.nrpages) * 100) / i.totalram); + + /* * Now decide how much we really want to unmap some pages. The mapped * 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. - * - * A 100% value of vm_swappiness overrides this algorithm altogether. */ swap_tendency = mapped_ratio / 2 + distress + vm_swappiness;