Commit b15655b1 authored by Carlos Llamas's avatar Carlos Llamas Committed by Greg Kroah-Hartman

Revert "binder_alloc: add missing mmap_lock calls when using the VMA"

This reverts commit 44e602b4.

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: 44e602b4 ("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: default avatarCarlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/20230502201220.1756319-1-cmllamas@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bdc1c5fa
...@@ -380,15 +380,12 @@ static struct binder_buffer *binder_alloc_new_buf_locked( ...@@ -380,15 +380,12 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
size_t size, data_offsets_size; size_t size, data_offsets_size;
int ret; int ret;
mmap_read_lock(alloc->mm);
if (!binder_alloc_get_vma(alloc)) { if (!binder_alloc_get_vma(alloc)) {
mmap_read_unlock(alloc->mm);
binder_alloc_debug(BINDER_DEBUG_USER_ERROR, binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
"%d: binder_alloc_buf, no vma\n", "%d: binder_alloc_buf, no vma\n",
alloc->pid); alloc->pid);
return ERR_PTR(-ESRCH); return ERR_PTR(-ESRCH);
} }
mmap_read_unlock(alloc->mm);
data_offsets_size = ALIGN(data_size, sizeof(void *)) + data_offsets_size = ALIGN(data_size, sizeof(void *)) +
ALIGN(offsets_size, sizeof(void *)); ALIGN(offsets_size, sizeof(void *));
...@@ -916,25 +913,17 @@ void binder_alloc_print_pages(struct seq_file *m, ...@@ -916,25 +913,17 @@ void binder_alloc_print_pages(struct seq_file *m,
* Make sure the binder_alloc is fully initialized, otherwise we might * Make sure the binder_alloc is fully initialized, otherwise we might
* read inconsistent state. * read inconsistent state.
*/ */
if (binder_alloc_get_vma(alloc) != NULL) {
mmap_read_lock(alloc->mm); for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
if (binder_alloc_get_vma(alloc) == NULL) { page = &alloc->pages[i];
mmap_read_unlock(alloc->mm); if (!page->page_ptr)
goto uninitialized; free++;
} else if (list_empty(&page->lru))
active++;
mmap_read_unlock(alloc->mm); else
for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) { lru++;
page = &alloc->pages[i]; }
if (!page->page_ptr)
free++;
else if (list_empty(&page->lru))
active++;
else
lru++;
} }
uninitialized:
mutex_unlock(&alloc->mutex); mutex_unlock(&alloc->mutex);
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free); seq_printf(m, " pages: %d:%d:%d\n", active, lru, free);
seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high); seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment