mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
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>
This commit is contained in:
committed by
Linus Torvalds
parent
03f889378f
commit
e4bd84c069
15
mm/mmap.c
15
mm/mmap.c
@@ -2551,19 +2551,8 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
|
|||||||
/* Point of no return */
|
/* Point of no return */
|
||||||
mm->locked_vm -= locked_vm;
|
mm->locked_vm -= locked_vm;
|
||||||
mm->map_count -= count;
|
mm->map_count -= count;
|
||||||
/*
|
if (downgrade)
|
||||||
* Do not downgrade mmap_lock if we are next to VM_GROWSDOWN or
|
mmap_write_downgrade(mm);
|
||||||
* VM_GROWSUP VMA. Such VMAs can change their size under
|
|
||||||
* down_read(mmap_lock) and collide with the VMA we are about to unmap.
|
|
||||||
*/
|
|
||||||
if (downgrade) {
|
|
||||||
if (next && (next->vm_flags & VM_GROWSDOWN))
|
|
||||||
downgrade = false;
|
|
||||||
else if (prev && (prev->vm_flags & VM_GROWSUP))
|
|
||||||
downgrade = false;
|
|
||||||
else
|
|
||||||
mmap_write_downgrade(mm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can free page tables without write-locking mmap_lock because VMAs
|
* We can free page tables without write-locking mmap_lock because VMAs
|
||||||
|
Reference in New Issue
Block a user