Re: [PATCH v4 64/66] nommu: Remove uses of VMA linked list

From: Matthew Wilcox
Date: Thu Jan 20 2022 - 10:54:22 EST


On Thu, Jan 20, 2022 at 04:06:21PM +0100, Vlastimil Babka wrote:
> On 12/1/21 15:30, Liam Howlett wrote:
> > From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
> >
> > Use the maple tree or VMA iterator instead. This is faster and will
> > allow us to shrink the VMA.
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
>
> Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
>
> But I think some fixup needed:
>
> > @@ -1456,12 +1458,14 @@ void exit_mmap(struct mm_struct *mm)
> >
> > mm->total_vm = 0;
> >
> > - while ((vma = mm->mmap)) {
> > - mm->mmap = vma->vm_next;
> > + mmap_write_lock(mm);
>
> If locking was missing, should have been added sooner than now?

I don't think so? This is the exit_mmap() path, so we know nobody
has access to the mm. We didn't need to hold the lock at this point
before, but now for_each_vma() will check we're holding the mmap_lock.

> > + for_each_vma(vmi, vma) {
> > delete_vma_from_mm(vma);
> > delete_vma(mm, vma);
> > cond_resched();
> > }
> > + __mt_destroy(&mm->mm_mt);
>
> And this at the point mm_mt was added?

You mean we should have been calling __mt_destroy() earlier in the
patch series? Umm ... I'll defer to Liam on that one.