Commit 4a23717a236b2ab31efb1651f586126789fc997f

Authored by Davidlohr Bueso
Committed by Linus Torvalds
1 parent 3dec0ba0be

uprobes: share the i_mmap_rwsem

Both register and unregister call build_map_info() in order to create the
list of mappings before installing or removing breakpoints for every mm
which maps file backed memory.  As such, there is no reason to hold the
i_mmap_rwsem exclusively, so share it and allow concurrent readers to
build the mapping data.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Oleg Nesterov <oleg@redhat.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

kernel/events/uprobes.c
... ... @@ -724,7 +724,7 @@
724 724 int more = 0;
725 725  
726 726 again:
727   - i_mmap_lock_write(mapping);
  727 + i_mmap_lock_read(mapping);
728 728 vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
729 729 if (!valid_vma(vma, is_register))
730 730 continue;
... ... @@ -755,7 +755,7 @@
755 755 info->mm = vma->vm_mm;
756 756 info->vaddr = offset_to_vaddr(vma, offset);
757 757 }
758   - i_mmap_unlock_write(mapping);
  758 + i_mmap_unlock_read(mapping);
759 759  
760 760 if (!more)
761 761 goto out;