From: Peter Dinda Date: Tue, 28 May 2013 22:19:39 +0000 (-0500) Subject: Lock checking enhancements X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ff1f595f17c72647db29bd1deb79fab2d88063e;p=palacios.releases.git Lock checking enhancements --- diff --git a/linux_module/lockcheck.c b/linux_module/lockcheck.c index bfa0566..eee6ce0 100644 --- a/linux_module/lockcheck.c +++ b/linux_module/lockcheck.c @@ -6,6 +6,11 @@ #include "lockcheck.h" +#define PRINT_LOCK_ALLOC 0 +#define PRINT_LOCK_FREE 0 +#define PRINT_LOCK_LOCK 0 +#define PRINT_LOCK_UNLOCK 0 + // How far up the stack to track the caller // 0 => palacios_... // 1 => v3_lock... @@ -331,8 +336,9 @@ void palacios_lockcheck_alloc(void *lock) clear_trace(l->lastirqlocker); clear_trace(l->lastirqunlocker); //INFO("LOCKCHECK: LOCK ALLOCATE 0x%p\n",lock); +#if PRINT_LOCK_ALLOC printlock("NEW LOCK", l); - //dump_stack(); +#endif } void palacios_lockcheck_free(void *lock) @@ -351,6 +357,11 @@ void palacios_lockcheck_free(void *lock) if ((l->irqcount)) { printlock("BAD IRQ COUNT AT FREE",l); } + +#if PRINT_LOCK_FREE + printlock("FREE LOCK",l); +#endif + free_lock_entry(l); } @@ -377,6 +388,10 @@ void palacios_lockcheck_lock(void *lock) lock_stack_lock(lock,0); +#if PRINT_LOCK_LOCK + printlock("LOCK",l); +#endif + } void palacios_lockcheck_unlock(void *lock) { @@ -399,6 +414,11 @@ void palacios_lockcheck_unlock(void *lock) l->lockcount--; backtrace(l->lastunlocker); +#if PRINT_LOCK_UNLOCK + printlock("UNLOCK",l); +#endif + + } void palacios_lockcheck_lock_irqsave(void *lock,unsigned long flags) @@ -426,6 +446,11 @@ void palacios_lockcheck_lock_irqsave(void *lock,unsigned long flags) lock_stack_lock(lock,1); +#if PRINT_LOCK_LOCK + printlock("LOCK_IRQSAVE",l); +#endif + + } @@ -451,5 +476,9 @@ void palacios_lockcheck_unlock_irqrestore(void *lock,unsigned long flags) lock_stack_unlock(lock,1); backtrace(l->lastirqunlocker); + +#if PRINT_LOCK_UNLOCK + printlock("UNLOCK_IRQRESTORE",l); +#endif } diff --git a/linux_module/palacios.h b/linux_module/palacios.h index 23519dc..ca35565 100644 --- a/linux_module/palacios.h +++ b/linux_module/palacios.h @@ -147,18 +147,19 @@ void palacios_yield_cpu(void); void palacios_yield_cpu_timed(unsigned int us); unsigned int palacios_get_cpu(void); unsigned int palacios_get_cpu_khz(void); -void *palacios_mutex_alloc(void); // allocates and inits a lock -void palacios_mutex_init(void *mutex); // use instead of spin_lock_init -void palacios_mutex_free(void *mutex); +void *palacios_mutex_alloc(void); // allocates and inits a lock +void palacios_mutex_init(void *mutex); // only inits a lock +void palacios_mutex_deinit(void *mutex); // only deinits a lock +void palacios_mutex_free(void *mutex); // deinits and frees a lock void palacios_mutex_lock(void *mutex, int must_spin); void palacios_mutex_unlock(void *mutex); void *palacios_mutex_lock_irqsave(void *mutex, int must_spin); void palacios_mutex_unlock_irqrestore(void *mutex, void *flags); - // Macros for spin-locks in the module code // By using these macros, the lock checker will be able // to see the module code as well as the core VMM #define palacios_spinlock_init(l) palacios_mutex_init(l) +#define palacios_spinlock_deinit(l) palacios_mutex_deinit(l) #define palacios_spinlock_lock(l) palacios_mutex_lock(l,0) #define palacios_spinlock_unlock(l) palacios_mutex_unlock(l) #define palacios_spinlock_lock_irqsave(l,f) do { f=(unsigned long)palacios_mutex_lock_irqsave(l,0); } while (0)