From: Matthew Wilcox (Oracle) Date: Thu, 29 Jun 2023 19:14:14 +0000 (+0100) Subject: mm: Always downgrade mmap_lock if requested X-Git-Tag: v6.6.7~2474 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4bd84c069f212c01258e405f86e91f327888e41;p=platform%2Fkernel%2Flinux-starfive.git 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) Signed-off-by: Linus Torvalds --- diff --git a/mm/mmap.c b/mm/mmap.c index 3e5793e..141c618 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2551,19 +2551,8 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, /* Point of no return */ mm->locked_vm -= locked_vm; mm->map_count -= count; - /* - * Do not downgrade mmap_lock if we are next to VM_GROWSDOWN or - * 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); - } + if (downgrade) + mmap_write_downgrade(mm); /* * We can free page tables without write-locking mmap_lock because VMAs