Skip to content

Commit

Permalink
mm: don't waste swap on locked pages
Browse files Browse the repository at this point in the history
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 <hugh@veritas.com>
Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Ethan Solomita <solo@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Feb 5, 2008
1 parent 9eccf2a commit 5a9bbdc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5a9bbdc

Please sign in to comment.