From 5723a22d2745fb6734578584eff70e0f7bd644f0 Mon Sep 17 00:00:00 2001 From: xieliujie Date: Fri, 23 Feb 2024 17:12:36 +0800 Subject: [PATCH] ANDROID: vendor_hooks: Add hooks for oem percpu-rwsem optimaton Recently we have discovered many lag issues caused by percpu_rwsem lock-holding tasks not being scheduled for a long time. we need to identify them and provide appropriate scheduling protection in our oem scheduler. To support this, we add one hook below: trace_android_vh_percpu_rwsem_wq_add Bug: 301066838 Change-Id: Id770c1a7978842abfc62d3fa9aeb5ac7a1904972 Signed-off-by: xieliujie --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/dtask.h | 4 ++++ kernel/locking/percpu-rwsem.c | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 5442af200773..c04674169488 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -175,6 +175,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_record_mutex_lock_starttime); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_record_rtmutex_lock_starttime); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_record_rwsem_lock_starttime); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_record_pcpu_rwsem_starttime); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_percpu_rwsem_wq_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_commit_creds); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_exit_creds); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_override_creds); diff --git a/include/trace/hooks/dtask.h b/include/trace/hooks/dtask.h index 5c6c04eb425b..0ada24dc250a 100644 --- a/include/trace/hooks/dtask.h +++ b/include/trace/hooks/dtask.h @@ -18,6 +18,7 @@ struct rt_mutex; struct rt_mutex_base; struct rw_semaphore; struct task_struct; +struct percpu_rw_semaphore; DECLARE_HOOK(android_vh_mutex_wait_start, TP_PROTO(struct mutex *lock), @@ -102,6 +103,9 @@ DECLARE_HOOK(android_vh_flush_work_wait_finish, DECLARE_HOOK(android_vh_sched_show_task, TP_PROTO(struct task_struct *task), TP_ARGS(task)); +DECLARE_HOOK(android_vh_percpu_rwsem_wq_add, + TP_PROTO(struct percpu_rw_semaphore *sem, bool reader), + TP_ARGS(sem, reader)); struct mutex_waiter; DECLARE_HOOK(android_vh_alter_mutex_list_add, diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index d07cc4959833..65731595483b 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -167,6 +167,7 @@ static void percpu_rwsem_wait(struct percpu_rw_semaphore *sem, bool reader) if (wait) { wq_entry.flags |= WQ_FLAG_EXCLUSIVE | reader * WQ_FLAG_CUSTOM; __add_wait_queue_entry_tail(&sem->waiters, &wq_entry); + trace_android_vh_percpu_rwsem_wq_add(sem, reader); } spin_unlock_irq(&sem->waiters.lock);