ANDROID: vendor_hook: add hooks to protect locking-tsk in cpu scheduler
Providing vendor hooks to record the start time of holding the lock, which protects rwsem/mutex locking-process from being preemptedfor a short time in some cases. - android_vh_record_mutex_lock_starttime - android_vh_record_rtmutex_lock_starttime - android_vh_record_rwsem_lock_starttime - android_vh_record_percpu_rwsem_lock_starttime Bug: 241191475 Signed-off-by: Peifeng Li <lipeifeng@oppo.com> Change-Id: I0e967a1e8b77c32a1ad588acd54028fae2f90c4e
This commit is contained in:

committed by
Matthias Männich

parent
fb39cdb9ea
commit
eed2741ae6
@@ -170,8 +170,10 @@ static __always_inline bool __mutex_trylock_fast(struct mutex *lock)
|
||||
unsigned long curr = (unsigned long)current;
|
||||
unsigned long zero = 0UL;
|
||||
|
||||
if (atomic_long_try_cmpxchg_acquire(&lock->owner, &zero, curr))
|
||||
if (atomic_long_try_cmpxchg_acquire(&lock->owner, &zero, curr)) {
|
||||
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -748,6 +750,7 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
|
||||
*/
|
||||
void __sched mutex_unlock(struct mutex *lock)
|
||||
{
|
||||
trace_android_vh_record_mutex_lock_starttime(current, 0);
|
||||
#ifndef CONFIG_DEBUG_LOCK_ALLOC
|
||||
if (__mutex_unlock_fast(lock))
|
||||
return;
|
||||
@@ -978,6 +981,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
|
||||
lock_acquired(&lock->dep_map, ip);
|
||||
if (ww_ctx)
|
||||
ww_mutex_set_context_fastpath(ww, ww_ctx);
|
||||
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
|
||||
preempt_enable();
|
||||
return 0;
|
||||
}
|
||||
@@ -1097,6 +1101,7 @@ skip_wait:
|
||||
|
||||
spin_unlock(&lock->wait_lock);
|
||||
preempt_enable();
|
||||
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
@@ -1433,8 +1438,10 @@ int __sched mutex_trylock(struct mutex *lock)
|
||||
#endif
|
||||
|
||||
locked = __mutex_trylock(lock);
|
||||
if (locked)
|
||||
if (locked) {
|
||||
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
|
||||
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
|
||||
}
|
||||
|
||||
return locked;
|
||||
}
|
||||
|
Reference in New Issue
Block a user