From 5b1116c33fc208a98f716a8eb255eea11ab5e6f4 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 3 Feb 2004 18:49:23 -0800 Subject: [PATCH] [PATCH] shrink_list(): check PageSwapCache() after add_to_swap() 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 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index dcb7dc0f176d1..7580d2812a97f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -271,8 +271,6 @@ shrink_list(struct list_head *page_list, unsigned int gfp_mask, (*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; @@ -303,6 +301,9 @@ shrink_list(struct list_head *page_list, unsigned int gfp_mask, } #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. -- 2.53.0