From: Hugh Dickins Date: Tue, 5 Feb 2008 06:29:23 +0000 (-0800) Subject: mm: don't waste swap on locked pages X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5a9bbdcd29adbb786c53eba1dfc3c2d256020d6b;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git mm: don't waste swap on locked pages 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 Tested-by: KAMEZAWA Hiroyuki Cc: Ethan Solomita Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/rmap.c b/mm/rmap.c index 0334c8f6b741..57ad276900c9 100644 --- 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