Skip to content

Commit b15655b

Browse files
Carlos Llamasgregkh
authored andcommitted
Revert "binder_alloc: add missing mmap_lock calls when using the VMA"
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>
1 parent bdc1c5f commit b15655b

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

drivers/android/binder_alloc.c

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

383-
mmap_read_lock(alloc->mm);
384383
if (!binder_alloc_get_vma(alloc)) {
385-
mmap_read_unlock(alloc->mm);
386384
binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
387385
"%d: binder_alloc_buf, no vma\n",
388386
alloc->pid);
389387
return ERR_PTR(-ESRCH);
390388
}
391-
mmap_read_unlock(alloc->mm);
392389

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

0 commit comments

Comments
 (0)