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
This commit is contained in:
xieliujie
2021-03-09 22:15:47 +08:00
committed by Todd Kjos
parent ec89366c1f
commit 80b4341d05
5 changed files with 21 additions and 1 deletions

View File

@@ -176,3 +176,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_eff_value);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpufreq_transition);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished);
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_rwsem_wake_finish);

View File

@@ -37,6 +37,15 @@ struct task_struct;
DECLARE_HOOK(android_vh_sched_show_task,
TP_PROTO(struct task_struct *task),
TP_ARGS(task));
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));
/* macro versions of hooks are no longer required */

View File

@@ -26,6 +26,9 @@ DECLARE_HOOK(android_vh_alter_rwsem_list_add,
struct rw_semaphore *sem,
bool *already_on_list),
TP_ARGS(waiter, sem, already_on_list));
DECLARE_HOOK(android_vh_rwsem_wake_finish,
TP_PROTO(struct rw_semaphore *sem),
TP_ARGS(sem));
/* macro versions of hooks are no longer required */

View File

@@ -210,9 +210,12 @@ static void __sched
__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);
}
@@ -1280,6 +1283,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);
spin_unlock(&lock->wait_lock);
wake_up_q(&wake_q);

View File

@@ -1313,6 +1313,7 @@ static struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem, long count)
if (!list_empty(&sem->wait_list))
rwsem_mark_wake(sem, RWSEM_WAKE_ANY, &wake_q);
trace_android_vh_rwsem_wake_finish(sem);
raw_spin_unlock_irqrestore(&sem->wait_lock, flags);
wake_up_q(&wake_q);