mm: don't waste swap on locked pages
authorHugh Dickins <[email protected]>
Tue, 5 Feb 2008 06:29:23 +0000 (22:29 -0800)
committerLinus Torvalds <[email protected]>
Tue, 5 Feb 2008 17:44:18 +0000 (09:44 -0800)
try_to_unmap always fails on a page found in a VM_LOCKED vma (unless
migrating), and recycles it back to the active list.  But if it's an
anonymous page, we've already allocated swap to it: just wasting swap.
Spot locked pages in page_referenced_one and treat them as referenced.

Signed-off-by: Hugh Dickins <[email protected]>
Tested-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Ethan Solomita <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/rmap.c

index 0334c8f6b741072c4fb1fb4830223c1530e5919c..57ad276900c94903a2febd53e1c0d995958a38a9 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -283,7 +283,10 @@ static int page_referenced_one(struct page *page,
        if (!pte)
                goto out;
 
-       if (ptep_clear_flush_young(vma, address, pte))
+       if (vma->vm_flags & VM_LOCKED) {
+               referenced++;
+               *mapcount = 1;  /* break early from loop */
+       } else if (ptep_clear_flush_young(vma, address, pte))
                referenced++;
 
        /* Pretend the page is referenced if the task has the