Merge tag 'memory-controller-drv-5.13-2' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / mm / mremap.c
index f554320..ec8f840 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/syscalls.h>
 #include <linux/mmu_notifier.h>
 #include <linux/uaccess.h>
-#include <linux/mm-arch-hooks.h>
 #include <linux/userfaultfd_k.h>
 
 #include <asm/cacheflush.h>
@@ -336,8 +335,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-                       unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+                       unsigned long old_addr, unsigned long old_end,
+                       unsigned long new_addr)
 {
        unsigned long next, extent, mask, size;
 
@@ -562,8 +562,6 @@ static unsigned long move_vma(struct vm_area_struct *vma,
                new_addr = err;
        } else {
                mremap_userfaultfd_prep(new_vma, uf);
-               arch_remap(mm, old_addr, old_addr + old_len,
-                          new_addr, new_addr + new_len);
        }
 
        /* Conceal VM_ACCOUNT so old reservation is not undone */
@@ -595,6 +593,14 @@ static unsigned long move_vma(struct vm_area_struct *vma,
                /* We always clear VM_LOCKED[ONFAULT] on the old vma */
                vma->vm_flags &= VM_LOCKED_CLEAR_MASK;
 
+               /*
+                * anon_vma links of the old vma is no longer needed after its page
+                * table has been moved.
+                */
+               if (new_vma != vma && vma->vm_start == old_addr &&
+                       vma->vm_end == (old_addr + old_len))
+                       unlink_anon_vmas(vma);
+
                /* Because we won't unmap we don't need to touch locked_vm */
                return new_addr;
        }