Re: [PATCH v3 04/16] mm/mmap: Extract the gathering of vmas from do_vmi_align_munmap()
From: Liam R. Howlett
Date: Fri Jul 05 2024 - 14:41:40 EST
* Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> [240705 14:01]:
> On Thu, Jul 04, 2024 at 02:27:06PM GMT, Liam R. Howlett wrote:
> > Create vmi_gather_munmap_vmas() to handle the gathering of vmas into a
> > detached maple tree for removal later. Part of the gathering is the
> > splitting of vmas that span the boundary.
> >
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
> > ---
> > mm/mmap.c | 82 +++++++++++++++++++++++++++++++++++++++----------------
> > 1 file changed, 58 insertions(+), 24 deletions(-)
> >
> > diff --git a/mm/mmap.c b/mm/mmap.c
> > index 411798f46932..8dc8ffbf9d8d 100644
> > --- a/mm/mmap.c
> > +++ b/mm/mmap.c
> > @@ -2656,32 +2656,29 @@ vmi_complete_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma,
> > }
> >
> > /*
> > - * do_vmi_align_munmap() - munmap the aligned region from @start to @end.
> > + * vmi_gather_munmap_vmas() - Put all VMAs within a range into a maple tree
> > + * for removal at a later date. Handles splitting first and last if necessary
> > + * and marking the vmas as isolated.
> > + *
> > * @vmi: The vma iterator
> > * @vma: The starting vm_area_struct
> > * @mm: The mm_struct
> > * @start: The aligned start address to munmap.
> > * @end: The aligned end address to munmap.
> > * @uf: The userfaultfd list_head
> > - * @unlock: Set to true to drop the mmap_lock. unlocking only happens on
> > - * success.
> > + * @mas_detach: The maple state tracking the detached tree
>
> Missing the locked_vm parameter.
Thanks. This will be dropped later but I'll add it and drop it later.
>
> > *
> > - * Return: 0 on success and drops the lock if so directed, error and leaves the
> > - * lock held otherwise.
> > + * Return: 0 on success
> > */
> > static int
> > -do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
> > +vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma,
> > struct mm_struct *mm, unsigned long start,
> > - unsigned long end, struct list_head *uf, bool unlock)
> > + unsigned long end, struct list_head *uf,
> > + struct ma_state *mas_detach, unsigned long *locked_vm)
...
>
> Other than trivial comment error, LGTM:
>
> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
Thanks!