[PATCH] don't waste swap on locked pages

From: Hugh Dickins
Date: Wed Nov 28 2007 - 14:01:08 EST


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@xxxxxxxxxxx>
Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
---

mm/rmap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

--- 2.6.24-rc3-git/mm/rmap.c 2007-11-27 05:00:22.000000000 +0000
+++ linux/mm/rmap.c 2007-11-28 17:01:20.000000000 +0000
@@ -284,7 +284,10 @@ static int page_referenced_one(struct pa
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/