[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220527211708.839033-3-matenajakub@gmail.com>
Date: Fri, 27 May 2022 23:17:08 +0200
From: Jakub Matěna <matenajakub@...il.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, patches@...ts.linux.dev,
linux-kernel@...r.kernel.org, vbabka@...e.cz, mhocko@...nel.org,
mgorman@...hsingularity.net, willy@...radead.org,
liam.howlett@...cle.com, hughd@...gle.com, kirill@...temov.name,
riel@...riel.com, rostedt@...dmis.org, peterz@...radead.org,
Jakub Matěna <matenajakub@...il.com>
Subject: [PATCH v2 2/2] [PATCH 2/2] mm: add merging after mremap resize
When mremap call results in expansion, it might be possible to merge the
VMA with the next VMA which might become adjacent. This patch adds
vma_merge call after the expansion is done to try and merge.
Signed-off-by: Jakub Matěna <matenajakub@...il.com>
---
mm/mremap.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mm/mremap.c b/mm/mremap.c
index 303d3290b938..21dfa15e8200 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -9,6 +9,7 @@
*/
#include <linux/mm.h>
+#include <linux/mm_inline.h>
#include <linux/hugetlb.h>
#include <linux/shm.h>
#include <linux/ksm.h>
@@ -23,6 +24,7 @@
#include <linux/mmu_notifier.h>
#include <linux/uaccess.h>
#include <linux/userfaultfd_k.h>
+#include <linux/mempolicy.h>
#include <asm/cacheflush.h>
#include <asm/tlb.h>
@@ -1022,8 +1024,11 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
}
}
- if (vma_adjust(vma, vma->vm_start, addr + new_len,
- vma->vm_pgoff, NULL)) {
+ vma = vma_merge(mm, vma, addr + old_len, addr + new_len,
+ vma->vm_flags, vma->anon_vma, vma->vm_file,
+ vma->vm_pgoff + (old_len >> PAGE_SHIFT), vma_policy(vma),
+ vma->vm_userfaultfd_ctx, anon_vma_name(vma));
+ if (!vma) {
vm_unacct_memory(pages);
ret = -ENOMEM;
goto out;
--
2.35.1
Powered by blists - more mailing lists