public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/8] binder: faster page installations
@ 2024-11-08 19:10 Carlos Llamas
  2024-11-08 19:10 ` [PATCH v3 1/8] Revert "binder: switch alloc->mutex to spinlock_t" Carlos Llamas
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Carlos Llamas @ 2024-11-08 19:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, kernel-team, Carlos Llamas, Alice Ryhl, Barry Song,
	David Hildenbrand, Liam R. Howlett, Matthew Wilcox, Minchan Kim,
	Nhat Pham, Johannes Weiner, Suren Baghdasaryan, Todd Kjos,
	Viktor Martensson, Hillf Danton, Lorenzo Stoakes

The main focus of these patches is to improve the performance of binder
page installations, primarily by reducing contention on the mmap_lock.
The idea is to allow concurrent page insertion by leveraging per-vma
locking and get_user_pages_remote().

Unfortunately, this required reverting the alloc->lock spinlock back
into a mutex in order to serialize with the shrinker. At least until
finding a better solution e.g. support page zapping with a spinlock.
The trade off is still quite worth it though.

Other patches are also included that remove unsafe and redundant things
such as the alloc->vma pointer or the struct binder_lru_page concept.

Note: I'll work on setting up a page fault handler for binder next.
I believe an idea from Alice Ryhl to deferred the page insertions will
make this finally feasible. I only need to figure out a few performance
bits but if/when done most of the manual page insertion code in binder
could be dropped. :)

Changelog:

v3:
 * collect "Reviewed-by" tags from Suren
 * use full commit subject in revert (not only sha1)
 * add "goto unlock" label for vma_lookup() failures
 * address -ENOMEM error override in separate patch
 * squash "remove alloc->vma" patch into alloc->mapped patch
 * pass 'struct binder_alloc *' to  binder_page_lookup() too
 * factor out individual mmget_not_zero()/mmput_async() calls
 * cleanup binder_page_insert() to avoid using goto
 * document only one mapping allowed per binder instance
 * check binder_alloc_is_mapped() in binder_page_lookup()
 * remove no longer need local page_to_free pointer

v2:
https://lore.kernel.org/all/20241107040239.2847143-1-cmllamas@google.com/
 * fix locking order when upgrading from vma lock to mmap lock
 * switch folio_walk_start() for get_user_pages_remote()
 * release vma/mmap locks and mmput() right after vm_insert_page()
 * add binder_page_alloc() helper for binder_install_single_page()

v1:
https://lore.kernel.org/all/20241105200258.2380168-1-cmllamas@google.com/

Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Barry Song <v-songbaohua@oppo.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Viktor Martensson <vmartensson@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

Carlos Llamas (8):
  Revert "binder: switch alloc->mutex to spinlock_t"
  binder: concurrent page installation
  binder: select correct nid for pages in LRU
  binder: remove struct binder_lru_page
  binder: replace alloc->vma with alloc->mapped
  binder: rename alloc->buffer to vm_start
  binder: use per-vma lock in page installation
  binder: propagate vm_insert_page() errors

 drivers/android/binder.c                |   2 +-
 drivers/android/binder_alloc.c          | 313 ++++++++++++++----------
 drivers/android/binder_alloc.h          |  36 +--
 drivers/android/binder_alloc_selftest.c |  18 +-
 drivers/android/binder_trace.h          |   2 +-
 5 files changed, 207 insertions(+), 164 deletions(-)

-- 
2.47.0.277.g8800431eea-goog


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-11-12 15:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 19:10 [PATCH v3 0/8] binder: faster page installations Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 1/8] Revert "binder: switch alloc->mutex to spinlock_t" Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 2/8] binder: concurrent page installation Carlos Llamas
2024-11-08 20:41   ` Liam R. Howlett
2024-11-08 22:26     ` Carlos Llamas
2024-11-09  3:58       ` Liam R. Howlett
2024-11-12 11:10   ` David Hildenbrand
2024-11-12 14:43     ` Carlos Llamas
2024-11-12 14:53       ` David Hildenbrand
2024-11-12 15:15         ` Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 3/8] binder: select correct nid for pages in LRU Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 4/8] binder: remove struct binder_lru_page Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 5/8] binder: replace alloc->vma with alloc->mapped Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 6/8] binder: rename alloc->buffer to vm_start Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 7/8] binder: use per-vma lock in page installation Carlos Llamas
2024-11-08 19:10 ` [PATCH v3 8/8] binder: propagate vm_insert_page() errors Carlos Llamas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox