diff -urN 2.3.18/include/linux/swap.h 2.3.18-lru/include/linux/swap.h --- 2.3.18/include/linux/swap.h Tue Oct 5 20:44:21 1999 +++ 2.3.18-lru/include/linux/swap.h Tue Oct 5 21:10:59 1999 @@ -175,6 +175,14 @@ spin_unlock(&pagemap_lru_lock); \ } while (0) +#define lru_swap_cache_add(page) \ +do { \ + spin_lock(&pagemap_lru_lock); \ + list_add_tail(&(page)->lru, &lru_cache); \ + nr_lru_pages++; \ + spin_unlock(&pagemap_lru_lock); \ +} while (0) + #define lru_cache_del(page) \ do { \ spin_lock(&pagemap_lru_lock); \ diff -urN 2.3.18/mm/filemap.c 2.3.18-lru/mm/filemap.c --- 2.3.18/mm/filemap.c Tue Sep 14 14:35:32 1999 +++ 2.3.18-lru/mm/filemap.c Tue Oct 5 21:44:07 1999 @@ -488,15 +488,19 @@ struct page **hash) { unsigned long flags; + int page_cache = !PageSwapCache(page); - flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (1 << PG_referenced)); + flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (page_cache << PG_referenced)); page->flags = flags | (1 << PG_locked); page->owner = current; /* REMOVEME */ get_page(page); page->offset = offset; add_page_to_inode_queue(inode, page); __add_page_to_hash_queue(page, hash); - lru_cache_add(page); + if (page_cache) + lru_cache_add(page); + else + lru_swap_cache_add(page); } void add_to_page_cache(struct page * page, struct inode * inode, unsigned long offset)