Skip to content

Commit f433195

Browse files
MiaoheLinakpm00
authored andcommitted
mm/mremap: use helper mlock_future_check()
Use helper mlock_future_check() to check whether it's safe to resize the locked_vm to simplify the code. Minor readability improvement. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Miaohe Lin <[email protected]> Reviewed-by: Wei Yang <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3afa793 commit f433195

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

mm/mremap.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -766,14 +766,8 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
766766
if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP))
767767
return ERR_PTR(-EFAULT);
768768

769-
if (vma->vm_flags & VM_LOCKED) {
770-
unsigned long locked, lock_limit;
771-
locked = mm->locked_vm << PAGE_SHIFT;
772-
lock_limit = rlimit(RLIMIT_MEMLOCK);
773-
locked += new_len - old_len;
774-
if (locked > lock_limit && !capable(CAP_IPC_LOCK))
775-
return ERR_PTR(-EAGAIN);
776-
}
769+
if (mlock_future_check(mm, vma->vm_flags, new_len - old_len))
770+
return ERR_PTR(-EAGAIN);
777771

778772
if (!may_expand_vm(mm, vma->vm_flags,
779773
(new_len - old_len) >> PAGE_SHIFT))

0 commit comments

Comments
 (0)