[PATCH v2 7/8] kvm tools: Add debug mode to brlock

Sasha Levin
2011-05-30T08:31:47Z

Adds a debug mode which allows to switch the brlock into
a big rwlock.
This can be used to verify we don't end up with a BKL kind
of lock with the current brlock implementation.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/include/kvm/brlock.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/include/kvm/brlock.h b/tools/kvm/include/kvm/brlock.h
index 1863166..4cc0521 100644
--- a/tools/kvm/include/kvm/brlock.h
+++ b/tools/kvm/include/kvm/brlock.h
@@ -17,9 +17,25 @@
#define barrier() __asm__ __volatile__("": : :"memory")
#endif

+#ifdef KVM_BRLOCK_DEBUG
+
+#include "kvm/rwsem.h"
+
+DECLARE_RWSEM(brlock_sem);
+
+#define br_read_lock() down_read(&brlock_sem);
+#define br_read_unlock() up_read(&brlock_sem);
+
+#define br_write_lock() down_write(&brlock_sem);
+#define br_write_unlock() up_write(&brlock_sem);
+
+#else
+
#define br_read_lock() barrier()
#define br_read_unlock() barrier()

#define br_write_lock() kvm__pause()
#define br_write_unlock() kvm__continue()
#endif
+
+#endif
--
1.7.5.rc3