Skip to content

Commit dad8109

Browse files
Carlos Llamassmb49
authored andcommitted
Revert "binder_alloc: add missing mmap_lock calls when using the VMA"
BugLink: https://bugs.launchpad.net/bugs/2028979 commit b15655b upstream. This reverts commit 44e602b. This caused a performance regression particularly when pages are getting reclaimed. We don't need to acquire the mmap_lock to determine when the binder buffer has been fully initialized. A subsequent patch will bring back the lockless approach for this. [cmllamas: resolved trivial conflicts with renaming of alloc->mm] Fixes: 44e602b ("binder_alloc: add missing mmap_lock calls when using the VMA") Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: stable@vger.kernel.org Signed-off-by: Carlos Llamas <cmllamas@google.com> Link: https://lore.kernel.org/r/20230502201220.1756319-1-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent a67753e commit dad8109

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

drivers/android/binder_alloc.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,12 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
379379
size_t size, data_offsets_size;
380380
int ret;
381381

382-
mmap_read_lock(alloc->mm);
383382
if (!binder_alloc_get_vma(alloc)) {
384-
mmap_read_unlock(alloc->mm);
385383
binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
386384
"%d: binder_alloc_buf, no vma\n",
387385
alloc->pid);
388386
return ERR_PTR(-ESRCH);
389387
}
390-
mmap_read_unlock(alloc->mm);
391388

392389
data_offsets_size = ALIGN(data_size, sizeof(void *)) +
393390
ALIGN(offsets_size, sizeof(void *));
@@ -915,25 +912,17 @@ void binder_alloc_print_pages(struct seq_file *m,
915912
* Make sure the binder_alloc is fully initialized, otherwise we might
916913
* read inconsistent state.
917914
*/
918-
919-
mmap_read_lock(alloc->mm);
920-
if (binder_alloc_get_vma(alloc) == NULL) {
921-
mmap_read_unlock(alloc->mm);
922-
goto uninitialized;
923-
}
924-
925-
mmap_read_unlock(alloc->mm);
926-
for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
927-
page = &alloc->pages[i];
928-
if (!page->page_ptr)
929-
free++;
930-
else if (list_empty(&page->lru))
931-
active++;
932-
else
933-
lru++;
915+
if (binder_alloc_get_vma(alloc) != NULL) {
916+
for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
917+
page = &alloc->pages[i];
918+
if (!page->page_ptr)
919+
free++;
920+
else if (list_empty(&page->lru))
921+
active++;
922+
else
923+
lru++;
924+
}
934925
}
935-
936-
uninitialized:
937926
mutex_unlock(&alloc->mutex);
938927
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free);
939928
seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high);

0 commit comments

Comments
 (0)