ANDROID: vendor_hooks: change the argument to 'lock struct' for some hooks

To count some information about locks, we need to replace the argument
'current' by 'lock struct' for these four hooks.
- android_vh_record_mutex_lock_starttime
- android_vh_record_rtmutex_lock_starttime
- android_vh_record_rwsem_lock_starttime
- android_vh_record_pcpu_rwsem_starttime

Bug: 336412598
Change-Id: I52d610079023df0feb1173ec99a6c72d12483f80
Signed-off-by: xieliujie <xieliujie@oppo.com>
This commit is contained in:
xieliujie
2024-04-23 14:16:00 +08:00
committed by Treehugger Robot
parent 3d98011e2a
commit 5af73be864
6 changed files with 37 additions and 36 deletions
+6 -6
View File
@@ -9,9 +9,6 @@
#include <linux/rcu_sync.h>
#include <linux/lockdep.h>
void _trace_android_vh_record_pcpu_rwsem_starttime(
struct task_struct *tsk, unsigned long settime);
struct percpu_rw_semaphore {
struct rcu_sync rss;
unsigned int __percpu *read_count;
@@ -23,6 +20,9 @@ struct percpu_rw_semaphore {
#endif
};
void _trace_android_vh_record_pcpu_rwsem_starttime(
struct percpu_rw_semaphore *sem, unsigned long settime);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname },
#else
@@ -70,7 +70,7 @@ static inline void percpu_down_read(struct percpu_rw_semaphore *sem)
* The preempt_enable() prevents the compiler from
* bleeding the critical section out.
*/
_trace_android_vh_record_pcpu_rwsem_starttime(current, jiffies);
_trace_android_vh_record_pcpu_rwsem_starttime(sem, jiffies);
preempt_enable();
}
@@ -93,7 +93,7 @@ static inline bool percpu_down_read_trylock(struct percpu_rw_semaphore *sem)
*/
if (ret) {
_trace_android_vh_record_pcpu_rwsem_starttime(current, jiffies);
_trace_android_vh_record_pcpu_rwsem_starttime(sem, jiffies);
rwsem_acquire_read(&sem->dep_map, 0, 1, _RET_IP_);
}
@@ -124,7 +124,7 @@ static inline void percpu_up_read(struct percpu_rw_semaphore *sem)
this_cpu_dec(*sem->read_count);
rcuwait_wake_up(&sem->writer);
}
_trace_android_vh_record_pcpu_rwsem_starttime(current, 0);
_trace_android_vh_record_pcpu_rwsem_starttime(sem, 0);
preempt_enable();
}
+9 -8
View File
@@ -14,6 +14,7 @@
*/
struct mutex;
struct rt_mutex;
struct rt_mutex_base;
struct rw_semaphore;
struct task_struct;
@@ -114,17 +115,17 @@ DECLARE_HOOK(android_vh_mutex_unlock_slowpath,
TP_ARGS(lock));
DECLARE_HOOK(android_vh_record_mutex_lock_starttime,
TP_PROTO(struct task_struct *tsk, unsigned long settime_jiffies),
TP_ARGS(tsk, settime_jiffies));
TP_PROTO(struct mutex *lock, unsigned long settime_jiffies),
TP_ARGS(lock, settime_jiffies));
DECLARE_HOOK(android_vh_record_rtmutex_lock_starttime,
TP_PROTO(struct task_struct *tsk, unsigned long settime_jiffies),
TP_ARGS(tsk, settime_jiffies));
TP_PROTO(struct rt_mutex *lock, unsigned long settime_jiffies),
TP_ARGS(lock, settime_jiffies));
DECLARE_HOOK(android_vh_record_rwsem_lock_starttime,
TP_PROTO(struct task_struct *tsk, unsigned long settime_jiffies),
TP_ARGS(tsk, settime_jiffies));
TP_PROTO(struct rw_semaphore *sem, unsigned long settime_jiffies),
TP_ARGS(sem, settime_jiffies));
DECLARE_HOOK(android_vh_record_pcpu_rwsem_starttime,
TP_PROTO(struct task_struct *tsk, unsigned long settime_jiffies),
TP_ARGS(tsk, settime_jiffies));
TP_PROTO(struct percpu_rw_semaphore *sem, unsigned long settime_jiffies),
TP_ARGS(sem, settime_jiffies));
#endif /* _TRACE_HOOK_DTASK_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
+6 -6
View File
@@ -148,7 +148,7 @@ static __always_inline bool __mutex_trylock_fast(struct mutex *lock)
unsigned long zero = 0UL;
if (atomic_long_try_cmpxchg_acquire(&lock->owner, &zero, curr)) {
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
trace_android_vh_record_mutex_lock_starttime(lock, jiffies);
return true;
}
@@ -537,12 +537,12 @@ void __sched mutex_unlock(struct mutex *lock)
{
#ifndef CONFIG_DEBUG_LOCK_ALLOC
if (__mutex_unlock_fast(lock)) {
trace_android_vh_record_mutex_lock_starttime(current, 0);
trace_android_vh_record_mutex_lock_starttime(lock, 0);
return;
}
#endif
__mutex_unlock_slowpath(lock, _RET_IP_);
trace_android_vh_record_mutex_lock_starttime(current, 0);
trace_android_vh_record_mutex_lock_starttime(lock, 0);
}
EXPORT_SYMBOL(mutex_unlock);
@@ -614,7 +614,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
if (ww_ctx)
ww_mutex_set_context_fastpath(ww, ww_ctx);
trace_contention_end(lock, 0);
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
trace_android_vh_record_mutex_lock_starttime(lock, jiffies);
preempt_enable();
return 0;
}
@@ -758,7 +758,7 @@ skip_wait:
raw_spin_unlock(&current->blocked_lock);
raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
wake_up_q(&wake_q);
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
trace_android_vh_record_mutex_lock_starttime(lock, jiffies);
preempt_enable();
return 0;
@@ -1167,7 +1167,7 @@ int __sched mutex_trylock(struct mutex *lock)
locked = __mutex_trylock(lock);
if (locked) {
trace_android_vh_record_mutex_lock_starttime(current, jiffies);
trace_android_vh_record_mutex_lock_starttime(lock, jiffies);
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
}
+4 -4
View File
@@ -19,10 +19,10 @@
* will result to build-err. So we create
* func:_trace_android_vh_record_pcpu_rwsem_starttime for percpu-rwsem.h to call.
*/
void _trace_android_vh_record_pcpu_rwsem_starttime(struct task_struct *tsk,
void _trace_android_vh_record_pcpu_rwsem_starttime(struct percpu_rw_semaphore *sem,
unsigned long settime)
{
trace_android_vh_record_pcpu_rwsem_starttime(tsk, settime);
trace_android_vh_record_pcpu_rwsem_starttime(sem, settime);
}
EXPORT_SYMBOL_GPL(_trace_android_vh_record_pcpu_rwsem_starttime);
@@ -268,7 +268,7 @@ void __sched percpu_down_write(struct percpu_rw_semaphore *sem)
rcuwait_wait_event(&sem->writer, readers_active_check(sem), TASK_UNINTERRUPTIBLE);
if (contended)
trace_contention_end(sem, 0);
trace_android_vh_record_pcpu_rwsem_starttime(current, jiffies);
trace_android_vh_record_pcpu_rwsem_starttime(sem, jiffies);
}
EXPORT_SYMBOL_GPL(percpu_down_write);
@@ -299,6 +299,6 @@ void percpu_up_write(struct percpu_rw_semaphore *sem)
* exclusive write lock because its counting.
*/
rcu_sync_exit(&sem->rss);
trace_android_vh_record_pcpu_rwsem_starttime(current, 0);
trace_android_vh_record_pcpu_rwsem_starttime(sem, 0);
}
EXPORT_SYMBOL_GPL(percpu_up_write);
+3 -3
View File
@@ -32,7 +32,7 @@ static __always_inline int __rt_mutex_lock_common(struct rt_mutex *lock,
if (ret)
mutex_release(&lock->dep_map, _RET_IP_);
else
trace_android_vh_record_rtmutex_lock_starttime(current, jiffies);
trace_android_vh_record_rtmutex_lock_starttime(lock, jiffies);
return ret;
}
@@ -126,7 +126,7 @@ int __sched rt_mutex_trylock(struct rt_mutex *lock)
ret = __rt_mutex_trylock(&lock->rtmutex);
if (ret) {
trace_android_vh_record_rtmutex_lock_starttime(current, jiffies);
trace_android_vh_record_rtmutex_lock_starttime(lock, jiffies);
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
}
@@ -141,7 +141,7 @@ EXPORT_SYMBOL_GPL(rt_mutex_trylock);
*/
void __sched rt_mutex_unlock(struct rt_mutex *lock)
{
trace_android_vh_record_rtmutex_lock_starttime(current, 0);
trace_android_vh_record_rtmutex_lock_starttime(lock, 0);
mutex_release(&lock->dep_map, _RET_IP_);
__rt_mutex_unlock(&lock->rtmutex);
}
+9 -9
View File
@@ -256,7 +256,7 @@ static inline bool rwsem_read_trylock(struct rw_semaphore *sem, long *cntp)
if (!(*cntp & RWSEM_READ_FAILED_MASK)) {
rwsem_set_reader_owned(sem);
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
return true;
}
@@ -268,7 +268,7 @@ static inline bool rwsem_write_trylock(struct rw_semaphore *sem)
long tmp = RWSEM_UNLOCKED_VALUE;
if (atomic_long_try_cmpxchg_acquire(&sem->count, &tmp, RWSEM_WRITER_LOCKED)) {
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
rwsem_set_owner(sem);
return true;
}
@@ -1044,7 +1044,7 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat
raw_spin_unlock_irq(&sem->wait_lock);
wake_up_q(&wake_q);
}
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
return sem;
}
@@ -1114,7 +1114,7 @@ queue:
trace_android_vh_rwsem_read_wait_finish(sem);
lockevent_inc(rwsem_rlock);
trace_contention_end(sem, 0);
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
return sem;
out_nolock:
@@ -1139,7 +1139,7 @@ rwsem_down_write_slowpath(struct rw_semaphore *sem, int state)
/* do optimistic spinning and steal lock if possible */
if (rwsem_can_spin_on_owner(sem) && rwsem_optimistic_spin(sem)) {
/* rwsem_optimistic_spin() implies ACQUIRE on success */
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
return sem;
}
@@ -1220,7 +1220,7 @@ trylock_again:
raw_spin_unlock_irq(&sem->wait_lock);
lockevent_inc(rwsem_wlock);
trace_contention_end(sem, 0);
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
return sem;
out_nolock:
@@ -1327,7 +1327,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
tmp + RWSEM_READER_BIAS)) {
rwsem_set_reader_owned(sem);
ret = 1;
trace_android_vh_record_rwsem_lock_starttime(current, jiffies);
trace_android_vh_record_rwsem_lock_starttime(sem, jiffies);
break;
}
}
@@ -1392,7 +1392,7 @@ static inline void __up_read(struct rw_semaphore *sem)
clear_nonspinnable(sem);
rwsem_wake(sem);
}
trace_android_vh_record_rwsem_lock_starttime(current, 0);
trace_android_vh_record_rwsem_lock_starttime(sem, 0);
preempt_enable();
}
@@ -1416,7 +1416,7 @@ static inline void __up_write(struct rw_semaphore *sem)
tmp = atomic_long_fetch_add_release(-RWSEM_WRITER_LOCKED, &sem->count);
if (unlikely(tmp & RWSEM_FLAG_WAITERS))
rwsem_wake(sem);
trace_android_vh_record_rwsem_lock_starttime(current, 0);
trace_android_vh_record_rwsem_lock_starttime(sem, 0);
preempt_enable();
}