--- linux-2.6.0-test8-base/mm/vmscan.c 2003-10-19 20:24:36.000000000 +1000 +++ linux-2.6.0-test8-am/mm/vmscan.c 2003-10-22 17:56:18.501329888 +1000 @@ -47,7 +47,7 @@ /* * From 0 .. 100. Higher means more swappy. */ -int vm_swappiness = 60; +int vm_swappiness = 0; static long total_memory; #ifdef ARCH_HAS_PREFETCH @@ -595,11 +595,13 @@ refill_inactive_zone(struct zone *zone, int pgmoved; int pgdeactivate = 0; int nr_pages = nr_pages_in; + int pg_size; LIST_HEAD(l_hold); /* The pages which were snipped off */ LIST_HEAD(l_inactive); /* Pages to go onto the inactive_list */ LIST_HEAD(l_active); /* Pages to go onto the active_list */ struct page *page; struct pagevec pvec; + struct sysinfo i; int reclaim_mapped = 0; long mapped_ratio; long distress; @@ -642,6 +644,16 @@ refill_inactive_zone(struct zone *zone, mapped_ratio = (ps->nr_mapped * 100) / total_memory; /* + * Autoregulate vm_swappiness to be application pages % -ck. + */ + si_meminfo(&i); + si_swapinfo(&i); + pg_size = get_page_cache_size() - i.bufferram ; + vm_swappiness = 100 - (((i.freeram + i.bufferram + + (pg_size - swapper_space.nrpages)) * 100) / + (i.totalram ? i.totalram : 1)); + + /* * 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.