Skip to content

Commit

Permalink
mm/mremap: use helper mlock_future_check()
Browse files Browse the repository at this point in the history
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/20220322112004.27380-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Miaohe Lin authored and akpm committed Apr 29, 2022
1 parent 3afa793 commit f433195
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,14 +766,8 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP))
return ERR_PTR(-EFAULT);

if (vma->vm_flags & VM_LOCKED) {
unsigned long locked, lock_limit;
locked = mm->locked_vm << PAGE_SHIFT;
lock_limit = rlimit(RLIMIT_MEMLOCK);
locked += new_len - old_len;
if (locked > lock_limit && !capable(CAP_IPC_LOCK))
return ERR_PTR(-EAGAIN);
}
if (mlock_future_check(mm, vma->vm_flags, new_len - old_len))
return ERR_PTR(-EAGAIN);

if (!may_expand_vm(mm, vma->vm_flags,
(new_len - old_len) >> PAGE_SHIFT))
Expand Down

0 comments on commit f433195

Please sign in to comment.