summaryrefslogtreecommitdiff
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorLiam R. Howlett <Liam.Howlett@Oracle.com>2023-01-20 19:26:15 +0300
committerAndrew Morton <akpm@linux-foundation.org>2023-02-10 03:51:32 +0300
commitf2ebfe43ba6c845e70b6acbabd6c69ab74b3c52e (patch)
tree8bdb5bad8237a0578fe43b40e728a8796a5bfd71 /mm/mmap.c
parent3c441ab7d059ebfd2535a52c001c50eac5d63886 (diff)
downloadlinux-f2ebfe43ba6c845e70b6acbabd6c69ab74b3c52e.tar.xz
mm: add temporary vma iterator versions of vma_merge(), split_vma(), and __split_vma()
These wrappers are short-lived in this patch set so that each user can be converted on its own. In the end, these functions are renamed in one commit. Link: https://lkml.kernel.org/r/20230120162650.984577-15-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 7e406416cf47..894017841d5d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1091,6 +1091,25 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
return res;
}
+struct vm_area_struct *vmi_vma_merge(struct vma_iterator *vmi,
+ struct mm_struct *mm,
+ struct vm_area_struct *prev, unsigned long addr,
+ unsigned long end, unsigned long vm_flags,
+ struct anon_vma *anon_vma, struct file *file,
+ pgoff_t pgoff, struct mempolicy *policy,
+ struct vm_userfaultfd_ctx vm_userfaultfd_ctx,
+ struct anon_vma_name *anon_name)
+{
+ struct vm_area_struct *tmp;
+
+ tmp = vma_merge(mm, prev, addr, end, vm_flags, anon_vma, file, pgoff,
+ policy, vm_userfaultfd_ctx, anon_name);
+ if (tmp)
+ vma_iter_set(vmi, end);
+
+ return tmp;
+}
+
/*
* Rough compatibility check to quickly see if it's even worth looking
* at sharing an anon_vma.
@@ -2276,6 +2295,18 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
validate_mm_mt(mm);
return err;
}
+int vmi__split_vma(struct vma_iterator *vmi, struct mm_struct *mm,
+ struct vm_area_struct *vma, unsigned long addr, int new_below)
+{
+ int ret;
+ unsigned long end = vma->vm_end;
+
+ ret = __split_vma(mm, vma, addr, new_below);
+ if (!ret)
+ vma_iter_set(vmi, end);
+
+ return ret;
+}
/*
* Split a vma into two pieces at address 'addr', a new vma is allocated
@@ -2290,6 +2321,19 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
return __split_vma(mm, vma, addr, new_below);
}
+int vmi_split_vma(struct vma_iterator *vmi, struct mm_struct *mm,
+ struct vm_area_struct *vma, unsigned long addr, int new_below)
+{
+ int ret;
+ unsigned long end = vma->vm_end;
+
+ ret = split_vma(mm, vma, addr, new_below);
+ if (!ret)
+ vma_iter_set(vmi, end);
+
+ return ret;
+}
+
static inline int munmap_sidetree(struct vm_area_struct *vma,
struct ma_state *mas_detach)
{