Skip to contentSkip to conversation

mm-add-merging-after-mremap-resize.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Sep 27, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: add merging after mremap resize
has been removed from the -mm tree. Its filename was
mm-add-merging-after-mremap-resize.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Jakub Matěna <[email protected]>
Subject: mm: add merging after mremap resize
Date: Fri, 3 Jun 2022 16:57:19 +0200

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.

[[email protected]: coding-style cleanups]
Cc Hugh Dickins <[email protected]>
Cc "Kirill A . Shutemov" <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Peter Zijlstra (Intel) <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Steven Rostedt <[email protected]>

---

 mm/mremap.c                              |   19 +++++++-
 tools/testing/selftests/vm/mremap_test.c |   49 ++++++++++++++++++++-
 2 files changed, 65 insertions(+), 3 deletions(-)
mm/mremap.c renamed from mm/mremap.c~mm-add-merging-after-mremap-resize +17 -2
@@ -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>
@@ -1012,6 +1014,9 @@ SYSCALL_DEFINE5(mremap, unsigned long, a
 		/* can we just expand the current mapping? */
 		if (vma_expandable(vma, new_len - old_len)) {
 			long pages = (new_len - old_len) >> PAGE_SHIFT;
+			unsigned long extension_start = addr + old_len;
+			unsigned long extension_end = addr + new_len;
+			pgoff_t extension_pgoff = vma->vm_pgoff + (old_len >> PAGE_SHIFT);
 
 			if (vma->vm_flags & VM_ACCOUNT) {
 				if (security_vm_enough_memory_mm(mm, pages)) {
@@ -1020,8 +1025,18 @@ SYSCALL_DEFINE5(mremap, unsigned long, a
 				}
 			}
 
-			if (vma_adjust(vma, vma->vm_start, addr + new_len,
-				       vma->vm_pgoff, NULL)) {
+			/*
+			 * Function vma_merge() is called on the extension we are adding to
+			 * the already existing vma, vma_merge() will merge this extension with
+			 * the already existing vma (expand operation itself) and possibly also
+			 * with the next vma if it becomes adjacent to the expanded vma and
+			 * otherwise compatible.
+			 */
+			vma = vma_merge(mm, vma, extension_start, extension_end,
+					vma->vm_flags, vma->anon_vma, vma->vm_file,
+					extension_pgoff, vma_policy(vma),
+					vma->vm_userfaultfd_ctx, anon_vma_name(vma));
+			if (!vma) {
 				vm_unacct_memory(pages);
 				ret = -ENOMEM;
 				goto out;
tools/testing/selftests/vm/mremap_test.c renamed from tools/testing/selftests/vm/mremap_test.c~mm-add-merging-after-mremap-resize +48 -1

72 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are