[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241119183250.3497547-1-cmllamas@google.com>
Date: Tue, 19 Nov 2024 18:32:33 +0000
From: Carlos Llamas <cmllamas@...gle.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, kernel-team@...roid.com,
Carlos Llamas <cmllamas@...gle.com>, Alice Ryhl <aliceryhl@...gle.com>,
Barry Song <v-songbaohua@...o.com>, David Hildenbrand <david@...hat.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Matthew Wilcox <willy@...radead.org>,
Minchan Kim <minchan@...nel.org>, Nhat Pham <nphamcs@...il.com>,
Johannes Weiner <hannes@...xchg.org>, Suren Baghdasaryan <surenb@...gle.com>, Todd Kjos <tkjos@...gle.com>,
Viktor Martensson <vmartensson@...gle.com>, Hillf Danton <hdanton@...a.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Subject: [PATCH v4 0/9] binder: faster page installations
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:
v4:
* add explicit FOLL_NOFAULT to get_user_pages_remote()
* per-vma locking to shrinker path (per Liam)
v3:
https://lore.kernel.org/all/20241108191057.3288442-1-cmllamas@google.com/
* 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@...gle.com>
Cc: Barry Song <v-songbaohua@...o.com>
Cc: David Hildenbrand <david@...hat.com>
Cc: Liam R. Howlett <Liam.Howlett@...cle.com>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Minchan Kim <minchan@...nel.org>
Cc: Nhat Pham <nphamcs@...il.com>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Suren Baghdasaryan <surenb@...gle.com>
Cc: Todd Kjos <tkjos@...gle.com>
Cc: Viktor Martensson <vmartensson@...gle.com>
Cc: Hillf Danton <hdanton@...a.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Carlos Llamas (9):
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
binder: use per-vma lock in page reclaiming
drivers/android/binder.c | 2 +-
drivers/android/binder_alloc.c | 345 ++++++++++++++----------
drivers/android/binder_alloc.h | 36 +--
drivers/android/binder_alloc_selftest.c | 18 +-
drivers/android/binder_trace.h | 2 +-
5 files changed, 233 insertions(+), 170 deletions(-)
--
2.47.0.338.g60cca15819-goog
Powered by blists - more mailing lists