Reapply "ANDROID: vendor_hooks: Add hook for binder_detect_low_async_space"

This reverts commit 637c8e0d372f1dfff53337a5db89f772577828d7.

Also squash commit db91c5d31a ("ANDROID: vendor_hook: rename the the
name of hooks"), which fixes the length of the vendor hook's name.
Rework the error return for a goto as this has been refactor too.
Finally, also fix spaces vs tabs.

Change-Id: I22c495eb81237c51c0f9f4d4f9f4f1cf0c8438a8
Signed-off-by: Carlos Llamas <cmllamas@google.com>
This commit is contained in:
Carlos Llamas 2024-05-28 16:50:12 +00:00
parent 7e855d1492
commit 81054a4507
3 changed files with 14 additions and 0 deletions

View file

@ -445,9 +445,19 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
struct binder_buffer *buffer;
unsigned long next_used_page;
unsigned long curr_last_page;
bool should_fail = false;
size_t buffer_size;
trace_android_vh_binder_alloc_new_buf_locked(size, &alloc->free_async_space, is_async);
trace_android_vh_binder_detect_low_async_space(is_async, &alloc->free_async_space,
current->tgid, &should_fail);
if (should_fail) {
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
"%d: binder_alloc_buf size %zd failed, not allowed to alloc more async space\n",
alloc->pid, size);
buffer = ERR_PTR(-EPERM);
goto out;
}
if (is_async && alloc->free_async_space < size) {
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,

View file

@ -391,6 +391,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_ioctl_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_looper_exited);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_spawn_new_thread);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_has_special_work_ilocked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_detect_low_async_space);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_delayacct_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_delayacct_tsk_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_delayacct_tsk_free);

View file

@ -82,6 +82,9 @@ DECLARE_HOOK(android_vh_binder_select_special_worklist,
DECLARE_HOOK(android_vh_binder_alloc_new_buf_locked,
TP_PROTO(size_t size, size_t *free_async_space, int is_async),
TP_ARGS(size, free_async_space, is_async));
DECLARE_HOOK(android_vh_binder_detect_low_async_space,
TP_PROTO(int is_async, size_t *free_async_space, int pid, bool *should_fail),
TP_ARGS(is_async, free_async_space, pid, should_fail));
struct binder_transaction_data;
DECLARE_HOOK(android_vh_binder_reply,
TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc,