summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2019-02-18 17:11:45 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-19 14:50:11 +0100
commit3013bf62b67aef921bc2e9ba10e639a022002d02 (patch)
tree783ad1e60175ec150ea953276af0f8ab6e8fab49
parent7c11df42d0c7bf5b3dd743a21b4872e7b26ca2a2 (diff)
downloadlinux-3013bf62b67aef921bc2e9ba10e639a022002d02.tar.gz
linux-3013bf62b67aef921bc2e9ba10e639a022002d02.tar.bz2
linux-3013bf62b67aef921bc2e9ba10e639a022002d02.zip
binder: reduce mmap_sem write-side lock
binder has used write-side mmap_sem semaphore to release memory mapped at address space of the process. However, right lock to release pages is down_read, not down_write because page table lock already protects the race for parallel freeing. Please do not use mmap_sem write-side lock which is well known contented lock. Cc: Todd Kjos <tkjos@google.com> Cc: Martijn Coenen <maco@android.com> Cc: Arve Hjønnevåg <arve@android.com> Signed-off-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/android/binder_alloc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 000dd4d145ba..6389467670a0 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -932,7 +932,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
if (!mmget_not_zero(alloc->vma_vm_mm))
goto err_mmget;
mm = alloc->vma_vm_mm;
- if (!down_write_trylock(&mm->mmap_sem))
+ if (!down_read_trylock(&mm->mmap_sem))
goto err_down_write_mmap_sem_failed;
}
@@ -946,7 +946,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
trace_binder_unmap_user_end(alloc, index);
- up_write(&mm->mmap_sem);
+ up_read(&mm->mmap_sem);
mmput(mm);
}