All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/mremap: use helper mlock_future_check
@ 2022-03-22 11:20 Miaohe Lin
  2022-03-26  9:53 ` Wei Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2022-03-22 11:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

Use helper mlock_future_check to check whether it's safe to resize the
locked_vm to simplify the code. Minor readability improvement.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/mremap.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/mm/mremap.c b/mm/mremap.c
index 9d76da79594d..e776d4c2345c 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -763,14 +763,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))
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/mremap: use helper mlock_future_check
  2022-03-22 11:20 [PATCH] mm/mremap: use helper mlock_future_check Miaohe Lin
@ 2022-03-26  9:53 ` Wei Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Yang @ 2022-03-26  9:53 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, linux-mm, linux-kernel

On Tue, Mar 22, 2022 at 07:20:04PM +0800, Miaohe Lin wrote:
>Use helper mlock_future_check to check whether it's safe to resize the
>locked_vm to simplify the code. Minor readability improvement.
>
>Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-26  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 11:20 [PATCH] mm/mremap: use helper mlock_future_check Miaohe Lin
2022-03-26  9:53 ` Wei Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.