mm: simplify try_to_unmap_one()
SWAP_MLOCK mean "We marked the page as PG_MLOCK, please move it to unevictable-lru". So, following code is easy confusable. if (vma->vm_flags & VM_LOCKED) { ret = SWAP_MLOCK; goto out_unmap; } Plus, if the VMA doesn't have VM_LOCKED, We don't need to check the needed of calling mlock_vma_page(). Also, add some commentary to try_to_unmap_one(). Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
23ce932a5e
commit
caed0f486e
1 changed files with 24 additions and 15 deletions
25
mm/rmap.c
25
mm/rmap.c
|
@ -789,10 +789,9 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
|
|||
* skipped over this mm) then we should reactivate it.
|
||||
*/
|
||||
if (!(flags & TTU_IGNORE_MLOCK)) {
|
||||
if (vma->vm_flags & VM_LOCKED) {
|
||||
ret = SWAP_MLOCK;
|
||||
goto out_unmap;
|
||||
}
|
||||
if (vma->vm_flags & VM_LOCKED)
|
||||
goto out_mlock;
|
||||
|
||||
if (TTU_ACTION(flags) == TTU_MUNLOCK)
|
||||
goto out_unmap;
|
||||
}
|
||||
|
@ -865,9 +864,21 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
|
|||
|
||||
out_unmap:
|
||||
pte_unmap_unlock(pte, ptl);
|
||||
out:
|
||||
return ret;
|
||||
|
||||
if (ret == SWAP_MLOCK) {
|
||||
ret = SWAP_AGAIN;
|
||||
out_mlock:
|
||||
pte_unmap_unlock(pte, ptl);
|
||||
|
||||
|
||||
/*
|
||||
* We need mmap_sem locking, Otherwise VM_LOCKED check makes
|
||||
* unstable result and race. Plus, We can't wait here because
|
||||
* we now hold anon_vma->lock or mapping->i_mmap_lock.
|
||||
* if trylock failed, the page remain in evictable lru and later
|
||||
* vmscan could retry to move the page to unevictable lru if the
|
||||
* page is actually mlocked.
|
||||
*/
|
||||
if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
|
||||
if (vma->vm_flags & VM_LOCKED) {
|
||||
mlock_vma_page(page);
|
||||
|
@ -875,8 +886,6 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
|
|||
}
|
||||
up_read(&vma->vm_mm->mmap_sem);
|
||||
}
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue