--- zzzz-none-000/linux-3.10.107/arch/mips/include/asm/spinlock.h 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/include/asm/spinlock.h 2021-11-10 11:53:54.000000000 +0000 @@ -14,6 +14,44 @@ #include #include + +/*--------------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------------*/ +#if defined(CONFIG_ENABLE_SPINLOCK_PROFILING_HOOKS) +extern int avm_simple_profiling_is_enabled_func(void); +extern unsigned int avm_get_cycles_func(void); + +#define avm_simple_profiling_spin_lock(lock) ({ \ + if(avm_simple_profiling_is_enabled_func()) { \ + unsigned int avm_simple_profiling_spinlock_endtime = avm_get_cycles_func(); \ + __avm_simple_profiling_spinlock(_RET_IP_, (unsigned int)lock, avm_simple_profiling_spinlock_endtime - avm_simple_profiling_spinlock_starttime, 0); \ + } \ +}) + +#define avm_simple_profiling_spin_trylock(lock, success) ({ \ + if(avm_simple_profiling_is_enabled_func()) { \ + __avm_simple_profiling_spinlock(_RET_IP_, (unsigned int)lock, 0, success ? 1 : 2); \ + } \ +}) + +#define avm_simple_profiling_spin_unlock(lock) ({ \ + if(avm_simple_profiling_is_enabled_func()) { \ + __avm_simple_profiling_spinlock(_RET_IP_, (unsigned int)lock, 0, 3); \ + } \ +}) + +#define avm_simple_profiling_spin_gettime() unsigned int avm_simple_profiling_spinlock_starttime = avm_get_cycles_func() + +extern void __avm_simple_profiling_spinlock(unsigned int addr, unsigned int lock, unsigned int time, unsigned int id); + +#else +static inline void avm_simple_profiling_spin_lock(void *lock __attribute__ ((unused))) { }; +static inline void avm_simple_profiling_spin_trylock(void *lock __attribute__ ((unused)), unsigned int success __attribute__ ((unused))) { }; +static inline void avm_simple_profiling_spin_unlock(void *lock __attribute__ ((unused))) { }; +static inline unsigned int avm_simple_profiling_spin_gettime(void) { return 0; } +#endif + + /* * Your basic SMP spinlocks, allowing only a single CPU anywhere * @@ -59,6 +97,8 @@ int tmp; int inc = 0x10000; + avm_simple_profiling_spin_gettime(); + if (R10000_LLSC_WAR) { __asm__ __volatile__ ( " .set push # arch_spin_lock \n" @@ -129,6 +169,7 @@ } smp_llsc_mb(); + avm_simple_profiling_spin_lock(lock); } static inline void arch_spin_unlock(arch_spinlock_t *lock) @@ -136,6 +177,7 @@ unsigned int serving_now = lock->h.serving_now + 1; wmb(); lock->h.serving_now = (u16)serving_now; + avm_simple_profiling_spin_unlock(lock); nudge_writes(); } @@ -196,6 +238,7 @@ smp_llsc_mb(); + avm_simple_profiling_spin_trylock(lock, tmp); return tmp; }