From: Hugh Dickins Date: Thu, 13 Jan 2011 23:46:28 +0000 (-0800) Subject: thp: ksm: free swap when swapcache page is replaced X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ae52a2adb5afa5ac5ec5fb5c7b24777f84b6c926;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git thp: ksm: free swap when swapcache page is replaced When a swapcache page is replaced by a ksm page, it's best to free that swap immediately. Reported-by: Andrea Arcangeli Signed-off-by: Hugh Dickins Signed-off-by: Andrea Arcangeli Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/ksm.c b/mm/ksm.c index 43bc893470b4..b5b907cb0f90 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -800,6 +800,8 @@ static int replace_page(struct vm_area_struct *vma, struct page *page, set_pte_at_notify(mm, addr, ptep, mk_pte(kpage, vma->vm_page_prot)); page_remove_rmap(page); + if (!page_mapped(page)) + try_to_free_swap(page); put_page(page); pte_unmap_unlock(ptep, ptl);