Skip to content

Commit e4bd84c

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
mm: Always downgrade mmap_lock if requested
Now that stack growth must always hold the mmap_lock for write, we can always downgrade the mmap_lock to read and safely unmap pages from the page table, even if we're next to a stack. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 03f8893 commit e4bd84c

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

mm/mmap.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,19 +2551,8 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
25512551
/* Point of no return */
25522552
mm->locked_vm -= locked_vm;
25532553
mm->map_count -= count;
2554-
/*
2555-
* Do not downgrade mmap_lock if we are next to VM_GROWSDOWN or
2556-
* VM_GROWSUP VMA. Such VMAs can change their size under
2557-
* down_read(mmap_lock) and collide with the VMA we are about to unmap.
2558-
*/
2559-
if (downgrade) {
2560-
if (next && (next->vm_flags & VM_GROWSDOWN))
2561-
downgrade = false;
2562-
else if (prev && (prev->vm_flags & VM_GROWSUP))
2563-
downgrade = false;
2564-
else
2565-
mmap_write_downgrade(mm);
2566-
}
2554+
if (downgrade)
2555+
mmap_write_downgrade(mm);
25672556

25682557
/*
25692558
* We can free page tables without write-locking mmap_lock because VMAs

0 commit comments

Comments
 (0)