ANDROID: vendor_hooks: Add hooks for rwsem and mutex

Add hooks to apply oem's optimization of rwsem and mutex

Bug: 182237112
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I6332623732e2d6826b8b61087ca74e55393e0c3d
(cherry picked from commit 80b4341d05)
This commit is contained in:
xieliujie
2021-03-09 22:15:47 +08:00
committed by Todd Kjos
parent 3e3677f8f1
commit 0902cc73b7
3 changed files with 18 additions and 1 deletions

View File

@@ -311,6 +311,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_new_device_added);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_pre); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_pre);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_post); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_post);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_regmap_update); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_regmap_update);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_buf_release); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_buf_release);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pass_input_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pass_input_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_check_status); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_check_status);

View File

@@ -45,6 +45,17 @@ DECLARE_HOOK(android_vh_sched_show_task,
TP_PROTO(struct task_struct *task), TP_PROTO(struct task_struct *task),
TP_ARGS(task)); TP_ARGS(task));
struct mutex_waiter;
DECLARE_HOOK(android_vh_alter_mutex_list_add,
TP_PROTO(struct mutex *lock,
struct mutex_waiter *waiter,
struct list_head *list,
bool *already_on_list),
TP_ARGS(lock, waiter, list, already_on_list));
DECLARE_HOOK(android_vh_mutex_unlock_slowpath,
TP_PROTO(struct mutex *lock),
TP_ARGS(lock));
#endif /* _TRACE_HOOK_DTASK_H */ #endif /* _TRACE_HOOK_DTASK_H */
/* This part must be outside protection */ /* This part must be outside protection */
#include <trace/define_trace.h> #include <trace/define_trace.h>

View File

@@ -201,9 +201,12 @@ static void
__mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter, __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
struct list_head *list) struct list_head *list)
{ {
bool already_on_list = false;
debug_mutex_add_waiter(lock, waiter, current); debug_mutex_add_waiter(lock, waiter, current);
list_add_tail(&waiter->list, list); trace_android_vh_alter_mutex_list_add(lock, waiter, list, &already_on_list);
if (!already_on_list)
list_add_tail(&waiter->list, list);
if (__mutex_waiter_is_first(lock, waiter)) if (__mutex_waiter_is_first(lock, waiter))
__mutex_set_flag(lock, MUTEX_FLAG_WAITERS); __mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
} }
@@ -895,6 +898,7 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
if (owner & MUTEX_FLAG_HANDOFF) if (owner & MUTEX_FLAG_HANDOFF)
__mutex_handoff(lock, next); __mutex_handoff(lock, next);
trace_android_vh_mutex_unlock_slowpath(lock);
raw_spin_unlock(&lock->wait_lock); raw_spin_unlock(&lock->wait_lock);
wake_up_q(&wake_q); wake_up_q(&wake_q);