Re: [RFC v4 0/3] mm: zap pages with read mmap_sem in munmap for large mapping
- Date: Wed, 11 Jul 2018 13:58:24 +0200
- From: Michal Hocko <mhocko@xxxxxxxxxx>
- Subject: Re: [RFC v4 0/3] mm: zap pages with read mmap_sem in munmap for large mapping
On Wed 11-07-18 14:10:52, Kirill A. Shutemov wrote:
> It's okay. I have another suggestion that also doesn't require VM_DEAD
> trick too :)
> 1. Take mmap_sem for write;
> 2. Adjust VMA layout (split/remove). After the step all memory we try to
> unmap is outside any VMA.
> 3. Downgrade mmap_sem to read.
> 4. Zap the page range.
> 5. Drop mmap_sem.
> I believe it should be safe.
> The pages in the range cannot be re-faulted after step 3 as find_vma()
> will not see the corresponding VMA and deliver SIGSEGV.
> New VMAs cannot be created in the range before step 5 since we hold the
> semaphore at least for read the whole time.
> Do you see problem in this approach?
Yes this seems to be safe. At least from the first glance.