Skip to content

Commit

Permalink
binder: reduce mmap_sem write-side lock
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Martijn Coenen <[email protected]>
Cc: Arve Hjønnevåg <[email protected]>
Signed-off-by: Minchan Kim <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
minchank authored and gregkh committed Feb 19, 2019
1 parent 7c11df4 commit 3013bf6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/android/binder_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 3013bf6

Please sign in to comment.