Re: [PATCH v4] ANDROID: binder: change down_write to down_read

From: Joe Perches
Date: Thu Mar 29 2018 - 02:48:54 EST


On Thu, 2018-03-29 at 15:40 +0900, Minchan Kim wrote:
> binder_update_page_range needs down_write of mmap_sem because
> vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
> it is set. However, when I profile binder working, it seems
> every binder buffers should be mapped in advance by binder_mmap.
> It means we could set VM_MIXEDMAP in bider_mmap time which is

typo trivia: binder_mmap

> already hold a mmap_sem as down_write so binder_update_page_range
> doesn't need to hold a mmap_sem as down_write.

and style trivia:

> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
[]
> @@ -4722,7 +4722,8 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
> failure_string = "bad vm_flags";
> goto err_bad_arg;
> }
> - vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
> + vma->vm_flags = (vma->vm_flags | VM_DONTCOPY | VM_MIXEDMAP) &
> + ~VM_MAYWRITE;

Perhaps this is clearer as

vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
vma->vm_flags &= ~VM_MAYWRITE;