ANDROID: vendor_hooks: add hook in __mutex_unlock_slowpath()

This hook is used to modify the variables in mutex oemdata when the task releases mutex lock.
This code cannot be done in existing hook trace_android_vh_mutex_unlock_slowpath(), because it is executed after wake_up_q, and there is a risk that the mutex object has been freed.

Bug: 362700382

Change-Id: I7787c0ea51959642a010891606b2bc39fe056dd2
Signed-off-by: zhujingpeng <zhujingpeng@vivo.com>
This commit is contained in:
zhujingpeng 2024-08-28 21:50:56 +08:00 committed by Treehugger Robot
parent 8a0f09e1bc
commit 9f6bd03727
3 changed files with 5 additions and 0 deletions

View File

@ -293,6 +293,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_panic_unhandled);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_vcpu_exit_reason);
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_mutex_unlock_slowpath_before_wakeq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_track_hash);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_should_fault_around);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_id_remove);

View File

@ -97,6 +97,9 @@ DECLARE_HOOK(android_vh_alter_mutex_list_add,
DECLARE_HOOK(android_vh_mutex_unlock_slowpath,
TP_PROTO(struct mutex *lock),
TP_ARGS(lock));
DECLARE_HOOK(android_vh_mutex_unlock_slowpath_before_wakeq,
TP_PROTO(struct mutex *lock),
TP_ARGS(lock));
DECLARE_HOOK(android_vh_exit_signal_whether_wake,
TP_PROTO(struct task_struct *p, bool *wake),

View File

@ -974,6 +974,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_before_wakeq(lock);
raw_spin_unlock(&lock->wait_lock);
wake_up_q(&wake_q);