Commit dd254918 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] swapoff: activate pages

People like to use swapoff/swapon as a way of restoring their VM to a
predictable "preconditional" state.

Problem is, swapoff leaves mapped anon/pagecache pages on the inactive list,
so they immediately get swapped out again when swapspace becomes available.

Let's move these pages onto the active list to the VM has to again decide
whether to swap them out.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7d28f09f
...@@ -467,6 +467,13 @@ static unsigned long unuse_pmd(struct vm_area_struct * vma, pmd_t *dir, ...@@ -467,6 +467,13 @@ static unsigned long unuse_pmd(struct vm_area_struct * vma, pmd_t *dir,
if (unlikely(pte_same(*pte, swp_pte))) { if (unlikely(pte_same(*pte, swp_pte))) {
unuse_pte(vma, offset + address, pte, entry, page); unuse_pte(vma, offset + address, pte, entry, page);
pte_unmap(pte); pte_unmap(pte);
/*
* Move the page to the active list so it is not
* immediately swapped out again after swapon.
*/
activate_page(page);
/* add 1 since address may be 0 */ /* add 1 since address may be 0 */
return 1 + offset + address; return 1 + offset + address;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment