From 6e8c49bd14703d331cde0721ba097d3b236f2f29 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: 411279935 Change-Id: I349520b7e95a112d011af1c8b1b4c322ee61a7f5 Signed-off-by: liliangliang --- drivers/android/vendor_hooks.c | 3 +++ fs/fuse/dev.c | 3 +++ include/trace/hooks/fuse.h | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 include/trace/hooks/fuse.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 45115dc83b4a..6a472b0c3ecb 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -70,6 +70,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -365,6 +366,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_finish); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fuse_request_send); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fuse_request_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_sock_error); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_fastsyn); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_state_change); diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 67c48d2df8b7..e8eb8ea27284 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -22,6 +22,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include "fuse_trace.h" @@ -402,6 +403,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)) @@ -476,6 +478,7 @@ static void __fuse_request_send(struct fuse_req *req) BUG_ON(test_bit(FR_BACKGROUND, &req->flags)); + trace_android_vh_fuse_request_send(&fiq->waitq); /* acquire extra reference, since request is still needed after fuse_request_end() */ __fuse_get_request(req); diff --git a/include/trace/hooks/fuse.h b/include/trace/hooks/fuse.h new file mode 100644 index 000000000000..79229d12d711 --- /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_fuse_request_send, + TP_PROTO(struct wait_queue_head *wq_head), + TP_ARGS(wq_head)); +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