--- zzzz-none-000/linux-2.6.39.4/arch/x86/include/asm/spinlock.h 2011-08-03 19:43:28.000000000 +0000 +++ puma6-atom-6490-729/linux-2.6.39.4/arch/x86/include/asm/spinlock.h 2021-11-10 13:38:14.000000000 +0000 @@ -7,6 +7,43 @@ #include #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 * @@ -187,21 +224,26 @@ static __always_inline void arch_spin_lock(arch_spinlock_t *lock) { + avm_simple_profiling_spin_gettime(); __ticket_spin_lock(lock); + avm_simple_profiling_spin_lock(lock); } static __always_inline int arch_spin_trylock(arch_spinlock_t *lock) { - return __ticket_spin_trylock(lock); + int ret = __ticket_spin_trylock(lock); + avm_simple_profiling_spin_trylock(lock, ret); + return ret; } static __always_inline void arch_spin_unlock(arch_spinlock_t *lock) { + avm_simple_profiling_spin_unlock(lock); __ticket_spin_unlock(lock); } static __always_inline void arch_spin_lock_flags(arch_spinlock_t *lock, - unsigned long flags) + unsigned long flags __attribute__((unused))) { arch_spin_lock(lock); }