From: Nikita Danilov shrink_list() checks PageSwapCache() before calling add_to_swap(), this means that anonymous page that is going to be added to the swap right now these checks return false and: (*) it will be unaccounted for in nr_mapped, and (*) it won't be written to the swap if gfp_flags include __GFP_IO but not __GFP_FS. (Both will happen only on the next round of scanning.) Patch below just moves may_enter_fs initialization down. I am not sure about (*nr_mapped) increase though. --- mm/vmscan.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff -puN mm/vmscan.c~shrink_list-swapcache-check-fix mm/vmscan.c --- 25/mm/vmscan.c~shrink_list-swapcache-check-fix 2004-02-02 22:45:50.000000000 -0800 +++ 25-akpm/mm/vmscan.c 2004-02-02 22:45:50.000000000 -0800 @@ -274,8 +274,6 @@ shrink_list(struct list_head *page_list, (*nr_mapped)++; BUG_ON(PageActive(page)); - may_enter_fs = (gfp_mask & __GFP_FS) || - (PageSwapCache(page) && (gfp_mask & __GFP_IO)); if (PageWriteback(page)) goto keep_locked; @@ -306,6 +304,9 @@ shrink_list(struct list_head *page_list, } #endif /* CONFIG_SWAP */ + may_enter_fs = (gfp_mask & __GFP_FS) || + (PageSwapCache(page) && (gfp_mask & __GFP_IO)); + /* * The page is mapped into the page tables of one or more * processes. Try to unmap it here. _