ANDROID: vendor_hooks: add hook for kernel workqueue Add hooks in __queue_work() and process_one_work() to record the working status and execution time of each delegated work. Also add hooks in kick_pool() to allow us to know the next worker and the first work, which is used to apply specific scheduling policies to worker. Bug: 374015971 Bug: 375071856 Change-Id: Id84541461b5f37300b5cad1cfbef4533aa0390d5 Signed-off-by: liulu liu <liulu.liu@honor.corp-partner.google.com> (cherry picked from commit 69c4e48308b453eb270dfc50deecb3131b0426cb)
diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 780ab90..56cbcb2 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c
@@ -516,3 +516,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_retry); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_group_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_node_memcgs); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swap_writepage); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_queue_work); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_wake_idle_worker);
diff --git a/include/trace/hooks/wqlockup.h b/include/trace/hooks/wqlockup.h index 5a34038..4530ad0 100644 --- a/include/trace/hooks/wqlockup.h +++ b/include/trace/hooks/wqlockup.h
@@ -18,6 +18,14 @@ DECLARE_HOOK(android_vh_wq_lockup_pool, TP_PROTO(int cpu, unsigned long pool_ts), TP_ARGS(cpu, pool_ts)); +DECLARE_HOOK(android_vh_wq_queue_work, + TP_PROTO(struct work_struct *work, char *wq_name, unsigned int wq_flags, unsigned int cpu), + TP_ARGS(work, wq_name, wq_flags, cpu)); + +DECLARE_HOOK(android_vh_wq_wake_idle_worker, + TP_PROTO(struct task_struct *worker, struct work_struct *work), + TP_ARGS(worker, work)); + #ifndef __GENKSYMS__ DECLARE_RESTRICTED_HOOK(android_rvh_alloc_and_link_pwqs, TP_PROTO(struct workqueue_struct *wq, int *ret, bool *skip),
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 049dc4a..bb96b0f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c
@@ -1150,6 +1150,8 @@ static bool kick_pool(struct worker_pool *pool) get_work_pwq(work)->stats[PWQ_STAT_REPATRIATED]++; } #endif + trace_android_vh_wq_wake_idle_worker(p, list_first_entry(&pool->worklist, + struct work_struct, entry)); wake_up_process(p); return true; } @@ -1796,6 +1798,8 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, /* pwq determined, queue */ trace_workqueue_queue_work(req_cpu, pwq, work); + trace_android_vh_wq_queue_work(work, wq->name, wq->flags, cpu); + if (WARN_ON(!list_empty(&work->entry))) goto out;