From 62c50b9683d10ccaa0b689459efaa41794db129b Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Wed, 27 Apr 2022 12:46:04 -0400 Subject: [PATCH] mm/mlock: Use maple state in apply_mlockall_flags() 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 --- mm/mlock.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index d8549b3dcb59..c41604ba5197 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -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, ¤t->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: -- 2.35.1