From 40f3c9d658a5017a7063eb09cb8f0193c42aa29e Mon Sep 17 00:00:00 2001 From: liliangliang Date: Sun, 7 Apr 2024 15:19:02 +0800 Subject: [PATCH] ANDROID: vendor_hooks: add vendor hooks for fuse request Add hooks to fuse queue request and request end so we can do boost to those background tasks which block the UX related task. Bug: 333220630 Change-Id: I9be59ed88675c5102c57ba9cbd26cf4df3d2fd7f Signed-off-by: liliangliang (cherry picked from commit e520c2932df0d1bbf83ae45c82ac01fd41655d77) --- drivers/android/vendor_hooks.c | 3 +++ fs/fuse/dev.c | 4 ++++ include/trace/hooks/fuse.h | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 include/trace/hooks/fuse.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index a45022e569e2..9c7a0383c73d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -73,6 +73,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -417,3 +418,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_hibernate_save_cmp_len); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_read_lazy_flag); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_tsk_need_resched_lazy); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_read_fault); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_queue_request_and_unlock); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fuse_request_end); diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 90c8fd9b805f..c9ddc97e4782 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -23,6 +23,8 @@ #include #include +#include + MODULE_ALIAS_MISCDEV(FUSE_MINOR); MODULE_ALIAS("devname:fuse"); @@ -234,6 +236,7 @@ __releases(fiq->lock) fuse_len_args(req->args->in_numargs, (struct fuse_arg *) req->args->in_args); list_add_tail(&req->list, &fiq->pending); + trace_android_vh_queue_request_and_unlock(&fiq->waitq, sync); fiq->ops->wake_pending_and_unlock(fiq, sync); } @@ -331,6 +334,7 @@ void fuse_request_end(struct fuse_req *req) } else { /* Wake up waiter sleeping in request_wait_answer() */ wake_up(&req->waitq); + trace_android_vh_fuse_request_end(current); } if (test_bit(FR_ASYNC, &req->flags)) diff --git a/include/trace/hooks/fuse.h b/include/trace/hooks/fuse.h new file mode 100644 index 000000000000..a4267b47d5c0 --- /dev/null +++ b/include/trace/hooks/fuse.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fuse +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH trace/hooks +#if !defined(_TRACE_HOOK_FUSE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_FUSE_H +#include +/* + * Following tracepoints are not exported in tracefs and provide a + * mechanism for vendor modules to hook and extend functionality + */ + +struct wait_queue_head; +DECLARE_HOOK(android_vh_queue_request_and_unlock, + TP_PROTO(struct wait_queue_head *wq_head, bool sync), + TP_ARGS(wq_head, sync)); +DECLARE_HOOK(android_vh_fuse_request_end, + TP_PROTO(struct task_struct *self), + TP_ARGS(self)); + +#endif /* _TRACE_HOOK_FUSE_H */ +/* This part must be outside protection */ +#include