Re: [PATCH] binder: reduce mmap_sem write-side lock

From: Todd Kjos
Date: Tue Feb 19 2019 - 11:55:15 EST


On Mon, Feb 18, 2019 at 2:47 AM Minchan Kim <minchan@xxxxxxxxxx> wrote:
>
> On Mon, Feb 18, 2019 at 09:32:08AM +0100, Greg KH wrote:
> > On Mon, Feb 18, 2019 at 05:11:45PM +0900, Minchan Kim wrote:
> > > 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@xxxxxxxxxx>
> > > Cc: Martijn Coenen <maco@xxxxxxxxxxx>
> > > Cc: Arve HjÃnnevÃg <arve@xxxxxxxxxxx>
> > > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > > Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>

Acked-by: Todd Kjos <tkjos@xxxxxxxxxx>

> > > ---
> > > drivers/android/binder_alloc.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > Is this just needed for the recent binder changes that are in
> > linux-next, or for older kernels as well?
>
> It has been there for several years but no need to fix older kernels
> because down_write of mmap_sem is technically not a bug to stop the
> working of binder. Rather than, it's just abuse of the lock so
> it's okay to fix only recent kernel.
>
> Thanks.