--- zzzz-none-000/linux-2.6.39.4/arch/arm/include/asm/spinlock.h 2011-08-03 19:43:28.000000000 +0000 +++ puma6-atom-6490-729/linux-2.6.39.4/arch/arm/include/asm/spinlock.h 2021-11-10 13:38:14.000000000 +0000 @@ -5,6 +5,42 @@ #error SMP not supported on pre-ARMv6 CPUs #endif +/*--------------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------------*/ +#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 + /* * sev and wfe are ARMv6K extensions. Uniprocessor ARMv6 may not have the K * extensions, so when running on UP, we have to patch these instructions away. @@ -78,6 +114,8 @@ { unsigned long tmp; + avm_simple_profiling_spin_gettime(); + __asm__ __volatile__( "1: ldrex %0, [%1]\n" " teq %0, #0\n" @@ -90,6 +128,7 @@ : "cc"); smp_mb(); + avm_simple_profiling_spin_lock(lock); } static inline int arch_spin_trylock(arch_spinlock_t *lock) @@ -104,6 +143,7 @@ : "r" (&lock->lock), "r" (1) : "cc"); + avm_simple_profiling_spin_trylock(lock, tmp); if (tmp == 0) { smp_mb(); return 1; @@ -116,6 +156,8 @@ { smp_mb(); + avm_simple_profiling_spin_unlock(lock); + __asm__ __volatile__( " str %1, [%0]\n" :