Skip to content

Commit

Permalink
thp: ksm: free swap when swapcache page is replaced
Browse files Browse the repository at this point in the history
When a swapcache page is replaced by a ksm page, it's best to free that
swap immediately.

Reported-by: Andrea Arcangeli <[email protected]>
Signed-off-by: Hugh Dickins <[email protected]>
Signed-off-by: Andrea Arcangeli <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hugh Dickins authored and torvalds committed Jan 14, 2011
1 parent 240c879 commit ae52a2a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/ksm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ae52a2a

Please sign in to comment.