]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mlock: Use maple state in apply_mlockall_flags()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 27 Apr 2022 16:46:04 +0000 (12:46 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 27 Apr 2022 16:49:54 +0000 (12:49 -0400)
The vma iterator is for simple cases.  Since mlock_fixup() can cause the
tree to change and thus requires the maple state to be reset,
apply_mlockall_flags() is not a simple case.  Use a maple state and
call mas_pause() instead.

Fixes: 0d43186b36c1 (mm/mlock: use vma iterator and instead of vma
linked list)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
mm/mlock.c

index d8549b3dcb59a20642f2f42a46141ecb8a5d7b30..c41604ba5197d80c15716d8cd53d608d611359bc 100644 (file)
@@ -660,7 +660,7 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
  */
 static int apply_mlockall_flags(int flags)
 {
-       VMA_ITERATOR(vmi, current->mm, 0);
+       MA_STATE(mas, &current->mm->mm_mt, 0, 0);
        struct vm_area_struct *vma, *prev = NULL;
        vm_flags_t to_add = 0;
 
@@ -681,7 +681,7 @@ static int apply_mlockall_flags(int flags)
                        to_add |= VM_LOCKONFAULT;
        }
 
-       for_each_vma(vmi, vma) {
+       mas_for_each(&mas, vma, ULONG_MAX) {
                vm_flags_t newflags;
 
                newflags = vma->vm_flags & VM_LOCKED_CLEAR_MASK;
@@ -689,6 +689,7 @@ static int apply_mlockall_flags(int flags)
 
                /* Ignore errors */
                mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
+               mas_pause(&mas);
                cond_resched();
        }
 out: