diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/rmap.c | 35 |
1 files changed, 22 insertions, 13 deletions
@@ -789,10 +789,9 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
789 | * skipped over this mm) then we should reactivate it. | 789 | * skipped over this mm) then we should reactivate it. |
790 | */ | 790 | */ |
791 | if (!(flags & TTU_IGNORE_MLOCK)) { | 791 | if (!(flags & TTU_IGNORE_MLOCK)) { |
792 | if (vma->vm_flags & VM_LOCKED) { | 792 | if (vma->vm_flags & VM_LOCKED) |
793 | ret = SWAP_MLOCK; | 793 | goto out_mlock; |
794 | goto out_unmap; | 794 | |
795 | } | ||
796 | if (TTU_ACTION(flags) == TTU_MUNLOCK) | 795 | if (TTU_ACTION(flags) == TTU_MUNLOCK) |
797 | goto out_unmap; | 796 | goto out_unmap; |
798 | } | 797 | } |
@@ -865,18 +864,28 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, | |||
865 | 864 | ||
866 | out_unmap: | 865 | out_unmap: |
867 | pte_unmap_unlock(pte, ptl); | 866 | pte_unmap_unlock(pte, ptl); |
867 | out: | ||
868 | return ret; | ||
868 | 869 | ||
869 | if (ret == SWAP_MLOCK) { | 870 | out_mlock: |
870 | ret = SWAP_AGAIN; | 871 | pte_unmap_unlock(pte, ptl); |
871 | if (down_read_trylock(&vma->vm_mm->mmap_sem)) { | 872 | |
872 | if (vma->vm_flags & VM_LOCKED) { | 873 | |
873 | mlock_vma_page(page); | 874 | /* |
874 | ret = SWAP_MLOCK; | 875 | * We need mmap_sem locking, Otherwise VM_LOCKED check makes |
875 | } | 876 | * unstable result and race. Plus, We can't wait here because |
876 | up_read(&vma->vm_mm->mmap_sem); | 877 | * we now hold anon_vma->lock or mapping->i_mmap_lock. |
878 | * if trylock failed, the page remain in evictable lru and later | ||
879 | * vmscan could retry to move the page to unevictable lru if the | ||
880 | * page is actually mlocked. | ||
881 | */ | ||
882 | if (down_read_trylock(&vma->vm_mm->mmap_sem)) { | ||
883 | if (vma->vm_flags & VM_LOCKED) { | ||
884 | mlock_vma_page(page); | ||
885 | ret = SWAP_MLOCK; | ||
877 | } | 886 | } |
887 | up_read(&vma->vm_mm->mmap_sem); | ||
878 | } | 888 | } |
879 | out: | ||
880 | return ret; | 889 | return ret; |
881 | } | 890 | } |
882 | 891 | ||