summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Llamas <cmllamas@google.com>2023-12-01 17:21:54 +0000
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-01-09 01:15:49 +0000
commitb93c9f8565f53a1704c542da51ff530ad0543340 (patch)
tree417da76520290c3e9b9ddd067e0c9a6a808cf1ca
parentf6b1c043ae01fe5d31e3f07e229eaca0b491df4a (diff)
downloadcommon-b93c9f8565f53a1704c542da51ff530ad0543340.tar.gz
FROMGIT: binder: refactor binder_delete_free_buffer()
Skip the freelist call immediately as needed, instead of continuing the pointless checks. Also, drop the debug logs that we don't really need. Signed-off-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20231201172212.1813387-26-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Bug: 254650075 (cherry picked from commit f07b83a48e944c8a1cc1e9f6703fae5e34df2ba4 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-next) Change-Id: I035bd6cd5c06ec984cd6eb3c3b53e0958c64df4f Signed-off-by: Carlos Llamas <cmllamas@google.com>
-rw-r--r--drivers/android/binder_alloc.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 215c306928e7..c3e6883f0958 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -639,48 +639,26 @@ static unsigned long prev_buffer_end_page(struct binder_buffer *buffer)
static void binder_delete_free_buffer(struct binder_alloc *alloc,
struct binder_buffer *buffer)
{
- struct binder_buffer *prev, *next = NULL;
- bool to_free = true;
+ struct binder_buffer *prev, *next;
+
+ if (PAGE_ALIGNED(buffer->user_data))
+ goto skip_freelist;
BUG_ON(alloc->buffers.next == &buffer->entry);
prev = binder_buffer_prev(buffer);
BUG_ON(!prev->free);
- if (prev_buffer_end_page(prev) == buffer_start_page(buffer)) {
- to_free = false;
- binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
- "%d: merge free, buffer %lx share page with %lx\n",
- alloc->pid, buffer->user_data,
- prev->user_data);
- }
+ if (prev_buffer_end_page(prev) == buffer_start_page(buffer))
+ goto skip_freelist;
if (!list_is_last(&buffer->entry, &alloc->buffers)) {
next = binder_buffer_next(buffer);
- if (buffer_start_page(next) == buffer_start_page(buffer)) {
- to_free = false;
- binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
- "%d: merge free, buffer %lx share page with %lx\n",
- alloc->pid,
- buffer->user_data,
- next->user_data);
- }
+ if (buffer_start_page(next) == buffer_start_page(buffer))
+ goto skip_freelist;
}
- if (PAGE_ALIGNED(buffer->user_data)) {
- binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
- "%d: merge free, buffer start %lx is page aligned\n",
- alloc->pid, buffer->user_data);
- to_free = false;
- }
-
- if (to_free) {
- binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
- "%d: merge free, buffer %lx do not share page with %lx or %lx\n",
- alloc->pid, buffer->user_data,
- prev->user_data,
- next ? next->user_data : 0);
- binder_lru_freelist_add(alloc, buffer_start_page(buffer),
- buffer_start_page(buffer) + PAGE_SIZE);
- }
+ binder_lru_freelist_add(alloc, buffer_start_page(buffer),
+ buffer_start_page(buffer) + PAGE_SIZE);
+skip_freelist:
list_del(&buffer->entry);
kfree(buffer);
}