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 0902cc73b793f8b8cc2a80943d85d4ca9b98278b)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
This commit is contained in:
xieliujie 2021-03-09 22:15:47 +08:00 committed by Carlos Llamas
parent 54d553865e
commit 86c4152970
3 changed files with 19 additions and 1 deletions

View File

@ -193,3 +193,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_modify_src_caps);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_log);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_gfp_zone_flags);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_readahead_gfp_mask);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath);

View File

@ -59,6 +59,18 @@ DECLARE_HOOK(android_vh_record_rwsem_lock_starttime,
DECLARE_HOOK(android_vh_record_pcpu_rwsem_starttime,
TP_PROTO(struct task_struct *tsk, unsigned long settime_jiffies),
TP_ARGS(tsk, settime_jiffies));
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 */
/* This part must be outside protection */

View File

@ -210,9 +210,12 @@ static void
__mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
struct list_head *list)
{
bool already_on_list = false;
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))
__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
}
@ -957,6 +960,7 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
if (owner & MUTEX_FLAG_HANDOFF)
__mutex_handoff(lock, next);
trace_android_vh_mutex_unlock_slowpath(lock);
raw_spin_unlock(&lock->wait_lock);
wake_up_q(&wake_q);