--- 2.4.10pre14aa1/mm/filemap.c.~1~ Sat Sep 22 12:02:20 2001 +++ 2.4.10pre14aa1/mm/filemap.c Sat Sep 22 14:54:33 2001 @@ -1717,6 +1717,7 @@ */ if (VM_SequentialReadHint(area)) nopage_sequential_readahead(area, pgoff, size); + mark_page_accessed(page); /* * Found the page and have a reference on it, need to check sharing --- 2.4.10pre14aa1/mm/vmscan.c.~1~ Sat Sep 22 12:02:18 2001 +++ 2.4.10pre14aa1/mm/vmscan.c Sat Sep 22 14:58:04 2001 @@ -60,6 +60,9 @@ if (PageActive(page)) return 0; + if (PageTestandClearReferenced(page)) + return 0; + if (TryLockPage(page)) return 0; @@ -374,8 +377,14 @@ __max_scan--; /* Racy check to avoid trylocking when not worthwhile */ - if (!page->buffers && page_count(page) != 1) + if (!page->buffers && page_count(page) != 1) { + /* + * We cannot do anything about this page, so don't + * keep wasting time on it and just roll it over. + */ + activate_page_nolock(page); continue; + } /* * The page is locked. IO in progress? @@ -549,7 +558,7 @@ static int FASTCALL(shrink_caches(int priority, zone_t * classzone, unsigned int gfp_mask, int nr_pages)); static int shrink_caches(int priority, zone_t * classzone, unsigned int gfp_mask, int nr_pages) { - int max_scan = (nr_inactive_pages + nr_active_pages / DEF_PRIORITY) / priority; + int max_scan = nr_inactive_pages / priority; nr_pages -= kmem_cache_reap(gfp_mask); if (nr_pages <= 0) --- 2.4.10pre14aa1/mm/memory.c.~1~ Sat Sep 22 12:02:18 2001 +++ 2.4.10pre14aa1/mm/memory.c Sat Sep 22 14:53:37 2001 @@ -85,8 +85,6 @@ if (page->mapping) { if (pte_dirty(pte)) set_page_dirty(page); - if (pte_young(pte)) - mark_page_accessed(page); } free_page_and_swap_cache(page); @@ -1132,8 +1130,10 @@ spin_unlock(&mm->page_table_lock); page = lookup_swap_cache(entry); if (!page) { + int readahead = start_aggressive_readahead(__GFP_HIGHMEM); lock_kernel(); - swapin_readahead(entry); + if (readahead) + swapin_readahead(entry); page = read_swap_cache_async(entry); unlock_kernel(); if (!page) { @@ -1179,7 +1179,8 @@ pte = pte_mkwrite(pte); pte = pte_mkdirty(pte); delete_from_swap_cache_nolock(page); - } + } else + SetPageReferenced(page); UnlockPage(page); flush_page_to_ram(page); --- 2.4.10pre14aa1/mm/swap.c.~1~ Sat Sep 22 08:06:24 2001 +++ 2.4.10pre14aa1/mm/swap.c Sat Sep 22 13:41:02 2001 @@ -54,7 +54,6 @@ del_page_from_active_list(page); add_page_to_inactive_list(page); } - ClearPageReferenced(page); } void deactivate_page(struct page * page) @@ -73,7 +72,6 @@ del_page_from_inactive_list(page); add_page_to_active_list(page); } - SetPageReferenced(page); } void activate_page(struct page * page)