aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2022-04-28 23:16:12 -0700
committerakpm <akpm@linux-foundation.org>2022-04-28 23:16:12 -0700
commitc5d8a3643d91be748d7ff12eedc5876f32cc8283 (patch)
treecf1ca7621cf71e783f3fff7e9f500f842f4f0b19 /mm/mmap.c
parentmm/mmap: clarify protection_map[] indices (diff)
downloadlinux-dev-c5d8a3643d91be748d7ff12eedc5876f32cc8283.tar.xz
linux-dev-c5d8a3643d91be748d7ff12eedc5876f32cc8283.zip
mm/mmap.c: use helper mlock_future_check()
Use helper mlock_future_check() to check whether it's safe to enlarge the locked_vm to simplify the code. Minor readability improvement. Link: https://lkml.kernel.org/r/20220402032231.64974-1-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 7873cc3ca24c..e32640456c92 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2354,15 +2354,8 @@ static int acct_stack_growth(struct vm_area_struct *vma,
return -ENOMEM;
/* mlock limit tests */
- if (vma->vm_flags & VM_LOCKED) {
- unsigned long locked;
- unsigned long limit;
- locked = mm->locked_vm + grow;
- limit = rlimit(RLIMIT_MEMLOCK);
- limit >>= PAGE_SHIFT;
- if (locked > limit && !capable(CAP_IPC_LOCK))
- return -ENOMEM;
- }
+ if (mlock_future_check(mm, vma->vm_flags, grow << PAGE_SHIFT))
+ return -ENOMEM;
/* Check to ensure the stack will not grow into a hugetlb-only region */
new_start = (vma->vm_flags & VM_GROWSUP) ? vma->vm_start :