aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/xen/spinlock.h
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-10-23 11:53:52 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-10-23 11:53:52 +0100
commit10f097660035cec88e5f385e7f01d2902d639a4d (patch)
tree0f81b979fc01c36c2408870e8e9fdb9879f0ed16 /xen/include/xen/spinlock.h
parent33d21c38e4aa82c075c75e70bca94040d096fb9e (diff)
downloadxen-10f097660035cec88e5f385e7f01d2902d639a4d.tar.gz
xen-10f097660035cec88e5f385e7f01d2902d639a4d.tar.bz2
xen-10f097660035cec88e5f385e7f01d2902d639a4d.zip
spinlock: Add debug-build checks for IRQ-safe spinlocks.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/include/xen/spinlock.h')
-rw-r--r--xen/include/xen/spinlock.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h
index c49be63c5f..fec4264590 100644
--- a/xen/include/xen/spinlock.h
+++ b/xen/include/xen/spinlock.h
@@ -5,21 +5,38 @@
#include <asm/system.h>
#include <asm/spinlock.h>
+#ifndef NDEBUG
+struct lock_debug {
+ int irq_safe; /* +1: IRQ-safe; 0: not IRQ-safe; -1: don't know yet */
+};
+#define _LOCK_DEBUG { -1 }
+void spin_debug_enable(void);
+void spin_debug_disable(void);
+#else
+struct lock_debug { };
+#define _LOCK_DEBUG { }
+#define spin_debug_enable() ((void)0)
+#define spin_debug_disable() ((void)0)
+#endif
+
typedef struct {
raw_spinlock_t raw;
u16 recurse_cpu:12;
u16 recurse_cnt:4;
+ struct lock_debug debug;
} spinlock_t;
-#define SPIN_LOCK_UNLOCKED { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0 }
+
+#define SPIN_LOCK_UNLOCKED { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0, _LOCK_DEBUG }
#define DEFINE_SPINLOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
#define spin_lock_init(l) (*(l) = (spinlock_t)SPIN_LOCK_UNLOCKED)
typedef struct {
raw_rwlock_t raw;
+ struct lock_debug debug;
} rwlock_t;
-#define RW_LOCK_UNLOCKED { _RAW_RW_LOCK_UNLOCKED }
+#define RW_LOCK_UNLOCKED { _RAW_RW_LOCK_UNLOCKED, _LOCK_DEBUG }
#define DEFINE_RWLOCK(l) rwlock_t l = RW_LOCK_UNLOCKED
#define rwlock_init(l) (*(l) = (rwlock_t)RW_LOCK_UNLOCKED)