lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <i3wikc32rd4mxcvppwe7daakk7nmyd5hiutse4akakgjpzy3al@b3ksxa3hzf6g>
Date: Fri, 8 Nov 2024 22:58:03 -0500
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: Carlos Llamas <cmllamas@...gle.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Arve Hjønnevåg <arve@...roid.com>,
        Todd Kjos <tkjos@...roid.com>, Martijn Coenen <maco@...roid.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Christian Brauner <brauner@...nel.org>,
        Suren Baghdasaryan <surenb@...gle.com>, linux-kernel@...r.kernel.org,
        kernel-team@...roid.com, David Hildenbrand <david@...hat.com>,
        Barry Song <v-songbaohua@...o.com>
Subject: Re: [PATCH v3 2/8] binder: concurrent page installation

* Carlos Llamas <cmllamas@...gle.com> [241108 17:26]:

...
> > > -	ret = vm_insert_page(alloc->vma, addr, page);
> > > -	if (ret) {
> > > +	mmap_read_lock(alloc->mm);
> > 
> > Ah, I debate bring this up, but you can do this without the mmap read
> > lock.  You can use rcu and the per-vma locking like in the page fault
> > path.  If you look at how that is done using the lock_vma_under_rcu()
> > (mm/memory.c) then you can see that pages are installed today without
> > the mmap locking (on some architectures - which includes x86_64 and
> > arm64).
> 
> Right, per-vma locking is implemented in patch 7 of this series:
> https://lore.kernel.org/all/20241108191057.3288442-8-cmllamas@google.com/
> 

Oh, sorry I missed that.  I had not pulled the entire patch set for
review due to other tasks, but wanted to say something before this went
in.

Is there any performance numbers on how much this helps?

> 
> > userfaultfd had to do something like this as well, and created some
> > abstraction to facilitate either mmap or rcu, based on the arch support.
> > Going to rcu really helped performance there [1].  There was also a
> > chance of the vma being missed, so it is checked again under the mmap
> > read lock, but realistically that never happens and exists to ensure
> > correctness.
> 
> hmm, if there are more users of this pattern in the future then perhaps
> it might be worth adding a common helper?

Yes.  But the userfaultfd is a bit different in that it could need to
deal with a lazy init issue with anon vma, iirc.  Some of the fine
details have prevented common helpers so far.

> 
> > You also mention the shrinker and using the alloc->mutex, well zapping
> > pages can also be done under the vma specific lock - if that helps?
> > 
> > Freeing page tables is different though, that needs more locking, but I
> > don't think this is an issue for you.
> > 
> > [1]. https://lore.kernel.org/all/20240215182756.3448972-1-lokeshgidra@google.com/
> 
> ha, I was not aware of this. I'll have a look thanks.

Happy to help.
Liam

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ