[RHEL7,COMMIT] ms/uprobes: share the i_mmap_rwsem

Submitted by Vasily Averin on Dec. 3, 2020, 8:41 a.m.

Details

Message ID 202012030841.0B38f6Aj031329@vz7build.vvs.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Vasily Averin Dec. 3, 2020, 8:41 a.m.
The commit is pushed to "branch-rh7-3.10.0-1160.6.1.vz7.171.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.6.1.vz7.171.1
------>
commit 27f33ccad53483835a59c54615478cf0de90ffd6
Author: Davidlohr Bueso <dave@stgolabs.net>
Date:   Thu Dec 3 11:41:06 2020 +0300

    ms/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>
    
    https://jira.sw.ru/browse/PSBM-122663
    (cherry picked from commit 4a23717a236b2ab31efb1651f586126789fc997f)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 kernel/events/uprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index a7c557f..d29042c 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -690,7 +690,7 @@  build_map_info(struct address_space *mapping, loff_t offset, bool is_register)
 	int more = 0;
 
  again:
-	i_mmap_lock_write(mapping);
+	i_mmap_lock_read(mapping);
 	vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
 		if (!valid_vma(vma, is_register))
 			continue;
@@ -721,7 +721,7 @@  build_map_info(struct address_space *mapping, loff_t offset, bool is_register)
 		info->mm = vma->vm_mm;
 		info->vaddr = offset_to_vaddr(vma, offset);
 	}
-	i_mmap_unlock_write(mapping);
+	i_mmap_unlock_read(mapping);
 
 	if (!more)
 		goto out;